1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-12 01:17:04 +02:00

feat: search page flag status with change requests (#9744)

This commit is contained in:
Tymoteusz Czech 2025-04-14 09:51:09 +02:00 committed by GitHub
parent 1b7cf6d97d
commit 417d3b80a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 70 additions and 9 deletions

View File

@ -197,7 +197,7 @@ export const FeatureToggleListTable: FC = () => {
<StatusCell {...original} /> <StatusCell {...original} />
), ),
enableSorting: false, enableSorting: false,
size: 50, size: 80,
}), }),
columnHelper.accessor('project', { columnHelper.accessor('project', {
header: 'Project', header: 'Project',

View File

@ -2,19 +2,63 @@ import { type FC, useMemo } from 'react';
import type { FeatureSearchResponseSchema } from 'openapi'; import type { FeatureSearchResponseSchema } from 'openapi';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import { getStatus } from './getStatus'; import { getStatus } from './getStatus';
import DifferenceIcon from '@mui/icons-material/Difference';
import { Link } from 'react-router-dom';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
const Container = styled('div')(({ theme }) => ({ const Container = styled('div')(({ theme }) => ({
padding: theme.spacing(0, 2), padding: theme.spacing(0, 2),
display: 'flex',
alignItems: 'center',
gap: theme.spacing(1),
}));
const ChangeRequestIcon = styled(DifferenceIcon)(({ theme }) => ({
color: theme.palette.primary.main,
fontSize: theme.spacing(2.5),
marginLeft: theme.spacing(0.5),
})); }));
export const StatusCell: FC<FeatureSearchResponseSchema> = ({ export const StatusCell: FC<FeatureSearchResponseSchema> = ({
lifecycle, lifecycle,
environments, environments,
project,
}) => { }) => {
const status = useMemo( const status = useMemo(
() => getStatus({ lifecycle, environments }), () => getStatus({ lifecycle, environments }),
[lifecycle, environments], [lifecycle, environments],
); );
const changeRequestIds = useMemo(
() => environments.flatMap((env) => env.changeRequestIds),
[environments],
);
return <Container>{status}</Container>; return (
<Container>
<div>{status}</div>
{changeRequestIds.length > 0 && (
<HtmlTooltip
arrow
title={
<div>
<span>Change requests:</span>
<br />
{changeRequestIds.map((id) => (
<Link
key={id}
to={`/projects/${project}/change-requests/${id}`}
target='_blank'
rel='noopener noreferrer'
>
{`#${id}`}
</Link>
))}
</div>
}
>
<ChangeRequestIcon />
</HtmlTooltip>
)}
</Container>
);
}; };

View File

@ -38,15 +38,29 @@ export const getStatus = ({
} }
} }
const productionEnvironment = environments?.find( const productionEnvironments = environments?.filter(
(env) => env.type === PRODUCTION, (env) => env.type === PRODUCTION,
); );
if (lifecycle?.stage === 'live') { if (lifecycle?.stage === 'live' || lifecycle?.stage === 'completed') {
if (!productionEnvironment) { if (productionEnvironments.length > 1) {
const countEnabled = productionEnvironments.filter(
(env) => env.enabled,
).length;
if (countEnabled === 0) {
return 'Paused';
}
if (productionEnvironments.length !== countEnabled) {
return `In ${countEnabled} out of ${productionEnvironments.length} production environments`;
}
}
if (productionEnvironments.length === 0) {
return 'No production environments'; return 'No production environments';
} }
const productionEnvironment = productionEnvironments[0];
if (!productionEnvironment?.hasStrategies) { if (!productionEnvironment?.hasStrategies) {
return 'No strategies'; return 'No strategies';
} }
@ -54,11 +68,14 @@ export const getStatus = ({
if (!productionEnvironment?.enabled) { if (!productionEnvironment?.enabled) {
return 'Paused'; return 'Paused';
} }
}
if (lifecycle?.stage === 'completed') { if (productionEnvironment.totalMilestones) {
if (productionEnvironment?.enabled) { const order = `${(productionEnvironment.milestoneOrder || 0) + 1} of ${productionEnvironment.totalMilestones}`;
return 'Enabled'; if (productionEnvironment.milestoneName) {
return `Milestone: ${productionEnvironment.milestoneName} (${order})`;
}
return `Milestone ${order}`;
} }
} }