From 77c38306b2a8791163488cfe7a6e9ff7579111dc Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:20:24 +1300 Subject: [PATCH] fix(app): get min resource limits [EE-6567] (#10994) Co-authored-by: testa113 --- app/kubernetes/react/components/index.ts | 2 ++ .../views/applications/create/createApplication.html | 2 ++ .../components/form-components/Slider/SliderWithInput.tsx | 4 +++- .../ResourceReservationFormSection.tsx | 7 ++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/kubernetes/react/components/index.ts b/app/kubernetes/react/components/index.ts index 295e52ab5..c1bcb54aa 100644 --- a/app/kubernetes/react/components/index.ts +++ b/app/kubernetes/react/components/index.ts @@ -269,6 +269,8 @@ withFormValidation( [ 'namespaceHasQuota', 'resourceQuotaCapacityExceeded', + 'minMemoryLimit', + 'minCpuLimit', 'maxMemoryLimit', 'maxCpuLimit', ], diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index fb8cbad21..57a787ffa 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -283,6 +283,8 @@ values="{memoryLimit: ctrl.formValues.MemoryLimit, cpuLimit: ctrl.formValues.CpuLimit}" on-change="(ctrl.onChangeResourceReservation)" namespace-has-quota="ctrl.state.resourcePoolHasQuota" + min-memory-limit="ctrl.state.sliders.memory.min" + 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}" diff --git a/app/react/components/form-components/Slider/SliderWithInput.tsx b/app/react/components/form-components/Slider/SliderWithInput.tsx index b40d22d32..bfbff328f 100644 --- a/app/react/components/form-components/Slider/SliderWithInput.tsx +++ b/app/react/components/form-components/Slider/SliderWithInput.tsx @@ -6,6 +6,7 @@ export function SliderWithInput({ value, onChange, max, + min = 0, step = 1, dataCy, visibleTooltip = false, @@ -13,6 +14,7 @@ export function SliderWithInput({ value: number; onChange: (value: number) => void; max: number; + min?: number; dataCy: string; step?: number; visibleTooltip?: boolean; @@ -26,7 +28,7 @@ export function SliderWithInput({ onChange(typeof value === 'number' ? value : value[0]) } value={value} - min={0} + min={min} max={max} step={step} dataCy={`${dataCy}Slider`} diff --git a/app/react/kubernetes/applications/components/ResourceReservationFormSection/ResourceReservationFormSection.tsx b/app/react/kubernetes/applications/components/ResourceReservationFormSection/ResourceReservationFormSection.tsx index 1a5d8283c..b79dad502 100644 --- a/app/react/kubernetes/applications/components/ResourceReservationFormSection/ResourceReservationFormSection.tsx +++ b/app/react/kubernetes/applications/components/ResourceReservationFormSection/ResourceReservationFormSection.tsx @@ -15,6 +15,8 @@ type Props = { errors: FormikErrors; namespaceHasQuota: boolean; resourceQuotaCapacityExceeded: boolean; + minMemoryLimit: number; + minCpuLimit: number; maxMemoryLimit: number; maxCpuLimit: number; }; @@ -25,6 +27,8 @@ export function ResourceReservationFormSection({ errors, namespaceHasQuota, resourceQuotaCapacityExceeded, + minMemoryLimit, + minCpuLimit, maxMemoryLimit, maxCpuLimit, }: Props) { @@ -52,6 +56,7 @@ export function ResourceReservationFormSection({ onChange({ ...values, memoryLimit: value })} + min={minMemoryLimit} max={maxMemoryLimit} step={128} dataCy="k8sAppCreate-memoryLimit" @@ -79,7 +84,7 @@ export function ResourceReservationFormSection({ ) } value={values.cpuLimit} - min={0} + min={minCpuLimit} max={maxCpuLimit} step={0.1} dataCy="k8sAppCreate-cpuLimitSlider"