From 05ceb5b37b5f1c25a4216dfdbad14769541e71c8 Mon Sep 17 00:00:00 2001 From: Rajagopalan Madhavan Date: Sat, 6 Apr 2024 12:05:25 -0400 Subject: [PATCH] [BACKPORT 2.20.3][PLAT-13445]: Edit universe modal with dedicated masters shows wrong info Summary: 1. User creates a dedciated universe 2. User edits the universe, the rendering logic added in diff D33566 sets the master p;acement field to COLOCATED mode by default, this is right behavior but needs to be set only in CREATE mode not in EDIT mode 3. The new logic displays the master placement info based on API response and does not do any rendering logic in useEffect when in EDIT mode Diff fix for master: D33893 Test Plan: Please refer to the video {F167592} Reviewers: jmak, nbhatia Reviewed By: jmak Subscribers: aaruj, yugaware Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D33895 --- .../MasterPlacementField.tsx | 22 +++++++++---------- .../sections/cloud/CloudConfiguration.tsx | 1 + 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/managed/ui/src/redesign/features/universe/universe-form/form/fields/MasterPlacementField/MasterPlacementField.tsx b/managed/ui/src/redesign/features/universe/universe-form/form/fields/MasterPlacementField/MasterPlacementField.tsx index 8aa6820d425..53eb7f86fe5 100644 --- a/managed/ui/src/redesign/features/universe/universe-form/form/fields/MasterPlacementField/MasterPlacementField.tsx +++ b/managed/ui/src/redesign/features/universe/universe-form/form/fields/MasterPlacementField/MasterPlacementField.tsx @@ -15,6 +15,7 @@ interface MasterPlacementFieldProps { isPrimary: boolean; useK8CustomResources: boolean; disabled: boolean; + isEditMode: boolean; } const useStyles = makeStyles((theme) => ({ @@ -33,7 +34,8 @@ const useStyles = makeStyles((theme) => ({ export const MasterPlacementField = ({ isPrimary, useK8CustomResources, - disabled + disabled, + isEditMode }: MasterPlacementFieldProps): ReactElement => { const { control, setValue } = useFormContext(); const classes = useStyles(); @@ -47,21 +49,17 @@ export const MasterPlacementField = ({ const provider = useWatch({ name: PROVIDER_FIELD }); useEffect(() => { - if (!isPrimary) { - setValue(MASTER_PLACEMENT_FIELD, MasterPlacementMode.COLOCATED); - } - if (isPrimary) { - if (provider?.code === CloudType.kubernetes) { + // Master Placement field should not be changed in edit mode during onMount + if (!isEditMode) { + if (!isPrimary) { + setValue(MASTER_PLACEMENT_FIELD, MasterPlacementMode.COLOCATED); + } else if (provider?.code === CloudType.kubernetes) { setValue( MASTER_PLACEMENT_FIELD, useK8CustomResources ? MasterPlacementMode.DEDICATED : MasterPlacementMode.COLOCATED ); - } - else{ - setValue( - MASTER_PLACEMENT_FIELD, - MasterPlacementMode.COLOCATED - ); + } else { + setValue(MASTER_PLACEMENT_FIELD, MasterPlacementMode.COLOCATED); } } }, [isPrimary, provider]); diff --git a/managed/ui/src/redesign/features/universe/universe-form/form/sections/cloud/CloudConfiguration.tsx b/managed/ui/src/redesign/features/universe/universe-form/form/sections/cloud/CloudConfiguration.tsx index df2723d484b..d719181c535 100644 --- a/managed/ui/src/redesign/features/universe/universe-form/form/sections/cloud/CloudConfiguration.tsx +++ b/managed/ui/src/redesign/features/universe/universe-form/form/sections/cloud/CloudConfiguration.tsx @@ -102,6 +102,7 @@ export const CloudConfiguration = ({ runtimeConfigs }: UniverseFormConfiguration isPrimary={isPrimary} useK8CustomResources={useK8CustomResources} disabled={isViewMode} + isEditMode={isEditMode} /> )}