mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-24 20:06:55 +01:00
feat: first refactor
This commit is contained in:
parent
8f023696d9
commit
296b4333bf
@ -157,42 +157,22 @@ const createTimelineScheduleItem = (schedule: ChangeRequestSchedule) => {
|
|||||||
locationSettings?.locale,
|
locationSettings?.locale,
|
||||||
);
|
);
|
||||||
|
|
||||||
const color = (() => {
|
const [title, subtitle, color, reason] = (() => {
|
||||||
switch (schedule.status) {
|
switch (schedule.status) {
|
||||||
case 'suspended':
|
case 'suspended':
|
||||||
return 'grey';
|
return [
|
||||||
case 'failed':
|
'Schedule suspended',
|
||||||
return 'error';
|
`was ${time}`,
|
||||||
case 'pending':
|
'grey' as const,
|
||||||
default:
|
|
||||||
return 'warning';
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
const title = `Schedule ${schedule.status}`;
|
|
||||||
|
|
||||||
const subtitle = (() => {
|
|
||||||
switch (schedule.status) {
|
|
||||||
case 'suspended':
|
|
||||||
return `was ${time}`;
|
|
||||||
case 'failed':
|
|
||||||
return `at ${time}`;
|
|
||||||
case 'pending':
|
|
||||||
default:
|
|
||||||
return `for ${time}`;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
const reason = (() => {
|
|
||||||
switch (schedule.status) {
|
|
||||||
case 'suspended':
|
|
||||||
return (
|
|
||||||
<HtmlTooltip title={schedule.reason} arrow>
|
<HtmlTooltip title={schedule.reason} arrow>
|
||||||
<ErrorIcon color={'error'} fontSize={'small'} />
|
<ErrorIcon color={'error'} fontSize={'small'} />
|
||||||
</HtmlTooltip>
|
</HtmlTooltip>,
|
||||||
);
|
];
|
||||||
case 'failed':
|
case 'failed':
|
||||||
return (
|
return [
|
||||||
|
'Schedule failed',
|
||||||
|
`at ${time}`,
|
||||||
|
'error' as const,
|
||||||
<HtmlTooltip
|
<HtmlTooltip
|
||||||
title={`Schedule failed because of ${
|
title={`Schedule failed because of ${
|
||||||
schedule.reason || schedule.failureReason
|
schedule.reason || schedule.failureReason
|
||||||
@ -200,11 +180,11 @@ const createTimelineScheduleItem = (schedule: ChangeRequestSchedule) => {
|
|||||||
arrow
|
arrow
|
||||||
>
|
>
|
||||||
<ErrorIcon color={'error'} fontSize={'small'} />
|
<ErrorIcon color={'error'} fontSize={'small'} />
|
||||||
</HtmlTooltip>
|
</HtmlTooltip>,
|
||||||
);
|
];
|
||||||
case 'pending':
|
case 'pending':
|
||||||
default:
|
default:
|
||||||
return <></>;
|
return ['Scheduled', `for ${time}`, 'warning' as const, <></>];
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user