1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-10 01:19:53 +01:00

wip: quick and dirty hack to fix the badge

This commit is contained in:
Thomas Heartman 2024-01-10 14:36:12 +05:30
parent be579ba63b
commit 970334c9ec
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78

View File

@ -7,6 +7,7 @@ import {
CircleOutlined,
Close,
Error as ErrorIcon,
PauseCircle,
} from '@mui/icons-material';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
@ -60,23 +61,39 @@ 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 tooltipTitle =
schedule?.status === 'pending'
? `Scheduled for ${scheduledAt}`
: `Failed on ${scheduledAt} because of ${
schedule!.failureReason
}`;
const { color, icon, tooltipTitle } = (() => {
switch (schedule!.status) {
case 'pending':
return {
color: 'warning' as const,
icon: <AccessTime fontSize={'small'} />,
tooltipTitle: `Scheduled for ${scheduledAt}`,
};
case 'failed':
return {
color: 'error' as const,
icon: <ErrorIcon fontSize={'small'} />,
tooltipTitle: `Failed on ${scheduledAt} because of ${
// @ts-ignore
schedule!.reason ?? schedule!.failureReason
}`,
};
// @ts-ignore
case 'suspended':
return {
color: 'disabled' as const,
icon: <PauseCircle fontSize={'small'} />,
tooltipTitle: `Suspended because: ${
// @ts-ignore
schedule!.reason
}`,
};
}
})();
return (
<HtmlTooltip title={tooltipTitle} arrow>