From ed1b44c301560e38412eafd1f05e66b6afb1cc0f Mon Sep 17 00:00:00 2001 From: kwasniew Date: Tue, 23 Apr 2024 10:49:45 +0200 Subject: [PATCH] feat: pass lifecycle stage to tooltip --- .../FeatureLifecycleStageIcon.tsx | 35 ++++++++++++++ .../FeatureLifecycleTooltip.tsx | 48 +++++++++++++++---- .../FeatureOverviewMetaData.tsx | 22 +++++++-- 3 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleStageIcon.tsx rename frontend/src/component/feature/FeatureView/FeatureOverview/{FeatureLifecycleTooltip => FeatureLifecycle}/FeatureLifecycleTooltip.tsx (76%) diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleStageIcon.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleStageIcon.tsx new file mode 100644 index 000000000000..2ba17ffe1304 --- /dev/null +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleStageIcon.tsx @@ -0,0 +1,35 @@ +import type { FC } from 'react'; +import { ReactComponent as InitialStageIcon } from 'assets/icons/stage-initial.svg'; +import { ReactComponent as PreLiveStageIcon } from 'assets/icons/stage-pre-live.svg'; +import { ReactComponent as LiveStageIcon } from 'assets/icons/stage-live.svg'; +import { ReactComponent as CompletedStageIcon } from 'assets/icons/stage-completed.svg'; +import { ReactComponent as CompletedDiscardedStageIcon } from 'assets/icons/stage-completed-discarded.svg'; +import { ReactComponent as ArchivedStageIcon } from 'assets/icons/stage-archived.svg'; + +export type LifecycleStage = + | { name: 'initial' } + | { name: 'pre-live' } + | { name: 'live' } + | { + name: 'completed'; + status: 'kept' | 'discarded'; + } + | { name: 'archived' }; + +export const FeatureLifecycleStageIcon: FC<{ stage: LifecycleStage }> = ({ + stage, +}) => { + if (stage.name === 'archived') { + return ; + } else if (stage.name === 'pre-live') { + return ; + } else if (stage.name === 'live') { + return ; + } else if (stage.name === 'completed' && stage.status === 'kept') { + return ; + } else if (stage.name === 'completed' && stage.status === 'discarded') { + return ; + } else { + return ; + } +}; diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycleTooltip/FeatureLifecycleTooltip.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleTooltip.tsx similarity index 76% rename from frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycleTooltip/FeatureLifecycleTooltip.tsx rename to frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleTooltip.tsx index 633a20c4259b..ab339ad714cc 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycleTooltip/FeatureLifecycleTooltip.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleTooltip.tsx @@ -7,7 +7,12 @@ import { ReactComponent as InitialStageIcon } from 'assets/icons/stage-initial.s import { ReactComponent as PreLiveStageIcon } from 'assets/icons/stage-pre-live.svg'; import { ReactComponent as LiveStageIcon } from 'assets/icons/stage-live.svg'; import { ReactComponent as CompletedStageIcon } from 'assets/icons/stage-completed.svg'; +import { ReactComponent as CompletedDiscardedStageIcon } from 'assets/icons/stage-completed-discarded.svg'; import { ReactComponent as ArchivedStageIcon } from 'assets/icons/stage-archived.svg'; +import { + FeatureLifecycleStageIcon, + type LifecycleStage, +} from './FeatureLifecycleStageIcon'; const TimeLabel = styled('span')(({ theme }) => ({ color: theme.palette.text.secondary, @@ -92,7 +97,8 @@ const ColorFill = styled(Box)(({ theme }) => ({ export const FeatureLifecycleTooltip: FC<{ children: React.ReactElement; -}> = ({ children }) => ( + stage: LifecycleStage; +}> = ({ children, stage }) => ( - Initial - + + {stage.name} + + @@ -122,31 +130,51 @@ export const FeatureLifecycleTooltip: FC<{ 3 days - + - + - + - - + + {stage.name === 'completed' && + stage.status === 'discarded' ? ( + + ) : ( + + )} - + @@ -168,6 +196,6 @@ export const FeatureLifecycleTooltip: FC<{ } > - {children} + {children} ); diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewMetaData/FeatureOverviewMetaData.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewMetaData/FeatureOverviewMetaData.tsx index 11b7416cd3a9..ea33354c5869 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewMetaData/FeatureOverviewMetaData.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewMetaData/FeatureOverviewMetaData.tsx @@ -8,7 +8,8 @@ import PermissionIconButton from 'component/common/PermissionIconButton/Permissi import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useUiFlag } from 'hooks/useUiFlag'; -import { FeatureLifecycleTooltip } from '../FeatureLifecycleTooltip/FeatureLifecycleTooltip'; +import { FeatureLifecycleTooltip } from '../FeatureLifecycle/FeatureLifecycleTooltip'; +import { FeatureLifecycleStageIcon } from '../FeatureLifecycle/FeatureLifecycleStageIcon'; const StyledContainer = styled('div')(({ theme }) => ({ borderRadius: theme.shape.borderRadiusLarge, @@ -94,10 +95,21 @@ const FeatureOverviewMetaData = () => { - Lifecycle:{' '} - - Initial + + Lifecycle: + + }