1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02: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, OnFeatureToggleSwitchArgs,
UseFeatureToggleSwitchType, UseFeatureToggleSwitchType,
} from './FeatureToggleSwitch.types'; } from './FeatureToggleSwitch.types';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
type Middleware = (next: () => void) => void; type Middleware = (next: () => void) => void;
@ -212,10 +213,19 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
[setProdGuardModalState], [setProdGuardModalState],
); );
const featureSelected = enableEnvironmentDialogState.featureId.length !== 0;
const modals = ( const modals = (
<> <>
<FeatureStrategyProdGuard {...prodGuardModalState} /> <FeatureStrategyProdGuard {...prodGuardModalState} />
<EnableEnvironmentDialog {...enableEnvironmentDialogState} /> <ConditionallyRender
condition={featureSelected}
show={
<EnableEnvironmentDialog
{...enableEnvironmentDialogState}
/>
}
/>
<ChangeRequestDialogue <ChangeRequestDialogue
isOpen={changeRequestDialogDetails.isOpen} isOpen={changeRequestDialogDetails.isOpen}
onClose={() => { onClose={() => {
@ -238,5 +248,8 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
</> </>
); );
return { onToggle, modals }; return {
onToggle,
modals,
};
}; };