From bccf91f20b6541b6e6411b0812e8e052372e1a5b Mon Sep 17 00:00:00 2001 From: gaurav061 <60691495+gaurav061@users.noreply.github.com> Date: Fri, 19 Feb 2021 18:10:13 +0530 Subject: [PATCH] [#7024] Platform: Fixed edit number of nodes in AZ section (#7029) Description: The user was not able to edit the numbers of nodes from the AZ section while editing the universe. The issue was due to an undefined variable on the initial rendering. Added the API call to set the context for the number of nodes in the AZ section. Test scenario: Able to modify the number of nodes from the AZ section while editing the universe. --- .../universes/UniverseForm/AZSelectorTable.js | 20 ++++++++++++++++--- .../universes/UniverseForm/ClusterFields.js | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js b/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js index dc1f17bf32ac..586e3d34aa12 100644 --- a/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js +++ b/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js @@ -113,7 +113,7 @@ export default class AZSelectorTable extends Component { } = this.props; const universeTemplate = _.clone(universeConfigTemplate.data); const currentAZState = [...this.state.azItemState]; - const replicationFactor = currentPlacementStatus.replicationFactor; + const replicationFactor = currentPlacementStatus?.replicationFactor; const item = currentAZState.find(item => item.value === zoneId); const originalValue = item.count; let totalNumNodes = 0; @@ -403,10 +403,24 @@ export default class AZSelectorTable extends Component { UNSAFE_componentWillMount() { const { - universe: { currentUniverse, universeConfigTemplate }, + universe: { currentUniverse, universeConfigTemplate, currentPlacementStatus}, type, clusterType } = this.props; + + // If currentPlacementStatus is null the fetch it. + if(!currentPlacementStatus) { + const configTemplateCurrentCluster = isNonEmptyObject(universeConfigTemplate.data) + ? getClusterByType(universeConfigTemplate.data.clusters, clusterType) + : null; + const placementInfo = this.getGroupWithCounts(universeConfigTemplate.data); + const placementStatusObject = { + numUniqueRegions: placementInfo.uniqueRegions, + numUniqueAzs: placementInfo.uniqueAzs, + replicationFactor: configTemplateCurrentCluster.userIntent.replicationFactor + }; + this.props.setPlacementStatus(placementStatusObject); + } const currentCluster = getPromiseState(universeConfigTemplate).isSuccess() ? getClusterByType(universeConfigTemplate.data.clusters, clusterType) : {}; @@ -434,7 +448,7 @@ export default class AZSelectorTable extends Component { const placementInfo = this.getGroupWithCounts(universeConfigTemplate.data); const azGroups = placementInfo.groups; if ( - !areUniverseConfigsEqual( + !areUniverseConfigsEqual( this.props.universe.universeConfigTemplate.data, universeConfigTemplate.data ) diff --git a/managed/ui/src/components/universes/UniverseForm/ClusterFields.js b/managed/ui/src/components/universes/UniverseForm/ClusterFields.js index cf80f3665a51..1535f5ab6d92 100644 --- a/managed/ui/src/components/universes/UniverseForm/ClusterFields.js +++ b/managed/ui/src/components/universes/UniverseForm/ClusterFields.js @@ -1591,7 +1591,7 @@ export default class ClusterFields extends Component { ); } else if (currentProvider?.code === 'onprem'