1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-23 00:16:25 +01:00

feat: make segments editing work with template milestone strategies (#8964)

This commit is contained in:
David Leek 2024-12-12 11:27:32 +01:00 committed by GitHub
parent 828ecf8d63
commit 8ad63bc035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View File

@ -81,9 +81,6 @@ const StyledAccordion = styled(Accordion)(({ theme }) => ({
}, },
transition: 'background-color 0.2s ease-in-out', transition: 'background-color 0.2s ease-in-out',
backgroundColor: theme.palette.background.default, backgroundColor: theme.palette.background.default,
'&:hover': {
backgroundColor: theme.palette.neutral.light,
},
'&.Mui-expanded': { '&.Mui-expanded': {
marginTop: theme.spacing(3), marginTop: theme.spacing(3),
}, },

View File

@ -152,10 +152,31 @@ export const ReleasePlanTemplateAddStrategyForm = ({
? String(currentStrategy.parameters.stickiness) ? String(currentStrategy.parameters.stickiness)
: 'default'; : 'default';
const segmentsMap = allSegments?.reduce(
(acc, segment) => {
acc[segment.id] = segment;
return acc;
},
{} as Record<string, ISegment>,
);
useEffect(() => { useEffect(() => {
setSegments([]); if (segmentsMap) {
setSegments(
(currentStrategy?.segments || []).map((segment) => {
return segmentsMap[segment];
}),
);
}
}, []); }, []);
useEffect(() => {
setCurrentStrategy((prev) => ({
...prev,
segments: segments.map((segment) => segment.id),
}));
}, [segments]);
useEffect(() => { useEffect(() => {
setCurrentStrategy((prev) => ({ setCurrentStrategy((prev) => ({
...prev, ...prev,