From 51449490fab44341cc4da9543d0e470aa63ce3f1 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:43:41 +1300 Subject: [PATCH] fix(app): on create don't mention previous values [EE-6837] (#11350) Co-authored-by: testa113 --- .../applications/create/createApplication.html | 2 +- .../resourceReservationValidation.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index a503bdc01..e80ab6d3b 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -290,7 +290,7 @@ min-cpu-limit="ctrl.state.sliders.cpu.min" max-memory-limit="ctrl.state.sliders.memory.max" max-cpu-limit="ctrl.state.sliders.cpu.max" - validation-data="{maxMemoryLimit: ctrl.state.sliders.memory.max, maxCpuLimit: ctrl.state.sliders.cpu.max, isEnvironmentAdmin: ctrl.isAdmin, nodeLimits: ctrl.nodesLimits.nodesLimits}" + validation-data="{isEdit: ctrl.state.isEdit, maxMemoryLimit: ctrl.state.sliders.memory.max, maxCpuLimit: ctrl.state.sliders.cpu.max, isEnvironmentAdmin: ctrl.isAdmin, nodeLimits: ctrl.nodesLimits.nodesLimits}" resource-quota-capacity-exceeded="ctrl.resourceQuotaCapacityExceeded()" > diff --git a/app/react/kubernetes/applications/components/ResourceReservationFormSection/resourceReservationValidation.ts b/app/react/kubernetes/applications/components/ResourceReservationFormSection/resourceReservationValidation.ts index 2648b9253..2a785cb5e 100644 --- a/app/react/kubernetes/applications/components/ResourceReservationFormSection/resourceReservationValidation.ts +++ b/app/react/kubernetes/applications/components/ResourceReservationFormSection/resourceReservationValidation.ts @@ -17,6 +17,7 @@ type ValidationData = { maxCpuLimit: number; isEnvironmentAdmin: boolean; nodeLimits: NodesLimits; + isEdit: boolean; }; export function resourceReservationValidation( @@ -34,10 +35,10 @@ export function resourceReservationValidation( }`, () => !!validationData && validationData.maxMemoryLimit > 0 ) - .max( - validationData?.maxMemoryLimit || 0, - ({ value }) => - `Value must be between 0 and ${validationData?.maxMemoryLimit}MB now - the previous value of ${value} exceeds this.` + .max(validationData?.maxMemoryLimit || 0, ({ value }) => + validationData?.isEdit + ? `Value must be between 0 and ${validationData?.maxMemoryLimit}MB now - the previous value of ${value} exceeds this.` + : `Value must be between 0 and ${validationData?.maxMemoryLimit}MB.` ) .test( 'hasSuitableNode', @@ -68,10 +69,10 @@ export function resourceReservationValidation( }`, () => !!validationData && validationData.maxCpuLimit > 0 ) - .max( - validationData?.maxCpuLimit || 0, - ({ value }) => - `Value must be between 0 and ${validationData?.maxCpuLimit} now - the previous value of ${value} exceeds this.` + .max(validationData?.maxCpuLimit || 0, ({ value }) => + validationData?.isEdit + ? `Value must be between 0 and ${validationData?.maxCpuLimit} now - the previous value of ${value} exceeds this.` + : `Value must be between 0 and ${validationData?.maxCpuLimit}.` ) .test( 'hasSuitableNode',