1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00

feat: hide milestone progression on paused state (#10998)

This commit is contained in:
Jaanus Sellin 2025-11-19 12:41:18 +02:00 committed by GitHub
parent d3981baf2c
commit 35680f87eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 2 deletions

View File

@ -54,13 +54,12 @@ export const MilestoneAutomation = ({
pendingProgressionChange?.action === 'changeMilestoneProgression'; pendingProgressionChange?.action === 'changeMilestoneProgression';
const hasPendingDelete = const hasPendingDelete =
pendingProgressionChange?.action === 'deleteMilestoneProgression'; pendingProgressionChange?.action === 'deleteMilestoneProgression';
const isPaused = Boolean(milestone.pausedAt);
const badge = hasPendingDelete ? ( const badge = hasPendingDelete ? (
<Badge color='error'>Deleted in draft</Badge> <Badge color='error'>Deleted in draft</Badge>
) : hasPendingChange ? ( ) : hasPendingChange ? (
<Badge color='warning'>Modified in draft</Badge> <Badge color='warning'>Modified in draft</Badge>
) : isPaused ? ( ) : status?.type === 'paused' ? (
<Badge color='error' icon={<WarningAmber fontSize='small' />}> <Badge color='error' icon={<WarningAmber fontSize='small' />}>
Paused Paused
</Badge> </Badge>

View File

@ -10,6 +10,7 @@ describe('getMilestoneProgressionInfo', () => {
30, 30,
startedAt, startedAt,
'en-US', 'en-US',
undefined,
currentTime, currentTime,
); );
expect(res).toBeTruthy(); expect(res).toBeTruthy();
@ -22,9 +23,22 @@ describe('getMilestoneProgressionInfo', () => {
120, 120,
startedAt, startedAt,
'en-US', 'en-US',
undefined,
currentTime, currentTime,
); );
expect(res).toBeTruthy(); expect(res).toBeTruthy();
expect(res as string).toMatch(/^Will proceed at .* \(in .*\)\.$/); expect(res as string).toMatch(/^Will proceed at .* \(in .*\)\.$/);
}); });
it('returns null when milestone is paused', () => {
const startedAt = '2025-10-31T14:00:00.000Z';
const res = getMilestoneProgressionInfo(
120,
startedAt,
'en-US',
{ type: 'paused' },
currentTime,
);
expect(res).toBeNull();
});
}); });

View File

@ -1,16 +1,22 @@
import { addMinutes, differenceInMinutes, formatDistance } from 'date-fns'; import { addMinutes, differenceInMinutes, formatDistance } from 'date-fns';
import { formatDateYMDHM } from 'utils/formatDate.ts'; import { formatDateYMDHM } from 'utils/formatDate.ts';
import type { MilestoneStatus } from '../ReleasePlanMilestone/ReleasePlanMilestoneStatus.tsx';
export const getMilestoneProgressionInfo = ( export const getMilestoneProgressionInfo = (
intervalMinutes: number, intervalMinutes: number,
sourceMilestoneStartedAt: string | null | undefined, sourceMilestoneStartedAt: string | null | undefined,
locale: string, locale: string,
status?: MilestoneStatus,
currentTime: Date = new Date(), currentTime: Date = new Date(),
): string | null => { ): string | null => {
if (!sourceMilestoneStartedAt) { if (!sourceMilestoneStartedAt) {
return null; return null;
} }
if (status?.type === 'paused') {
return null;
}
const startDate = new Date(sourceMilestoneStartedAt); const startDate = new Date(sourceMilestoneStartedAt);
const elapsedMinutes = differenceInMinutes(currentTime, startDate); const elapsedMinutes = differenceInMinutes(currentTime, startDate);
const proceedDate = addMinutes(startDate, intervalMinutes); const proceedDate = addMinutes(startDate, intervalMinutes);

View File

@ -16,5 +16,6 @@ export const useMilestoneProgressionInfo = (
intervalMinutes, intervalMinutes,
sourceMilestoneStartedAt, sourceMilestoneStartedAt,
locationSettings.locale, locationSettings.locale,
status,
); );
}; };