mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
chore: persist strategy filter when going back from release template preview (#10663)
https://linear.app/unleash/issue/2-3878/persist-strategy-filter-when-going-back-from-the-release-template Persists the strategy filter in the new "add strategy" modal when going back from the release template preview modal. This is done by moving the filter to the parent component, so the filter state persists across these navigations. Also updates the button text in the release templates preview to say "Apply template" for consistency, but only if the `newStrategyModal` flag is enabled.
This commit is contained in:
parent
7d70f8fc55
commit
2e2840e690
@ -20,7 +20,10 @@ import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
|||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { ReleasePlanReviewDialog } from '../../FeatureView/FeatureOverview/ReleasePlan/ReleasePlanReviewDialog.tsx';
|
import { ReleasePlanReviewDialog } from '../../FeatureView/FeatureOverview/ReleasePlan/ReleasePlanReviewDialog.tsx';
|
||||||
import { FeatureStrategyMenuCards } from './FeatureStrategyMenuCards/FeatureStrategyMenuCards.tsx';
|
import {
|
||||||
|
FeatureStrategyMenuCards,
|
||||||
|
type StrategyFilterValue,
|
||||||
|
} from './FeatureStrategyMenuCards/FeatureStrategyMenuCards.tsx';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag.ts';
|
import { useUiFlag } from 'hooks/useUiFlag.ts';
|
||||||
|
|
||||||
interface IFeatureStrategyMenuProps {
|
interface IFeatureStrategyMenuProps {
|
||||||
@ -61,6 +64,7 @@ export const FeatureStrategyMenu = ({
|
|||||||
const [isStrategyMenuDialogOpen, setIsStrategyMenuDialogOpen] =
|
const [isStrategyMenuDialogOpen, setIsStrategyMenuDialogOpen] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
const [onlyReleasePlans, setOnlyReleasePlans] = useState<boolean>(false);
|
const [onlyReleasePlans, setOnlyReleasePlans] = useState<boolean>(false);
|
||||||
|
const [filter, setFilter] = useState<StrategyFilterValue>(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { trackEvent } = usePlausibleTracker();
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const [selectedTemplate, setSelectedTemplate] =
|
const [selectedTemplate, setSelectedTemplate] =
|
||||||
@ -251,6 +255,8 @@ export const FeatureStrategyMenu = ({
|
|||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
featureId={featureId}
|
featureId={featureId}
|
||||||
environmentId={environmentId}
|
environmentId={environmentId}
|
||||||
|
filter={filter}
|
||||||
|
setFilter={setFilter}
|
||||||
onAddReleasePlan={(template) => {
|
onAddReleasePlan={(template) => {
|
||||||
setSelectedTemplate(template);
|
setSelectedTemplate(template);
|
||||||
addReleasePlan(template);
|
addReleasePlan(template);
|
||||||
|
@ -6,7 +6,7 @@ import { Link as RouterLink, useNavigate } from 'react-router-dom';
|
|||||||
import CloseIcon from '@mui/icons-material/Close';
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig.ts';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig.ts';
|
||||||
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon.tsx';
|
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon.tsx';
|
||||||
import { useContext, useMemo, useState } from 'react';
|
import { type Dispatch, type SetStateAction, useContext, useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
FeatureStrategyMenuCardsSection,
|
FeatureStrategyMenuCardsSection,
|
||||||
StyledStrategyModalSectionHeader,
|
StyledStrategyModalSectionHeader,
|
||||||
@ -79,6 +79,8 @@ interface IFeatureStrategyMenuCardsProps {
|
|||||||
projectId: string;
|
projectId: string;
|
||||||
featureId: string;
|
featureId: string;
|
||||||
environmentId: string;
|
environmentId: string;
|
||||||
|
filter: StrategyFilterValue;
|
||||||
|
setFilter: Dispatch<SetStateAction<StrategyFilterValue>>;
|
||||||
onAddReleasePlan: (template: IReleasePlanTemplate) => void;
|
onAddReleasePlan: (template: IReleasePlanTemplate) => void;
|
||||||
onReviewReleasePlan: (template: IReleasePlanTemplate) => void;
|
onReviewReleasePlan: (template: IReleasePlanTemplate) => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
@ -88,6 +90,8 @@ export const FeatureStrategyMenuCards = ({
|
|||||||
projectId,
|
projectId,
|
||||||
featureId,
|
featureId,
|
||||||
environmentId,
|
environmentId,
|
||||||
|
filter,
|
||||||
|
setFilter,
|
||||||
onAddReleasePlan,
|
onAddReleasePlan,
|
||||||
onReviewReleasePlan,
|
onReviewReleasePlan,
|
||||||
onClose,
|
onClose,
|
||||||
@ -99,8 +103,6 @@ export const FeatureStrategyMenuCards = ({
|
|||||||
|
|
||||||
const { strategies } = useStrategies();
|
const { strategies } = useStrategies();
|
||||||
|
|
||||||
const [filter, setFilter] = useState<StrategyFilterValue>(null);
|
|
||||||
|
|
||||||
const activeStrategies = strategies.filter(
|
const activeStrategies = strategies.filter(
|
||||||
(strategy) => !strategy.deprecated,
|
(strategy) => !strategy.deprecated,
|
||||||
);
|
);
|
||||||
|
@ -16,6 +16,7 @@ import { useFeature } from 'hooks/api/getters/useFeature/useFeature';
|
|||||||
import { useReleasePlans } from 'hooks/api/getters/useReleasePlans/useReleasePlans';
|
import { useReleasePlans } from 'hooks/api/getters/useReleasePlans/useReleasePlans';
|
||||||
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
||||||
import CloseIcon from '@mui/icons-material/Close';
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
|
import { useUiFlag } from 'hooks/useUiFlag.ts';
|
||||||
|
|
||||||
const StyledDialog = styled(Dialog)(({ theme }) => ({
|
const StyledDialog = styled(Dialog)(({ theme }) => ({
|
||||||
'& .MuiDialog-paper': {
|
'& .MuiDialog-paper': {
|
||||||
@ -81,6 +82,7 @@ export const ReleasePlanReviewDialog = ({
|
|||||||
featureName,
|
featureName,
|
||||||
environment,
|
environment,
|
||||||
);
|
);
|
||||||
|
const newStrategyModalEnabled = useUiFlag('newStrategyModal');
|
||||||
|
|
||||||
const activeReleasePlan = releasePlans[0];
|
const activeReleasePlan = releasePlans[0];
|
||||||
|
|
||||||
@ -140,7 +142,11 @@ export const ReleasePlanReviewDialog = ({
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
<StyledDialogActions>
|
<StyledDialogActions>
|
||||||
<Button variant='contained' color='primary' onClick={onConfirm}>
|
<Button variant='contained' color='primary' onClick={onConfirm}>
|
||||||
{crProtected ? 'Add suggestion to draft' : 'Use template'}
|
{crProtected
|
||||||
|
? 'Add suggestion to draft'
|
||||||
|
: newStrategyModalEnabled
|
||||||
|
? 'Apply template'
|
||||||
|
: 'Use template'}
|
||||||
</Button>
|
</Button>
|
||||||
</StyledDialogActions>
|
</StyledDialogActions>
|
||||||
</StyledDialog>
|
</StyledDialog>
|
||||||
|
Loading…
Reference in New Issue
Block a user