Skip to content

Commit 0542fef

Browse files
chore(1 3493): handle cases with no strategies (#9563)
Handle cases where flags have no strategies in the playground. As part of this, also changes how we deal with the padding/margins in the playground: instead of making all but one items in the playground have to explicitly add padding, now we instead say that the only item that needs to do something is the list, which uses negative inline margins. This also has the added benefit of adding all the top-level elements (that is: that's not part of the strategy lists) inside the same container, so we can control gaps between them with flex's gaps. When you have no strategies (before): ![image](https://github.com/user-attachments/assets/52c85ba4-0738-4aa7-b2ac-84e5f0f65b45) When you have no strategies (after): ![image](https://github.com/user-attachments/assets/80f5ce75-29e5-4b6d-b707-213cb79d53cc)
1 parent 9bdad5e commit 0542fef

File tree

3 files changed

+20
-30
lines changed

3 files changed

+20
-30
lines changed

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

+7-15
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@ const LegacyFeatureResultInfoPopoverCell = ({
7474
);
7575
};
7676

77-
const DetailsPadding = styled('div')(({ theme }) => ({
78-
paddingInline: `var(--popover-inline-padding, ${theme.spacing(4)})`,
79-
paddingTop: theme.spacing(2.5),
80-
display: 'flex',
81-
flexDirection: 'column',
82-
gap: theme.spacing(2),
83-
}));
84-
8577
export const NewFeatureResultInfoPopoverCell = ({
8678
feature,
8779
input,
@@ -105,6 +97,8 @@ export const NewFeatureResultInfoPopoverCell = ({
10597
PaperProps={{
10698
sx: (theme) => ({
10799
'--popover-inline-padding': theme.spacing(4),
100+
paddingInline: 'var(--popover-inline-padding)',
101+
paddingBlock: theme.spacing(3),
108102
display: 'flex',
109103
flexDirection: 'column',
110104
width: 728,
@@ -125,13 +119,11 @@ export const NewFeatureResultInfoPopoverCell = ({
125119
horizontal: 'left',
126120
}}
127121
>
128-
<DetailsPadding>
129-
<FeatureDetails
130-
feature={feature}
131-
input={input}
132-
onClose={() => setOpen(false)}
133-
/>
134-
</DetailsPadding>
122+
<FeatureDetails
123+
feature={feature}
124+
input={input}
125+
onClose={() => setOpen(false)}
126+
/>
135127
<PlaygroundResultFeatureStrategyList
136128
feature={feature}
137129
input={input}

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1+
import { Alert } from '@mui/material';
12
import { PlaygroundResultStrategyLists } from './StrategyList/PlaygroundResultStrategyLists';
23
import type { PlaygroundFeatureSchema, PlaygroundRequestSchema } from 'openapi';
3-
import { Alert, styled } from '@mui/material';
44
import type { FC } from 'react';
55

66
interface PlaygroundResultFeatureStrategyListProps {
77
feature: PlaygroundFeatureSchema;
88
input?: PlaygroundRequestSchema;
99
}
1010

11-
const StyledAlert = styled(Alert)(({ theme }) => ({
12-
marginInline: `var(--popover-inline-padding, ${theme.spacing(4)})`,
13-
}));
14-
1511
const UnevaluatedUnsatisfiedInfo: FC<{ feature: PlaygroundFeatureSchema }> = ({
1612
feature,
1713
}) => {
@@ -36,11 +32,11 @@ const UnevaluatedUnsatisfiedInfo: FC<{ feature: PlaygroundFeatureSchema }> = ({
3632
}
3733

3834
return (
39-
<StyledAlert severity={'info'} color={'info'}>
35+
<Alert severity={'info'} color={'info'}>
4036
{text}, then this feature flag would be{' '}
4137
{feature.strategies?.result ? 'TRUE' : 'FALSE'} with strategies
4238
evaluated like this:
43-
</StyledAlert>
39+
</Alert>
4440
);
4541
};
4642

@@ -59,7 +55,7 @@ export const PlaygroundResultFeatureStrategyList = ({
5955

6056
if ((feature?.strategies?.data.length ?? 0) === 0) {
6157
return (
62-
<Alert severity='warning' sx={{ mt: 2 }}>
58+
<Alert severity='info'>
6359
There are no strategies added to this feature flag in the
6460
selected environment.
6561
</Alert>

frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/PlaygroundResultStrategyLists.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ interface PlaygroundResultStrategyListProps {
3636
infoText?: string;
3737
}
3838
const StyledHeaderGroup = styled('hgroup')(({ theme }) => ({
39-
paddingInline: `var(--popover-inline-padding, ${theme.spacing(4)})`,
4039
paddingBottom: theme.spacing(2),
41-
borderBottom: `1px solid ${theme.palette.divider}`,
4240
}));
4341

4442
const StyledListTitle = styled('h4')(({ theme }) => ({
@@ -52,8 +50,12 @@ const StyledListTitleDescription = styled('p')(({ theme }) => ({
5250
fontSize: theme.typography.body2.fontSize,
5351
}));
5452

55-
const StyledFeatureStrategyItem = styled(FeatureStrategyItem)(({ theme }) => ({
56-
paddingInline: `var(--popover-inline-padding, ${theme.spacing(4)})`,
53+
const RestyledContentList = styled(StyledContentList)(({ theme }) => ({
54+
marginInline: `calc(var(--popover-inline-padding) * -1)`,
55+
borderTop: `1px solid ${theme.palette.divider}`,
56+
'> li:last-of-type': {
57+
paddingBottom: 0,
58+
},
5759
}));
5860

5961
export const PlaygroundResultStrategyLists = ({
@@ -80,17 +82,17 @@ export const PlaygroundResultStrategyLists = ({
8082
</StyledListTitleDescription>
8183
) : null}
8284
</StyledHeaderGroup>
83-
<StyledContentList>
85+
<RestyledContentList>
8486
{strategies?.map((strategy, index) => (
8587
<StyledListItem key={strategy.id}>
8688
{index > 0 ? <StrategySeparator /> : ''}
87-
<StyledFeatureStrategyItem
89+
<FeatureStrategyItem
8890
strategy={strategy}
8991
input={input}
9092
/>
9193
</StyledListItem>
9294
))}
93-
</StyledContentList>
95+
</RestyledContentList>
9496
</div>
9597
);
9698
};

0 commit comments

Comments
 (0)