Skip to content

Commit 99895d9

Browse files
Rename DisabledInfo to DisabledEnvInfo and refactor impl
1 parent 37f0c6f commit 99895d9

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/PlaygroundResultsFeatureStrategyList.tsx

+13-21
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,26 @@ const StyledAlert = styled(Alert)(({ theme }) => ({
1111
marginInline: `var(--popover-inline-padding, ${theme.spacing(4)})`,
1212
}));
1313

14-
const DisabledInfo = ({ feature }: { feature: PlaygroundFeatureSchema }) => {
15-
const resolveHintText = (feature: PlaygroundFeatureSchema) => {
16-
if (
17-
feature.hasUnsatisfiedDependency &&
18-
!feature.isEnabledInCurrentEnvironment
19-
) {
20-
return 'If the environment was enabled and parent dependencies were satisfied';
21-
}
22-
if (feature.hasUnsatisfiedDependency) {
23-
return 'If parent dependencies were satisfied';
24-
}
25-
if (!feature.isEnabledInCurrentEnvironment) {
26-
return 'If the environment was enabled';
27-
}
28-
return '';
29-
};
30-
31-
const text = resolveHintText(feature);
14+
const DisabledEnvInfo = ({ feature }: { feature: PlaygroundFeatureSchema }) => {
15+
const text =
16+
feature.hasUnsatisfiedDependency &&
17+
!feature.isEnabledInCurrentEnvironment
18+
? 'If the environment was enabled and parent dependencies were satisfied'
19+
: feature.hasUnsatisfiedDependency
20+
? 'If parent dependencies were satisfied'
21+
: !feature.isEnabledInCurrentEnvironment
22+
? 'If the environment was enabled'
23+
: '';
3224

3325
if (!text) {
3426
return null;
3527
}
3628

3729
return (
3830
<StyledAlert severity={'info'} color={'info'}>
39-
{resolveHintText(feature)}, then this feature flag would be{' '}
31+
{text}, then this feature flag would be{' '}
4032
{feature.strategies?.result ? 'TRUE' : 'FALSE'} with strategies
41-
evaluated like this:{' '}
33+
evaluated like this:
4234
</StyledAlert>
4335
);
4436
};
@@ -67,7 +59,7 @@ export const PlaygroundResultFeatureStrategyList = ({
6759

6860
return (
6961
<>
70-
<DisabledInfo feature={feature} />
62+
<DisabledEnvInfo feature={feature} />
7163
<PlaygroundResultStrategyLists
7264
strategies={enabledStrategies || []}
7365
input={input}

0 commit comments

Comments
 (0)