1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

Fix: laggy toggles (#3873)

This PR removes the `disabled` state for the feature toggle env
switches.

This is what causes the lag from when you toggle the switch to when it
becomes available for actions again.


Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: Nuno Góis <github@nunogois.com>
This commit is contained in:
andreas-unleash 2023-05-26 17:42:42 +03:00 committed by GitHub
parent c7d8c9fd25
commit 89df3f364e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,13 +134,13 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
onChangeRequestToggle(
feature.name,
environmentName,
!value,
!isChecked,
false
);
}
return;
}
if (value) {
if (isChecked) {
await handleToggleEnvironmentOff();
return;
}
@ -159,7 +159,12 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
},
});
if (isChangeRequestConfigured(environmentName)) {
onChangeRequestToggle(feature.name, environmentName, !value, true);
onChangeRequestToggle(
feature.name,
environmentName,
!isChecked,
true
);
} else {
await handleToggleEnvironmentOn(true);
}
@ -173,7 +178,12 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
},
});
if (isChangeRequestConfigured(environmentName)) {
onChangeRequestToggle(feature.name, environmentName, !value, false);
onChangeRequestToggle(
feature.name,
environmentName,
!isChecked,
false
);
} else {
await handleToggleEnvironmentOn();
}
@ -201,7 +211,7 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
>
<PermissionSwitch
tooltip={
value
isChecked
? `Disable feature in ${environmentName}`
: `Enable feature in ${environmentName}`
}
@ -211,7 +221,6 @@ export const FeatureToggleSwitch: VFC<IFeatureToggleSwitchProps> = ({
permission={UPDATE_FEATURE_ENVIRONMENT}
inputProps={{ 'aria-label': environmentName }}
onClick={onClick}
disabled={isChecked !== value}
/>
</StyledBoxContainer>
{showStrategyImprovements && (