mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
feat: show suspended states in change request badge (#5871)
This updates the CR badge to show suspended states correctly. <img width="370" alt="image" src="https://github.com/Unleash/unleash/assets/17786332/f678059b-f72a-46ef-9111-0fc90f228fc8">
This commit is contained in:
parent
5a3bb1ffc3
commit
aecc0b54a1
@ -7,6 +7,7 @@ import {
|
||||
CircleOutlined,
|
||||
Close,
|
||||
Error as ErrorIcon,
|
||||
PauseCircle,
|
||||
} from '@mui/icons-material';
|
||||
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
|
||||
|
||||
@ -60,27 +61,30 @@ export const ChangeRequestStatusBadge: VFC<IChangeRequestStatusBadgeProps> = ({
|
||||
);
|
||||
case 'Scheduled': {
|
||||
const { schedule } = changeRequest;
|
||||
const color = schedule!.status === 'pending' ? 'warning' : 'error';
|
||||
const icon =
|
||||
schedule?.status === 'pending' ? (
|
||||
<AccessTime fontSize={'small'} />
|
||||
) : (
|
||||
<ErrorIcon fontSize={'small'} />
|
||||
);
|
||||
const scheduledAt = new Date(
|
||||
schedule!.scheduledAt,
|
||||
).toLocaleString();
|
||||
const scheduledAt = new Date(schedule.scheduledAt).toLocaleString();
|
||||
|
||||
const tooltipTitle = (() => {
|
||||
const { color, icon, tooltipTitle } = (() => {
|
||||
switch (schedule.status) {
|
||||
case 'failed':
|
||||
return `Failed on ${scheduledAt} because of ${
|
||||
schedule.reason || schedule.failureReason
|
||||
}`;
|
||||
return {
|
||||
color: 'error' as const,
|
||||
icon: <ErrorIcon fontSize={'small'} />,
|
||||
tooltipTitle: `Failed on ${scheduledAt} because of ${
|
||||
schedule.reason ?? schedule.failureReason
|
||||
}`,
|
||||
};
|
||||
case 'suspended':
|
||||
return schedule.reason;
|
||||
return {
|
||||
color: 'disabled' as const,
|
||||
icon: <PauseCircle fontSize={'small'} />,
|
||||
tooltipTitle: `Suspended because: ${schedule.reason}`,
|
||||
};
|
||||
default:
|
||||
return `Scheduled for ${scheduledAt}`;
|
||||
return {
|
||||
color: 'warning' as const,
|
||||
icon: <AccessTime fontSize={'small'} />,
|
||||
tooltipTitle: `Scheduled for ${scheduledAt}`,
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user