Skip to content

Commit

Permalink
Fix "Unsaved ACL changes" promt not appearing
Browse files Browse the repository at this point in the history
The introduction of the new modal component
broke the confirmation modal that appeared
when you had unsaved changes in your events
or series details access policy tab. Should now
be restored.
  • Loading branch information
Arnei committed Jan 21, 2025
1 parent b34dda7 commit 0e44e3c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/components/events/partials/modals/EventDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const EventDetailsModal = () => {
setPolicyChanged(false);
dispatch(removeNotificationWizardForm());
hideModal();
return true;
}
return false;
};

return (
Expand Down
2 changes: 2 additions & 0 deletions src/components/events/partials/modals/SeriesDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const SeriesDetailsModal = ({
if (!policyChanged || confirmUnsaved()) {
setPolicyChanged(false);
dispatch(removeNotificationWizardForm());
return true;
}
return false;
};

return (
Expand Down
5 changes: 0 additions & 5 deletions src/components/recordings/partials/RecordingsActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ const RecordingsActionCell = ({
deleteConfirmationModalRef.current?.close?.();
};

const hideRecordingDetails = () => {
recordingDetailsModalRef.current?.close?.()
};

const showRecordingDetails = async () => {
await dispatch(fetchRecordingDetails(row.name));

Expand All @@ -57,7 +53,6 @@ const RecordingsActionCell = ({
)}

<RecordingDetailsModal
close={hideRecordingDetails}
recordingId={row.name}
modalRef={recordingDetailsModalRef}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ import { Modal, ModalHandle } from "../../../shared/modals/Modal";
* This component renders the modal for displaying recording details
*/
const RecordingDetailsModal = ({
close,
recordingId,
modalRef,
}: {
close: () => void,
recordingId: string,
modalRef: React.RefObject<ModalHandle>
}) => {
const { t } = useTranslation();

return (
<Modal
closeCallback={close}
header={t("RECORDINGS.RECORDINGS.DETAILS.HEADER", {
name: recordingId,
})}
Expand Down
8 changes: 6 additions & 2 deletions src/components/shared/modals/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { useTranslation } from "react-i18next";

export type ModalProps = {
open?: boolean
closeCallback?: () => void
// Having this return false will prevent the modal from closing
closeCallback?: () => boolean
/** If true, the first element in the modal automatically be focused. If false,
* no element is initially focused */
initialFocus?: false | string
Expand Down Expand Up @@ -43,7 +44,10 @@ export const Modal = forwardRef<ModalHandle, PropsWithChildren<ModalProps>>(({
isOpen: () => isOpen,
open: () => setOpen(true),
close: () => {
closeCallback !== undefined && closeCallback();
if (closeCallback !== undefined && !closeCallback()) {
// Don't close modal
return;
}
setOpen(false);
},
}), [closeCallback, isOpen]);
Expand Down

0 comments on commit 0e44e3c

Please sign in to comment.