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 */
|
/* #region AUTO SCALER UI MANAGEMENT */
|
||||||
onAutoScaleChange(values) {
|
onAutoScaleChange(values) {
|
||||||
return this.$async(async () => {
|
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;
|
this.formValues.AutoScaler = values;
|
||||||
|
|
||||||
// reset it to previous form values if the user disables the auto scaler
|
// 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"
|
label="Enable auto scaling for this application"
|
||||||
labelClass="col-sm-3 col-lg-2"
|
labelClass="col-sm-3 col-lg-2"
|
||||||
checked={values.isUsed}
|
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({
|
onChange({
|
||||||
...values,
|
...values,
|
||||||
|
...newValues,
|
||||||
isUsed: value,
|
isUsed: value,
|
||||||
})
|
});
|
||||||
}
|
}}
|
||||||
/>
|
/>
|
||||||
{values.isUsed && (
|
{values.isUsed && (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 w-full gap-x-4 gap-y-2 my-3">
|
<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