1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: remove extra call to features on project load (#5690)

Currently EnableEnvironmentDialog was loaded even if no feature was
touched. Now it will only load, if feature toggle was selected.
This commit is contained in:
Jaanus Sellin 2023-12-19 21:03:24 +02:00 committed by GitHub
parent dce91b0e90
commit c979e687ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ import {
OnFeatureToggleSwitchArgs,
UseFeatureToggleSwitchType,
} from './FeatureToggleSwitch.types';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
type Middleware = (next: () => void) => void;
@ -212,10 +213,19 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
[setProdGuardModalState],
);
const featureSelected = enableEnvironmentDialogState.featureId.length !== 0;
const modals = (
<>
<FeatureStrategyProdGuard {...prodGuardModalState} />
<EnableEnvironmentDialog {...enableEnvironmentDialogState} />
<ConditionallyRender
condition={featureSelected}
show={
<EnableEnvironmentDialog
{...enableEnvironmentDialogState}
/>
}
/>
<ChangeRequestDialogue
isOpen={changeRequestDialogDetails.isOpen}
onClose={() => {
@ -238,5 +248,8 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
</>
);
return { onToggle, modals };
return {
onToggle,
modals,
};
};