Skip to content

Commit

Permalink
Merge pull request #512 from alan-turing-institute/471-edit-panel-alert
Browse files Browse the repository at this point in the history
Alert pop up changes
  • Loading branch information
RichGriff authored Jun 25, 2024
2 parents 91d61da + 6d7aa63 commit e682512
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions next_frontend/components/common/NodeEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,19 @@ const NodeEdit = ({ node, isOpen, setEditOpen }: NodeEditProps) => {
onClose={() => setDeleteOpen(false)}
onConfirm={handleDelete}
loading={loading}
confirmButtonText={'Delete'}
message={'Deleting this element will also remove all of the connected child elements. This cannot be undone.'}
confirmButtonText={'Yes, delete this element!'}
cancelButtonText={'No, keep the element'}
/>

<AlertModal
isOpen={alertOpen}
onClose={() => setAlertOpen(false)}
onConfirm={handleClose}
loading={loading}
message={'There are unresolved changes, continue to discard these changes.'}
confirmButtonText={'Discard Changes'}
message={'You have changes that have not been updated, would you like to discard these changes?'}
confirmButtonText={'Yes, discard changes!'}
cancelButtonText={'No, keep editing'}
/>
</>
)}
Expand Down
6 changes: 4 additions & 2 deletions next_frontend/components/modals/alertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface AlertModalProps {
loading: boolean;
message?: string
confirmButtonText: string
cancelButtonText?: string | null
}

export const AlertModal: React.FC<AlertModalProps> = ({
Expand All @@ -20,7 +21,8 @@ export const AlertModal: React.FC<AlertModalProps> = ({
onConfirm,
loading,
message,
confirmButtonText
confirmButtonText,
cancelButtonText
}) => {
const [isMounted, setIsMounted] = useState(false);

Expand All @@ -41,7 +43,7 @@ export const AlertModal: React.FC<AlertModalProps> = ({
>
<div className="pt-6 space-x-2 flex items-center justify-end w-full">
<Button disabled={loading} variant="outline" onClick={onClose}>
Cancel
{cancelButtonText ? cancelButtonText : 'Cancel'}
</Button>
<Button disabled={loading} variant="destructive" onClick={onConfirm}>
{loading ? 'Deleting' : confirmButtonText}
Expand Down

0 comments on commit e682512

Please sign in to comment.