Skip to content

Commit

Permalink
[BACKPORT 2.20.3][PLAT-13445]: Edit universe modal with dedicated mas…
Browse files Browse the repository at this point in the history
…ters 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
  • Loading branch information
rajmaddy89 committed Apr 6, 2024
1 parent 97f857c commit 05ceb5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Expand Up @@ -15,6 +15,7 @@ interface MasterPlacementFieldProps {
isPrimary: boolean;
useK8CustomResources: boolean;
disabled: boolean;
isEditMode: boolean;
}

const useStyles = makeStyles((theme) => ({
Expand All @@ -33,7 +34,8 @@ const useStyles = makeStyles((theme) => ({
export const MasterPlacementField = ({
isPrimary,
useK8CustomResources,
disabled
disabled,
isEditMode
}: MasterPlacementFieldProps): ReactElement => {
const { control, setValue } = useFormContext<UniverseFormData>();
const classes = useStyles();
Expand All @@ -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]);
Expand Down
Expand Up @@ -102,6 +102,7 @@ export const CloudConfiguration = ({ runtimeConfigs }: UniverseFormConfiguration
isPrimary={isPrimary}
useK8CustomResources={useK8CustomResources}
disabled={isViewMode}
isEditMode={isEditMode}
/>
</Box>
)}
Expand Down

0 comments on commit 05ceb5b

Please sign in to comment.