1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: add badges to the new strategy configuration form (#5773)

This PR adds badges to display the amount of variants and constraints /
segments.

<img width="778" alt="Skjermbilde 2024-01-05 kl 10 12 39"
src="https://github.com/Unleash/unleash/assets/16081982/3a188d46-7d2f-4fa2-b2a9-e64a59d5ef09">
This commit is contained in:
Fredrik Strand Oseberg 2024-01-05 10:28:27 +01:00 committed by GitHub
parent 46ecce49a8
commit de7f6e035e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,6 +170,14 @@ const EnvironmentTypographyHeader = styled(Typography)(({ theme }) => ({
color: theme.palette.text.secondary,
}));
const StyledTab = styled(Tab)(({ theme }) => ({
width: '100px',
}));
const StyledBadge = styled(Badge)(({ theme }) => ({
marginLeft: theme.spacing(1),
}));
const feedbackCategory = 'newStrategyForm';
export const NewFeatureStrategyForm = ({
@ -324,6 +332,13 @@ export const NewFeatureStrategyForm = ({
setTab(newValue);
};
const getTargetingCount = () => {
const constraintCount = strategy.constraints?.length || 0;
const segmentCount = segments.length || 0;
return constraintCount + segmentCount;
};
return (
<>
<StyledHeaderBox>
@ -357,9 +372,25 @@ export const NewFeatureStrategyForm = ({
) : null}
</StyledHeaderBox>
<StyledTabs value={tab} onChange={handleChange}>
<Tab label='General' />
<Tab label='Targeting' />
<Tab label='Variants' />
<StyledTab label='General' />
<Tab
label={
<Typography>
Targeting
<StyledBadge>{getTargetingCount()}</StyledBadge>
</Typography>
}
/>
<Tab
label={
<Typography>
Variants
<StyledBadge>
{strategy.variants?.length}
</StyledBadge>
</Typography>
}
/>
</StyledTabs>
<StyledForm onSubmit={onSubmitWithValidation}>
<ConditionallyRender