From c979e687caa574c31dfa28d79bda509dce8710d8 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Tue, 19 Dec 2023 21:03:24 +0200 Subject: [PATCH] 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. --- .../useFeatureToggleSwitch.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/FeatureToggleSwitch/useFeatureToggleSwitch.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/FeatureToggleSwitch/useFeatureToggleSwitch.tsx index bcb769207d..51c51bbe0e 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/FeatureToggleSwitch/useFeatureToggleSwitch.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/FeatureToggleSwitch/useFeatureToggleSwitch.tsx @@ -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 = ( <> - + + } + /> { @@ -238,5 +248,8 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = ( ); - return { onToggle, modals }; + return { + onToggle, + modals, + }; };