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 && (