From 360687056563d60c9351b46ae2e7d965c144f3c1 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:28:56 -0700 Subject: [PATCH] Fixed field reset for memory & cpu fields in new tenant size screen (#1593) Also fixed an issue with memory limit selection in create tenant Signed-off-by: Benjamin Perez --- .../Console/Tenants/AddTenant/AddTenant.tsx | 6 +++--- .../Tenants/AddTenant/Steps/SizePreview.tsx | 14 ++------------ .../Steps/TenantResources/TenantSizeResources.tsx | 9 +++++++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/portal-ui/src/screens/Console/Tenants/AddTenant/AddTenant.tsx b/portal-ui/src/screens/Console/Tenants/AddTenant/AddTenant.tsx index f77f7ebbc..e121e967c 100644 --- a/portal-ui/src/screens/Console/Tenants/AddTenant/AddTenant.tsx +++ b/portal-ui/src/screens/Console/Tenants/AddTenant/AddTenant.tsx @@ -29,7 +29,7 @@ import { wizardCommon, } from "../../Common/FormComponents/common/styleLibrary"; import api from "../../../../common/api"; -import { generatePoolName } from "../../../../common/utils"; +import { generatePoolName, getBytes } from "../../../../common/utils"; import GenericWizard from "../../Common/GenericWizard/GenericWizard"; import { IWizardElement } from "../../Common/GenericWizard/types"; import { NewServiceAccount } from "../../Common/CredentialsPrompt/types"; @@ -280,7 +280,7 @@ const AddTenant = ({ } if (fields.tenantSize.resourcesMemoryRequest !== "") { dataSend.pools[0].resources.requests.memory = parseInt( - fields.tenantSize.resourcesMemoryRequest + getBytes(fields.tenantSize.resourcesMemoryRequest, "Gi", true) ); } } @@ -297,7 +297,7 @@ const AddTenant = ({ } if (fields.tenantSize.resourcesMemoryLimit !== "") { dataSend.pools[0].resources.limits.memory = parseInt( - fields.tenantSize.resourcesMemoryLimit + getBytes(fields.tenantSize.resourcesMemoryLimit, "Gi", true) ); } } diff --git a/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx b/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx index e820a90f9..cd3e9a7ef 100644 --- a/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx +++ b/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx @@ -74,21 +74,11 @@ const styles = (theme: Theme) => const SizePreview = ({ classes, - updateAddField, - isPageValid, - volumeSize, - sizeFactor, - drivesPerServer, nodes, memoryNode, ecParity, - ecParityChoices, - cleanECChoices, - resourcesSize, distribution, ecParityCalc, - limitSize, - selectedStorageClass, cpuToUse, integrationSelection, }: ISizePreviewProps) => { @@ -253,7 +243,7 @@ const mapState = (state: AppState) => ({ sizeFactor: state.tenants.createTenant.fields.tenantSize.sizeFactor, drivesPerServer: state.tenants.createTenant.fields.tenantSize.drivesPerServer, nodes: state.tenants.createTenant.fields.tenantSize.nodes, - memoryNode: state.tenants.createTenant.fields.tenantSize.memoryNode, + memoryNode: state.tenants.createTenant.fields.tenantSize.resourcesMemoryRequest, ecParity: state.tenants.createTenant.fields.tenantSize.ecParity, ecParityChoices: state.tenants.createTenant.fields.tenantSize.ecParityChoices, cleanECChoices: state.tenants.createTenant.fields.tenantSize.cleanECChoices, @@ -263,7 +253,7 @@ const mapState = (state: AppState) => ({ limitSize: state.tenants.createTenant.fields.tenantSize.limitSize, selectedStorageClass: state.tenants.createTenant.fields.nameTenant.selectedStorageClass, - cpuToUse: state.tenants.createTenant.fields.tenantSize.cpuToUse, + cpuToUse: state.tenants.createTenant.fields.tenantSize.resourcesCPURequest, integrationSelection: state.tenants.createTenant.fields.tenantSize.integrationSelection, }); diff --git a/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx b/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx index 24fd2ec36..ff4bbcbc5 100644 --- a/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx +++ b/portal-ui/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx @@ -176,14 +176,19 @@ const TenantSizeResources = ({ ); const baseCpuUse = Math.max(1, floor(maxAllocatableCPU / 2)); - updateField("resourcesCPURequest", baseCpuUse); + if (resourcesCPURequest === "") { + updateField("resourcesCPURequest", baseCpuUse); + } const baseMemoryUse = Math.max(2, floor(maxMemory / 2)); - updateField("resourcesMemoryRequest", baseMemoryUse); + if (resourcesMemoryRequest === "") { + updateField("resourcesMemoryRequest", baseMemoryUse); + } }) .catch((err: any) => { updateField("maxMemorySize", 0); updateField("resourcesCPURequest", ""); + updateField("resourcesMemoryRequest", ""); console.error(err); });