mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +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,
|
CircleOutlined,
|
||||||
Close,
|
Close,
|
||||||
Error as ErrorIcon,
|
Error as ErrorIcon,
|
||||||
|
PauseCircle,
|
||||||
} from '@mui/icons-material';
|
} from '@mui/icons-material';
|
||||||
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
|
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
|
||||||
|
|
||||||
@ -60,27 +61,30 @@ export const ChangeRequestStatusBadge: VFC<IChangeRequestStatusBadgeProps> = ({
|
|||||||
);
|
);
|
||||||
case 'Scheduled': {
|
case 'Scheduled': {
|
||||||
const { schedule } = changeRequest;
|
const { schedule } = changeRequest;
|
||||||
const color = schedule!.status === 'pending' ? 'warning' : 'error';
|
const scheduledAt = new Date(schedule.scheduledAt).toLocaleString();
|
||||||
const icon =
|
|
||||||
schedule?.status === 'pending' ? (
|
|
||||||
<AccessTime fontSize={'small'} />
|
|
||||||
) : (
|
|
||||||
<ErrorIcon fontSize={'small'} />
|
|
||||||
);
|
|
||||||
const scheduledAt = new Date(
|
|
||||||
schedule!.scheduledAt,
|
|
||||||
).toLocaleString();
|
|
||||||
|
|
||||||
const tooltipTitle = (() => {
|
const { color, icon, tooltipTitle } = (() => {
|
||||||
switch (schedule.status) {
|
switch (schedule.status) {
|
||||||
case 'failed':
|
case 'failed':
|
||||||
return `Failed on ${scheduledAt} because of ${
|
return {
|
||||||
schedule.reason || schedule.failureReason
|
color: 'error' as const,
|
||||||
}`;
|
icon: <ErrorIcon fontSize={'small'} />,
|
||||||
|
tooltipTitle: `Failed on ${scheduledAt} because of ${
|
||||||
|
schedule.reason ?? schedule.failureReason
|
||||||
|
}`,
|
||||||
|
};
|
||||||
case 'suspended':
|
case 'suspended':
|
||||||
return schedule.reason;
|
return {
|
||||||
|
color: 'disabled' as const,
|
||||||
|
icon: <PauseCircle fontSize={'small'} />,
|
||||||
|
tooltipTitle: `Suspended because: ${schedule.reason}`,
|
||||||
|
};
|
||||||
default:
|
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