From 490d84f766185c0d5a7bdf3edff7cdf337a368ec Mon Sep 17 00:00:00 2001 From: Aurelien Benel Date: Mon, 16 Sep 2024 18:21:37 +0200 Subject: [PATCH] FEATURE: Delete a document. --- .../src/components/DeleteDocumentAction.jsx | 40 +++++++++++++++++++ frontend/src/components/OpenedDocuments.jsx | 2 + 2 files changed, 42 insertions(+) create mode 100644 frontend/src/components/DeleteDocumentAction.jsx diff --git a/frontend/src/components/DeleteDocumentAction.jsx b/frontend/src/components/DeleteDocumentAction.jsx new file mode 100644 index 0000000..212dbe5 --- /dev/null +++ b/frontend/src/components/DeleteDocumentAction.jsx @@ -0,0 +1,40 @@ +import { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { Modal, Button } from 'react-bootstrap'; +import DiscreeteDropdown from './DiscreeteDropdown'; + +function DeleteDocumentAction({metadata, backend, setLastUpdate}) { + const focus = useNavigate('#'); + const [show, setShow] = useState(false); + + const handleClick = () => { + backend.deleteDocument(metadata) + .then(x => setLastUpdate(x._rev)) + .then(focus); + }; + + return ( + <> + setShow(true)}> + Delete... + + setShow(false)}> + + Are you sure you want to delete this document (with all of its contents and metadata). + This action cannot be undone. + + + + + + + + ); +} + +export default DeleteDocumentAction; + diff --git a/frontend/src/components/OpenedDocuments.jsx b/frontend/src/components/OpenedDocuments.jsx index 2b958a4..64ab042 100644 --- a/frontend/src/components/OpenedDocuments.jsx +++ b/frontend/src/components/OpenedDocuments.jsx @@ -8,6 +8,7 @@ import License from './License'; import DiscreeteDropdown from './DiscreeteDropdown'; import InviteEditorsAction from './InviteEditorsAction'; import BreakIntoPassagesAction from './BreakIntoPassagesAction'; +import DeleteDocumentAction from './DeleteDocumentAction'; import Bookmark from './Bookmark'; import LicenseCompatibility from './LicenseCompatibility'; @@ -68,6 +69,7 @@ function RunningHeadMargin({metadata, lectern, margin, sourceHasRubrics, marginH +