From bac1c28fa95062e5ba0d8f296db7acf73a40f15a Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:35:32 +1300 Subject: [PATCH] fix(app): set values in react autoscaling form section [EE-6740] (#11220) --- .../create/createApplicationController.js | 11 ----------- .../AutoScalingFormSection.tsx | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index c167a901f..8177f362e 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -293,17 +293,6 @@ class KubernetesCreateApplicationController { /* #region AUTO SCALER UI MANAGEMENT */ onAutoScaleChange(values) { return this.$async(async () => { - // when enabling the auto scaler, set the default values - if (!this.formValues.AutoScaler.isUsed && values.isUsed) { - this.formValues.AutoScaler = { - isUsed: values.isUsed, - minReplicas: 1, - maxReplicas: 3, - targetCpuUtilizationPercentage: 50, - }; - return; - } - // otherwise, just update the values this.formValues.AutoScaler = values; // reset it to previous form values if the user disables the auto scaler diff --git a/app/react/kubernetes/applications/components/AutoScalingFormSection/AutoScalingFormSection.tsx b/app/react/kubernetes/applications/components/AutoScalingFormSection/AutoScalingFormSection.tsx index fa0600aaf..062282d56 100644 --- a/app/react/kubernetes/applications/components/AutoScalingFormSection/AutoScalingFormSection.tsx +++ b/app/react/kubernetes/applications/components/AutoScalingFormSection/AutoScalingFormSection.tsx @@ -32,12 +32,22 @@ export function AutoScalingFormSection({ label="Enable auto scaling for this application" labelClass="col-sm-3 col-lg-2" checked={values.isUsed} - onChange={(value: boolean) => + onChange={(value: boolean) => { + // when enabling the auto scaler, set the default values + const newValues = + !values.isUsed && value + ? { + minReplicas: 1, + maxReplicas: 3, + targetCpuUtilizationPercentage: 50, + } + : {}; onChange({ ...values, + ...newValues, isUsed: value, - }) - } + }); + }} /> {values.isUsed && (