Add modal to confirm workflow draft version overriding (#7758)

In this PR:

- Allow the `<ConfirmationModal />` to take additional buttons to
display between the cancel and the confirm buttons.
- Create a modal that's displayed when the user tries wants to use a
workflow version as draft while a draft version already exists. The
displayed modal contains a link to the current draft version and a
button to confirm the overriding of the current draft version.

A demo:


https://github.com/user-attachments/assets/6349f418-1b11-45b3-9f5e-061ca74c2966

Closes twentyhq/private-issues#114
This commit is contained in:
Baptiste Devessier
2024-10-21 11:51:54 +02:00
committed by GitHub
parent f3ec6a759f
commit fc6748de0a
4 changed files with 96 additions and 14 deletions

View File

@ -25,6 +25,7 @@ export type ConfirmationModalProps = {
confirmationPlaceholder?: string;
confirmationValue?: string;
confirmButtonAccent?: ButtonAccent;
AdditionalButtons?: React.ReactNode;
};
const StyledConfirmationModal = styled(Modal)`
@ -33,7 +34,8 @@ const StyledConfirmationModal = styled(Modal)`
height: auto;
`;
const StyledCenteredButton = styled(Button)`
export const StyledCenteredButton = styled(Button)`
box-sizing: border-box;
justify-content: center;
margin-top: ${({ theme }) => theme.spacing(2)};
`;
@ -68,6 +70,7 @@ export const ConfirmationModal = ({
confirmationValue,
confirmationPlaceholder,
confirmButtonAccent = 'danger',
AdditionalButtons,
}: ConfirmationModalProps) => {
const [inputConfirmationValue, setInputConfirmationValue] =
useState<string>('');
@ -138,6 +141,9 @@ export const ConfirmationModal = ({
title="Cancel"
fullWidth
/>
{AdditionalButtons}
<StyledCenteredButton
onClick={handleConfirmClick}
variant="secondary"