mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
cancel changes (#2510)
This commit is contained in:
parent
f9726fdee9
commit
9fee0bb264
@ -99,6 +99,23 @@ export const ChangeRequestOverview: FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const onCancelChanges = async () => {
|
||||
try {
|
||||
await changeState(projectId, Number(id), {
|
||||
state: 'Cancelled',
|
||||
});
|
||||
refetchChangeRequest();
|
||||
refetchChangeRequestOpen();
|
||||
setToastData({
|
||||
type: 'success',
|
||||
title: 'Success',
|
||||
text: 'Changes cancelled',
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
setToastApiError(formatUnknownError(error));
|
||||
}
|
||||
};
|
||||
|
||||
const isSelfReview =
|
||||
changeRequest?.createdBy.id === user?.id &&
|
||||
changeRequest.state === 'In review' &&
|
||||
@ -190,6 +207,23 @@ export const ChangeRequestOverview: FC = () => {
|
||||
</PermissionButton>
|
||||
}
|
||||
/>
|
||||
<ConditionallyRender
|
||||
condition={
|
||||
changeRequest.state !== 'Applied' &&
|
||||
changeRequest.state !== 'Cancelled' &&
|
||||
(changeRequest.createdBy.id === user?.id ||
|
||||
isAdmin)
|
||||
}
|
||||
show={
|
||||
<Button
|
||||
sx={{ ml: 2 }}
|
||||
variant="outlined"
|
||||
onClick={onCancelChanges}
|
||||
>
|
||||
Cancel changes
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</StyledButtonBox>
|
||||
</StyledInnerContainer>
|
||||
</StyledPaper>
|
||||
|
@ -54,22 +54,6 @@ export const ReviewButton = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const onReject = async () => {
|
||||
try {
|
||||
await changeState(projectId, Number(id), {
|
||||
state: 'Cancelled',
|
||||
});
|
||||
refetchChangeRequest();
|
||||
setToastData({
|
||||
type: 'success',
|
||||
title: 'Success',
|
||||
text: 'Changes rejected',
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
setToastApiError(formatUnknownError(error));
|
||||
}
|
||||
};
|
||||
|
||||
const onToggle = () => {
|
||||
setOpen(prevOpen => !prevOpen);
|
||||
};
|
||||
@ -132,9 +116,6 @@ export const ReviewButton = () => {
|
||||
<MenuItem onClick={onApprove}>
|
||||
Approve changes
|
||||
</MenuItem>
|
||||
<MenuItem onClick={onReject}>
|
||||
Reject changes
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</ClickAwayListener>
|
||||
</Paper>
|
||||
|
Loading…
Reference in New Issue
Block a user