Skip to content

Commit

Permalink
fix: remove extra call to features on project load (#5690)
Browse files Browse the repository at this point in the history
Currently EnableEnvironmentDialog was loaded even if no feature was
touched. Now it will only load, if feature toggle was selected.
  • Loading branch information
sjaanus committed Dec 19, 2023
1 parent dce91b0 commit c979e68
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -14,6 +14,7 @@ import {
OnFeatureToggleSwitchArgs,
UseFeatureToggleSwitchType,
} from './FeatureToggleSwitch.types';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

type Middleware = (next: () => void) => void;

Expand Down Expand Up @@ -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={() => {
Expand All @@ -238,5 +248,8 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
</>
);

return { onToggle, modals };
return {
onToggle,
modals,
};
};

0 comments on commit c979e68

Please sign in to comment.