From 9b4f091685c46647a3da04ecf6536cf4eeba62da Mon Sep 17 00:00:00 2001 From: gaurav061 Date: Fri, 29 Jan 2021 14:34:05 +0530 Subject: [PATCH] [#7024] Platform: Fixed edit number of nodes in Availability Zones section --- .../universes/UniverseForm/AZSelectorTable.js | 36 ++++++++++++++++--- .../universes/UniverseForm/ClusterFields.js | 2 +- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js b/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js index a6882fdc0075..53121b2d640d 100644 --- a/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js +++ b/managed/ui/src/components/universes/UniverseForm/AZSelectorTable.js @@ -107,11 +107,26 @@ export default class AZSelectorTable extends Component { handleAZNodeCountChange(zoneId, value) { const { - universe: { currentPlacementStatus, universeConfigTemplate } + universe: { currentPlacementStatus, universeConfigTemplate }, + clusterType } = this.props; + console.log("This props currentPlacementStatus", currentPlacementStatus) const universeTemplate = _.clone(universeConfigTemplate.data); const currentAZState = [...this.state.azItemState]; - const replicationFactor = currentPlacementStatus.replicationFactor; + const replicationFactor = currentPlacementStatus?.replicationFactor; + // if (!replicationFactor) { + // const configTemplateCurrentCluster = isNonEmptyObject(universeTemplate) + // ? getClusterByType(universeTemplate.clusters, clusterType) + // : null; + // const placementInfo = this.getGroupWithCounts(universeTemplate); + // const placementStatusObject = { + // numUniqueRegions: placementInfo.uniqueRegions, + // numUniqueAzs: placementInfo.uniqueAzs, + // replicationFactor: configTemplateCurrentCluster.userIntent.replicationFactor + // }; + // this.props.setPlacementStatus(placementStatusObject); + // console.log("CurrentPlacementStatus -- ", currentPlacementStatus); + // } const item = currentAZState.find(item => item.value === zoneId); const originalValue = item.count; let totalNumNodes = 0; @@ -397,10 +412,23 @@ export default class AZSelectorTable extends Component { UNSAFE_componentWillMount() { const { - universe: { currentUniverse, universeConfigTemplate }, + universe: { currentUniverse, universeConfigTemplate, currentPlacementStatus}, type, clusterType } = this.props; + + 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) : {}; @@ -428,7 +456,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 129d533adbae..e9f779a16aa3 100644 --- a/managed/ui/src/components/universes/UniverseForm/ClusterFields.js +++ b/managed/ui/src/components/universes/UniverseForm/ClusterFields.js @@ -1534,7 +1534,7 @@ export default class ClusterFields extends Component { ); } else if (currentProvider?.code === 'onprem'