Skip to content

Commit 8da5fe6

Browse files
authored
feat: strategy menu interaction between two dialogues. (#9732)
1 parent 48b9be7 commit 8da5fe6

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

frontend/src/component/feature/FeatureStrategy/FeatureStrategyMenu/FeatureReleasePlanCard/FeatureReleasePlanCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const StyledCard = styled('div')(({ theme }) => ({
3838
display: 'flex',
3939
flexDirection: 'column',
4040
width: '100%',
41+
height: '100%',
4142
maxWidth: '30rem',
4243
padding: theme.spacing(1.5, 2),
4344
color: 'inherit',

frontend/src/component/feature/FeatureStrategy/FeatureStrategyMenu/FeatureStrategyMenu.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,17 @@ export const FeatureStrategyMenu = ({
7070
matchWidth,
7171
disableReason,
7272
}: IFeatureStrategyMenuProps) => {
73-
const [anchor, setAnchor] = useState<Element>();
73+
const [isStrategyMenuDialogOpen, setIsStrategyMenuDialogOpen] =
74+
useState<boolean>(false);
7475
const [onlyReleasePlans, setOnlyReleasePlans] = useState<boolean>(false);
7576
const navigate = useNavigate();
7677
const { trackEvent } = usePlausibleTracker();
7778
const [selectedTemplate, setSelectedTemplate] =
7879
useState<IReleasePlanTemplate>();
7980
const [addReleasePlanOpen, setAddReleasePlanOpen] = useState(false);
80-
const isPopoverOpen = Boolean(anchor);
81-
const popoverId = isPopoverOpen ? 'FeatureStrategyMenuPopover' : undefined;
81+
const dialogId = isStrategyMenuDialogOpen
82+
? 'FeatureStrategyMenuDialog'
83+
: undefined;
8284
const { setToastApiError, setToastData } = useToast();
8385
const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId);
8486
const { addChange } = useChangeRequestApi();
@@ -93,7 +95,7 @@ export const FeatureStrategyMenu = ({
9395
releasePlansEnabled && isChangeRequestConfigured(environmentId);
9496

9597
const onClose = () => {
96-
setAnchor(undefined);
98+
setIsStrategyMenuDialogOpen(false);
9799
};
98100

99101
const openDefaultStrategyCreationModal = (event: React.SyntheticEvent) => {
@@ -107,12 +109,12 @@ export const FeatureStrategyMenu = ({
107109

108110
const openMoreStrategies = (event: React.SyntheticEvent) => {
109111
setOnlyReleasePlans(false);
110-
setAnchor(event.currentTarget);
112+
setIsStrategyMenuDialogOpen(true);
111113
};
112114

113115
const openReleasePlans = (event: React.SyntheticEvent) => {
114116
setOnlyReleasePlans(true);
115-
setAnchor(event.currentTarget);
117+
setIsStrategyMenuDialogOpen(true);
116118
};
117119

118120
const addReleasePlan = async (template: IReleasePlanTemplate) => {
@@ -158,6 +160,7 @@ export const FeatureStrategyMenu = ({
158160
} finally {
159161
setAddReleasePlanOpen(false);
160162
setSelectedTemplate(undefined);
163+
onClose();
161164
}
162165
};
163166

@@ -178,7 +181,7 @@ export const FeatureStrategyMenu = ({
178181
projectId={projectId}
179182
environmentId={environmentId}
180183
onClick={openReleasePlans}
181-
aria-labelledby={popoverId}
184+
aria-labelledby={dialogId}
182185
variant='outlined'
183186
sx={{ minWidth: matchWidth ? '282px' : 'auto' }}
184187
disabled={Boolean(disableReason)}
@@ -196,7 +199,7 @@ export const FeatureStrategyMenu = ({
196199
projectId={projectId}
197200
environmentId={environmentId}
198201
onClick={openDefaultStrategyCreationModal}
199-
aria-labelledby={popoverId}
202+
aria-labelledby={dialogId}
200203
variant={variant}
201204
sx={{ minWidth: matchWidth ? '282px' : 'auto' }}
202205
disabled={Boolean(disableReason)}
@@ -222,7 +225,7 @@ export const FeatureStrategyMenu = ({
222225
<MoreVert />
223226
</StyledAdditionalMenuButton>
224227
<Dialog
225-
open={isPopoverOpen}
228+
open={isStrategyMenuDialogOpen}
226229
onClose={onClose}
227230
maxWidth='md'
228231
PaperProps={{
@@ -244,6 +247,7 @@ export const FeatureStrategyMenu = ({
244247
onReviewReleasePlan={(template) => {
245248
setSelectedTemplate(template);
246249
setAddReleasePlanOpen(true);
250+
onClose();
247251
}}
248252
onClose={onClose}
249253
/>
@@ -252,7 +256,12 @@ export const FeatureStrategyMenu = ({
252256
{selectedTemplate && (
253257
<ReleasePlanReviewDialog
254258
open={addReleasePlanOpen}
255-
setOpen={setAddReleasePlanOpen}
259+
setOpen={(open) => {
260+
setAddReleasePlanOpen(open);
261+
if (!open) {
262+
setIsStrategyMenuDialogOpen(true);
263+
}
264+
}}
256265
onConfirm={() => {
257266
addReleasePlan(selectedTemplate);
258267
}}

frontend/src/component/feature/FeatureStrategy/FeatureStrategyMenu/FeatureStrategyMenuCard/FeatureStrategyMenuCard.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface IFeatureStrategyMenuCardProps {
1717
strategy: Pick<IStrategy, 'name' | 'displayName' | 'description'> &
1818
Partial<IStrategy>;
1919
defaultStrategy?: boolean;
20+
onClose: () => void;
2021
}
2122

2223
const StyledIcon = styled('div')(({ theme }) => ({
@@ -67,6 +68,7 @@ export const FeatureStrategyMenuCard = ({
6768
environmentId,
6869
strategy,
6970
defaultStrategy,
71+
onClose,
7072
}: IFeatureStrategyMenuCardProps) => {
7173
const StrategyIcon = getFeatureStrategyIcon(strategy.name);
7274
const strategyName = formatStrategyName(strategy.name);
@@ -86,6 +88,7 @@ export const FeatureStrategyMenuCard = ({
8688
buttonTitle: strategy.displayName || strategyName,
8789
},
8890
});
91+
onClose();
8992
};
9093

9194
return (

frontend/src/component/feature/FeatureStrategy/FeatureStrategyMenu/FeatureStrategyMenuCards/FeatureStrategyMenuCards.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface IFeatureStrategyMenuCardsProps {
2424
onlyReleasePlans: boolean;
2525
onAddReleasePlan: (template: IReleasePlanTemplate) => void;
2626
onReviewReleasePlan: (template: IReleasePlanTemplate) => void;
27-
onClose?: () => void;
27+
onClose: () => void;
2828
}
2929

3030
const StyledTypography = styled(Typography)(({ theme }) => ({
@@ -102,7 +102,6 @@ const StyledIcon = styled('div')(({ theme }) => ({
102102
alignItems: 'center',
103103
}));
104104

105-
// Empty state styling
106105
const EmptyStateContainer = styled(Box)(({ theme }) => ({
107106
display: 'flex',
108107
flexDirection: 'column',
@@ -170,16 +169,14 @@ export const FeatureStrategyMenuCards = ({
170169
<TitleText variant='h2'>
171170
{onlyReleasePlans ? 'Select template' : 'Select strategy'}
172171
</TitleText>
173-
{onClose && (
174-
<IconButton
175-
size='small'
176-
onClick={onClose}
177-
edge='end'
178-
aria-label='close'
179-
>
180-
<CloseIcon fontSize='small' />
181-
</IconButton>
182-
)}
172+
<IconButton
173+
size='small'
174+
onClick={onClose}
175+
edge='end'
176+
aria-label='close'
177+
>
178+
<CloseIcon fontSize='small' />
179+
</IconButton>
183180
</TitleRow>
184181
<ScrollableContent>
185182
{allStrategies ? (
@@ -203,6 +200,7 @@ export const FeatureStrategyMenuCards = ({
203200
environmentId={environmentId}
204201
strategy={defaultStrategy}
205202
defaultStrategy={true}
203+
onClose={onClose}
206204
/>
207205
</CardWrapper>
208206
{preDefinedStrategies.map((strategy) => (
@@ -212,6 +210,7 @@ export const FeatureStrategyMenuCards = ({
212210
featureId={featureId}
213211
environmentId={environmentId}
214212
strategy={strategy}
213+
onClose={onClose}
215214
/>
216215
</CardWrapper>
217216
))}
@@ -331,6 +330,7 @@ export const FeatureStrategyMenuCards = ({
331330
environmentId
332331
}
333332
strategy={strategy}
333+
onClose={onClose}
334334
/>
335335
</CardWrapper>
336336
))}

0 commit comments

Comments
 (0)