mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: show suspended schedule states in review status (#5872)
Updates the change request review status box to handle suspended schedules. <img width="852" alt="image" src="https://github.com/Unleash/unleash/assets/17786332/2af52b6d-d821-4d30-9166-e8e76ead120d">
This commit is contained in:
parent
aecc0b54a1
commit
a88763283a
@ -5,6 +5,7 @@ import {
|
|||||||
Schedule,
|
Schedule,
|
||||||
Edit,
|
Edit,
|
||||||
Error as ErrorIcon,
|
Error as ErrorIcon,
|
||||||
|
PauseCircle,
|
||||||
} from '@mui/icons-material';
|
} from '@mui/icons-material';
|
||||||
import { Box, Typography, Divider } from '@mui/material';
|
import { Box, Typography, Divider } from '@mui/material';
|
||||||
|
|
||||||
@ -55,6 +56,16 @@ export const StyledScheduleFailedIcon = styled(ErrorIcon)(({ theme }) => ({
|
|||||||
width: '35px',
|
width: '35px',
|
||||||
marginRight: theme.spacing(1),
|
marginRight: theme.spacing(1),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export const StyledScheduleSuspendedIcon = styled(PauseCircle)(
|
||||||
|
({ theme }) => ({
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
height: '35px',
|
||||||
|
width: '35px',
|
||||||
|
marginRight: theme.spacing(1),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
export const StyledEditIcon = styled(Edit)(({ theme }) => ({
|
export const StyledEditIcon = styled(Edit)(({ theme }) => ({
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
height: '24px',
|
height: '24px',
|
||||||
|
@ -23,12 +23,15 @@ import {
|
|||||||
StyledScheduledBox,
|
StyledScheduledBox,
|
||||||
StyledErrorIcon,
|
StyledErrorIcon,
|
||||||
StyledScheduleFailedIcon,
|
StyledScheduleFailedIcon,
|
||||||
|
StyledScheduleSuspendedIcon,
|
||||||
} from './ChangeRequestReviewStatus.styles';
|
} from './ChangeRequestReviewStatus.styles';
|
||||||
import {
|
import {
|
||||||
ChangeRequestState,
|
ChangeRequestState,
|
||||||
ChangeRequestType,
|
ChangeRequestType,
|
||||||
ChangeRequestSchedule,
|
ChangeRequestSchedule,
|
||||||
ChangeRequestScheduleFailed,
|
ChangeRequestScheduleFailed,
|
||||||
|
ChangeRequestSchedulePending,
|
||||||
|
ChangeRequestScheduleSuspended,
|
||||||
} from 'component/changeRequest/changeRequest.types';
|
} from 'component/changeRequest/changeRequest.types';
|
||||||
import { getBrowserTimezone } from './utils';
|
import { getBrowserTimezone } from './utils';
|
||||||
import { ConditionallyRender } from '../../../common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from '../../../common/ConditionallyRender/ConditionallyRender';
|
||||||
@ -236,10 +239,23 @@ interface IScheduledProps {
|
|||||||
const Scheduled = ({ schedule, onEditClick }: IScheduledProps) => {
|
const Scheduled = ({ schedule, onEditClick }: IScheduledProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (!schedule?.scheduledAt) {
|
if (!schedule) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scheduleStatusBox = (() => {
|
||||||
|
switch (schedule.status) {
|
||||||
|
case 'pending':
|
||||||
|
return <ScheduledPending schedule={schedule} />;
|
||||||
|
case 'failed':
|
||||||
|
return <ScheduledFailed schedule={schedule} />;
|
||||||
|
case 'suspended':
|
||||||
|
return <ScheduledSuspended schedule={schedule} />;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<StyledFlexAlignCenterBox>
|
<StyledFlexAlignCenterBox>
|
||||||
@ -257,16 +273,7 @@ const Scheduled = ({ schedule, onEditClick }: IScheduledProps) => {
|
|||||||
<StyledDivider />
|
<StyledDivider />
|
||||||
|
|
||||||
<StyledScheduledBox>
|
<StyledScheduledBox>
|
||||||
<ConditionallyRender
|
{scheduleStatusBox}
|
||||||
condition={schedule.status === 'pending'}
|
|
||||||
show={<ScheduledPending schedule={schedule} />}
|
|
||||||
elseShow={
|
|
||||||
<ScheduledFailed
|
|
||||||
schedule={schedule as ChangeRequestScheduleFailed}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<StyledIconButton onClick={onEditClick}>
|
<StyledIconButton onClick={onEditClick}>
|
||||||
<StyledEditIcon />
|
<StyledEditIcon />
|
||||||
</StyledIconButton>
|
</StyledIconButton>
|
||||||
@ -282,10 +289,6 @@ const ScheduledFailed = ({
|
|||||||
const timezone = getBrowserTimezone();
|
const timezone = getBrowserTimezone();
|
||||||
const { locationSettings } = useLocationSettings();
|
const { locationSettings } = useLocationSettings();
|
||||||
|
|
||||||
if (!schedule?.scheduledAt) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const scheduledTime = formatDateYMDHMS(
|
const scheduledTime = formatDateYMDHMS(
|
||||||
new Date(schedule?.scheduledAt),
|
new Date(schedule?.scheduledAt),
|
||||||
locationSettings?.locale,
|
locationSettings?.locale,
|
||||||
@ -304,17 +307,41 @@ const ScheduledFailed = ({
|
|||||||
</StyledFlexAlignCenterBox>
|
</StyledFlexAlignCenterBox>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const ScheduledSuspended = ({
|
||||||
const ScheduledPending = ({
|
|
||||||
schedule,
|
schedule,
|
||||||
}: { schedule: ChangeRequestSchedule }) => {
|
}: { schedule: ChangeRequestScheduleSuspended }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const timezone = getBrowserTimezone();
|
const timezone = getBrowserTimezone();
|
||||||
const { locationSettings } = useLocationSettings();
|
const { locationSettings } = useLocationSettings();
|
||||||
|
|
||||||
if (!schedule?.scheduledAt) {
|
const scheduledTime = formatDateYMDHMS(
|
||||||
return null;
|
new Date(schedule?.scheduledAt),
|
||||||
}
|
locationSettings?.locale,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledFlexAlignCenterBox>
|
||||||
|
<StyledScheduleSuspendedIcon />
|
||||||
|
<Box>
|
||||||
|
<StyledReviewTitle color={theme.palette.text.secondary}>
|
||||||
|
The change request is suspended for the following reason:{' '}
|
||||||
|
{schedule.reason}
|
||||||
|
</StyledReviewTitle>
|
||||||
|
<StyledReviewTitle color={theme.palette.text.secondary}>
|
||||||
|
It will not be applied on {scheduledTime}.
|
||||||
|
</StyledReviewTitle>
|
||||||
|
<Typography>Your timezone is {timezone}</Typography>
|
||||||
|
</Box>
|
||||||
|
</StyledFlexAlignCenterBox>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ScheduledPending = ({
|
||||||
|
schedule,
|
||||||
|
}: { schedule: ChangeRequestSchedulePending }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const timezone = getBrowserTimezone();
|
||||||
|
const { locationSettings } = useLocationSettings();
|
||||||
|
|
||||||
const scheduledTime = formatDateYMDHMS(
|
const scheduledTime = formatDateYMDHMS(
|
||||||
new Date(schedule?.scheduledAt),
|
new Date(schedule?.scheduledAt),
|
||||||
|
Loading…
Reference in New Issue
Block a user