mirror of https://github.com/portainer/portainer
fix(app): set values in react autoscaling form section [EE-6740] (#11220)
parent
a17da6d2cd
commit
bac1c28fa9
|
@ -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
|
||||
|
|
|
@ -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 && (
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 w-full gap-x-4 gap-y-2 my-3">
|
||||
|
|
Loading…
Reference in New Issue