mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
Fix/scheduled request UI (#5318)
Change timezone format Fixes a bug where the Edit button on hover being elongated Before: <img width="755" alt="Screenshot 2023-11-09 at 21 36 01" src="https://github.com/Unleash/unleash/assets/104830839/189f21d5-8a68-4d6b-b094-b518749a9b2f"> After: <img width="812" alt="Screenshot 2023-11-09 at 22 09 26" src="https://github.com/Unleash/unleash/assets/104830839/9056f995-bd2b-4353-8526-77160e49e990"> Adds the missed onClick to the edit button to show the dialog Fixes a bug with ScheduleChangesDialog onClose --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
0b9e11629d
commit
180c0dceae
@ -219,7 +219,7 @@ export const ChangeRequestOverview: FC = () => {
|
|||||||
const onCancelAbort = () => setShowCancelDialog(false);
|
const onCancelAbort = () => setShowCancelDialog(false);
|
||||||
const onCancelReject = () => setShowRejectDialog(false);
|
const onCancelReject = () => setShowRejectDialog(false);
|
||||||
const onApplyScheduledAbort = () => setShowApplyScheduledDialog(false);
|
const onApplyScheduledAbort = () => setShowApplyScheduledDialog(false);
|
||||||
const onScheduleChangeAbort = () => setShowApplyScheduledDialog(false);
|
const onScheduleChangeAbort = () => setShowScheduleChangeDialog(false);
|
||||||
const onRejectScheduledAbort = () => setShowRejectScheduledDialog(false);
|
const onRejectScheduledAbort = () => setShowRejectScheduledDialog(false);
|
||||||
|
|
||||||
const isSelfReview =
|
const isSelfReview =
|
||||||
@ -286,6 +286,9 @@ export const ChangeRequestOverview: FC = () => {
|
|||||||
/>
|
/>
|
||||||
<ChangeRequestReviewStatus
|
<ChangeRequestReviewStatus
|
||||||
changeRequest={changeRequest}
|
changeRequest={changeRequest}
|
||||||
|
onEditClick={() =>
|
||||||
|
setShowScheduleChangeDialog(true)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<StyledButtonBox>
|
<StyledButtonBox>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { Box, IconButton, Theme, Typography, useTheme } from '@mui/material';
|
import {
|
||||||
|
Box,
|
||||||
|
IconButton,
|
||||||
|
styled,
|
||||||
|
Theme,
|
||||||
|
Typography,
|
||||||
|
useTheme,
|
||||||
|
} from '@mui/material';
|
||||||
import { ReactComponent as ChangesAppliedIcon } from 'assets/icons/merge.svg';
|
import { ReactComponent as ChangesAppliedIcon } from 'assets/icons/merge.svg';
|
||||||
import {
|
import {
|
||||||
StyledOuterContainer,
|
StyledOuterContainer,
|
||||||
@ -19,10 +26,11 @@ import {
|
|||||||
ChangeRequestState,
|
ChangeRequestState,
|
||||||
IChangeRequest,
|
IChangeRequest,
|
||||||
} from 'component/changeRequest/changeRequest.types';
|
} from 'component/changeRequest/changeRequest.types';
|
||||||
import { getBrowserTimezoneInHumanReadableUTCOffset } from './utils';
|
import { getBrowserTimezone } from './utils';
|
||||||
|
|
||||||
interface ISuggestChangeReviewsStatusProps {
|
interface ISuggestChangeReviewsStatusProps {
|
||||||
changeRequest: IChangeRequest;
|
changeRequest: IChangeRequest;
|
||||||
|
onEditClick?: () => void;
|
||||||
}
|
}
|
||||||
const resolveBorder = (state: ChangeRequestState, theme: Theme) => {
|
const resolveBorder = (state: ChangeRequestState, theme: Theme) => {
|
||||||
if (state === 'Approved' || state === 'Scheduled') {
|
if (state === 'Approved' || state === 'Scheduled') {
|
||||||
@ -58,7 +66,7 @@ const resolveIconColors = (state: ChangeRequestState, theme: Theme) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ChangeRequestReviewStatus: FC<ISuggestChangeReviewsStatusProps> =
|
export const ChangeRequestReviewStatus: FC<ISuggestChangeReviewsStatusProps> =
|
||||||
({ changeRequest }) => {
|
({ changeRequest, onEditClick }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
return (
|
return (
|
||||||
<StyledOuterContainer>
|
<StyledOuterContainer>
|
||||||
@ -80,7 +88,10 @@ export const ChangeRequestReviewStatus: FC<ISuggestChangeReviewsStatusProps> =
|
|||||||
}}
|
}}
|
||||||
border={resolveBorder(changeRequest.state, theme)}
|
border={resolveBorder(changeRequest.state, theme)}
|
||||||
>
|
>
|
||||||
<ResolveComponent changeRequest={changeRequest} />
|
<ResolveComponent
|
||||||
|
changeRequest={changeRequest}
|
||||||
|
onEditClick={onEditClick}
|
||||||
|
/>
|
||||||
</StyledReviewStatusContainer>
|
</StyledReviewStatusContainer>
|
||||||
</StyledOuterContainer>
|
</StyledOuterContainer>
|
||||||
);
|
);
|
||||||
@ -88,9 +99,13 @@ export const ChangeRequestReviewStatus: FC<ISuggestChangeReviewsStatusProps> =
|
|||||||
|
|
||||||
interface IResolveComponentProps {
|
interface IResolveComponentProps {
|
||||||
changeRequest: IChangeRequest;
|
changeRequest: IChangeRequest;
|
||||||
|
onEditClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ResolveComponent = ({ changeRequest }: IResolveComponentProps) => {
|
const ResolveComponent = ({
|
||||||
|
changeRequest,
|
||||||
|
onEditClick,
|
||||||
|
}: IResolveComponentProps) => {
|
||||||
const { state } = changeRequest;
|
const { state } = changeRequest;
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
@ -115,7 +130,10 @@ const ResolveComponent = ({ changeRequest }: IResolveComponentProps) => {
|
|||||||
|
|
||||||
if (state === 'Scheduled') {
|
if (state === 'Scheduled') {
|
||||||
return (
|
return (
|
||||||
<Scheduled scheduledDate={changeRequest.schedule?.scheduledAt} />
|
<Scheduled
|
||||||
|
scheduledDate={changeRequest.schedule?.scheduledAt}
|
||||||
|
onEditClick={onEditClick}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,17 +222,23 @@ const Applied = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const StyledIconButton = styled(IconButton)({
|
||||||
|
maxWidth: '32px',
|
||||||
|
maxHeight: '32px',
|
||||||
|
});
|
||||||
|
|
||||||
interface IScheduledProps {
|
interface IScheduledProps {
|
||||||
scheduledDate?: string;
|
scheduledDate?: string;
|
||||||
|
onEditClick?: () => any;
|
||||||
}
|
}
|
||||||
const Scheduled = ({ scheduledDate }: IScheduledProps) => {
|
const Scheduled = ({ scheduledDate, onEditClick }: IScheduledProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (!scheduledDate) {
|
if (!scheduledDate) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const timezone = getBrowserTimezoneInHumanReadableUTCOffset();
|
const timezone = getBrowserTimezone();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -243,9 +267,9 @@ const Scheduled = ({ scheduledDate }: IScheduledProps) => {
|
|||||||
<Typography>Your timezone is {timezone}</Typography>
|
<Typography>Your timezone is {timezone}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</StyledFlexAlignCenterBox>
|
</StyledFlexAlignCenterBox>
|
||||||
<IconButton>
|
<StyledIconButton onClick={onEditClick}>
|
||||||
<StyledEditIcon />
|
<StyledEditIcon />
|
||||||
</IconButton>
|
</StyledIconButton>
|
||||||
</StyledScheduledBox>
|
</StyledScheduledBox>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -15,3 +15,7 @@ export const getBrowserTimezoneInHumanReadableUTCOffset = (
|
|||||||
|
|
||||||
return `UTC${sign}${zeroPaddedHours}:${zeroPaddedMinutes}`;
|
return `UTC${sign}${zeroPaddedHours}:${zeroPaddedMinutes}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getBrowserTimezone = (): string => {
|
||||||
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
|
};
|
||||||
|
@ -4,7 +4,7 @@ import { Dialogue } from 'component/common/Dialogue/Dialogue';
|
|||||||
import { APPLY_CHANGE_REQUEST } from 'component/providers/AccessProvider/permissions';
|
import { APPLY_CHANGE_REQUEST } from 'component/providers/AccessProvider/permissions';
|
||||||
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
|
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
|
||||||
import { DateTimePicker } from 'component/common/DateTimePicker/DateTimePicker';
|
import { DateTimePicker } from 'component/common/DateTimePicker/DateTimePicker';
|
||||||
import { getBrowserTimezoneInHumanReadableUTCOffset } from '../ChangeRequestReviewStatus/utils';
|
import { getBrowserTimezone } from '../ChangeRequestReviewStatus/utils';
|
||||||
|
|
||||||
export interface ScheduleChangeRequestDialogProps {
|
export interface ScheduleChangeRequestDialogProps {
|
||||||
title: string;
|
title: string;
|
||||||
@ -42,7 +42,7 @@ export const ScheduleChangeRequestDialog: FC<ScheduleChangeRequestDialogProps> =
|
|||||||
);
|
);
|
||||||
const [error, setError] = useState<string | undefined>(undefined);
|
const [error, setError] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
const timezone = getBrowserTimezoneInHumanReadableUTCOffset();
|
const timezone = getBrowserTimezone();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialogue
|
<Dialogue
|
||||||
@ -50,7 +50,7 @@ export const ScheduleChangeRequestDialog: FC<ScheduleChangeRequestDialogProps> =
|
|||||||
primaryButtonText={primaryButtonText}
|
primaryButtonText={primaryButtonText}
|
||||||
secondaryButtonText='Cancel'
|
secondaryButtonText='Cancel'
|
||||||
open={open}
|
open={open}
|
||||||
onClose={onClose}
|
onClose={() => onClose()}
|
||||||
onClick={() => onConfirm(selectedDate)}
|
onClick={() => onConfirm(selectedDate)}
|
||||||
permissionButton={
|
permissionButton={
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
|
@ -127,6 +127,8 @@ export const CHANGE_REQUEST_CANCELLED = 'change-request-cancelled' as const;
|
|||||||
export const CHANGE_REQUEST_SENT_TO_REVIEW =
|
export const CHANGE_REQUEST_SENT_TO_REVIEW =
|
||||||
'change-request-sent-to-review' as const;
|
'change-request-sent-to-review' as const;
|
||||||
export const CHANGE_REQUEST_APPLIED = 'change-request-applied' as const;
|
export const CHANGE_REQUEST_APPLIED = 'change-request-applied' as const;
|
||||||
|
export const SCHEDULED_CHANGE_REQUEST_APPLIED =
|
||||||
|
'scheduled-change-request-applied' as const;
|
||||||
export const CHANGE_REQUEST_SCHEDULED = 'change-request-scheduled' as const;
|
export const CHANGE_REQUEST_SCHEDULED = 'change-request-scheduled' as const;
|
||||||
|
|
||||||
export const API_TOKEN_CREATED = 'api-token-created' as const;
|
export const API_TOKEN_CREATED = 'api-token-created' as const;
|
||||||
@ -248,6 +250,7 @@ export const IEventTypes = [
|
|||||||
CHANGE_REQUEST_CANCELLED,
|
CHANGE_REQUEST_CANCELLED,
|
||||||
CHANGE_REQUEST_SENT_TO_REVIEW,
|
CHANGE_REQUEST_SENT_TO_REVIEW,
|
||||||
CHANGE_REQUEST_APPLIED,
|
CHANGE_REQUEST_APPLIED,
|
||||||
|
SCHEDULED_CHANGE_REQUEST_APPLIED,
|
||||||
CHANGE_REQUEST_SCHEDULED,
|
CHANGE_REQUEST_SCHEDULED,
|
||||||
API_TOKEN_CREATED,
|
API_TOKEN_CREATED,
|
||||||
API_TOKEN_UPDATED,
|
API_TOKEN_UPDATED,
|
||||||
|
Loading…
Reference in New Issue
Block a user