From 8ad63bc03557083262f7fd8e0acaedaac9488484 Mon Sep 17 00:00:00 2001 From: David Leek Date: Thu, 12 Dec 2024 11:27:32 +0100 Subject: [PATCH] feat: make segments editing work with template milestone strategies (#8964) --- .../ReleasePlanTemplate/MilestoneCard.tsx | 3 --- .../ReleasePlanTemplateAddStrategyForm.tsx | 23 ++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/releases/ReleasePlanTemplate/MilestoneCard.tsx b/frontend/src/component/releases/ReleasePlanTemplate/MilestoneCard.tsx index ea798726d246..6963c545bf1e 100644 --- a/frontend/src/component/releases/ReleasePlanTemplate/MilestoneCard.tsx +++ b/frontend/src/component/releases/ReleasePlanTemplate/MilestoneCard.tsx @@ -81,9 +81,6 @@ const StyledAccordion = styled(Accordion)(({ theme }) => ({ }, transition: 'background-color 0.2s ease-in-out', backgroundColor: theme.palette.background.default, - '&:hover': { - backgroundColor: theme.palette.neutral.light, - }, '&.Mui-expanded': { marginTop: theme.spacing(3), }, diff --git a/frontend/src/component/releases/ReleasePlanTemplate/ReleasePlanTemplateAddStrategyForm.tsx b/frontend/src/component/releases/ReleasePlanTemplate/ReleasePlanTemplateAddStrategyForm.tsx index bd6c2acb920f..ab006e2745a5 100644 --- a/frontend/src/component/releases/ReleasePlanTemplate/ReleasePlanTemplateAddStrategyForm.tsx +++ b/frontend/src/component/releases/ReleasePlanTemplate/ReleasePlanTemplateAddStrategyForm.tsx @@ -152,10 +152,31 @@ export const ReleasePlanTemplateAddStrategyForm = ({ ? String(currentStrategy.parameters.stickiness) : 'default'; + const segmentsMap = allSegments?.reduce( + (acc, segment) => { + acc[segment.id] = segment; + return acc; + }, + {} as Record, + ); + useEffect(() => { - setSegments([]); + if (segmentsMap) { + setSegments( + (currentStrategy?.segments || []).map((segment) => { + return segmentsMap[segment]; + }), + ); + } }, []); + useEffect(() => { + setCurrentStrategy((prev) => ({ + ...prev, + segments: segments.map((segment) => segment.id), + })); + }, [segments]); + useEffect(() => { setCurrentStrategy((prev) => ({ ...prev,