Skip to content

Commit

Permalink
feat: pass lifecycle stage to tooltip (#6904)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Apr 23, 2024
1 parent dec107a commit 18d317f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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 <ArchivedStageIcon />;
} else if (stage.name === 'pre-live') {
return <PreLiveStageIcon />;
} else if (stage.name === 'live') {
return <LiveStageIcon />;
} else if (stage.name === 'completed' && stage.status === 'kept') {
return <CompletedStageIcon />;
} else if (stage.name === 'completed' && stage.status === 'discarded') {
return <CompletedDiscardedStageIcon />;
} else {
return <InitialStageIcon />;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -92,7 +97,8 @@ const ColorFill = styled(Box)(({ theme }) => ({

export const FeatureLifecycleTooltip: FC<{
children: React.ReactElement<any, any>;
}> = ({ children }) => (
stage: LifecycleStage;
}> = ({ children, stage }) => (
<HtmlTooltip
maxHeight={800}
maxWidth={350}
Expand All @@ -109,8 +115,10 @@ export const FeatureLifecycleTooltip: FC<{
gap: 1,
}}
>
<Badge>Initial</Badge>
<InitialStageIcon />
<Badge sx={{ textTransform: 'capitalize' }}>
{stage.name}
</Badge>
<FeatureLifecycleStageIcon stage={stage} />
</Box>
</MainLifecycleRow>
<TimeLifecycleRow>
Expand All @@ -122,31 +130,51 @@ export const FeatureLifecycleTooltip: FC<{
<span>3 days</span>
</TimeLifecycleRow>
<IconsRow>
<StageBox data-after-content='Initial' active={true}>
<StageBox
data-after-content='Initial'
active={stage.name === 'initial'}
>
<InitialStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Pre-live'>
<StageBox
data-after-content='Pre-live'
active={stage.name === 'pre-live'}
>
<PreLiveStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Live'>
<StageBox
data-after-content='Live'
active={stage.name === 'live'}
>
<LiveStageIcon />
</StageBox>

<Line />

<StageBox data-after-content='Completed'>
<CompletedStageIcon />
<StageBox
data-after-content='Completed'
active={stage.name === 'completed'}
>
{stage.name === 'completed' &&
stage.status === 'discarded' ? (
<CompletedDiscardedStageIcon />
) : (
<CompletedStageIcon />
)}
</StageBox>

<Line />

<StageBox data-after-content='Archived'>
<StageBox
data-after-content='Archived'
active={stage.name === 'archived'}
>
<ArchivedStageIcon />
</StageBox>
</IconsRow>
Expand All @@ -168,6 +196,6 @@ export const FeatureLifecycleTooltip: FC<{
</Box>
}
>
{children}
<Box>{children}</Box>
</HtmlTooltip>
);
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -94,10 +95,21 @@ const FeatureOverviewMetaData = () => {
<ConditionallyRender
condition={featureLifecycleEnabled}
show={
<StyledBodyItem data-loading>
Lifecycle:{' '}
<FeatureLifecycleTooltip>
<span>Initial</span>
<StyledBodyItem
sx={{
display: 'flex',
gap: 1,
alignItems: 'start',
}}
data-loading
>
<span>Lifecycle:</span>
<FeatureLifecycleTooltip
stage={{ name: 'initial' }}
>
<FeatureLifecycleStageIcon
stage={{ name: 'initial' }}
/>
</FeatureLifecycleTooltip>
</StyledBodyItem>
}
Expand Down

0 comments on commit 18d317f

Please sign in to comment.