feat: Allow moving draft documents (#4652)

* feat: Allow moving draft documents

* Allow drag-n-drop move of draft documents

* fix: Allow moving draft without a collection

* fix: Allow moving draft without a collection
This commit is contained in:
Tom Moor
2023-01-06 19:31:06 -08:00
committed by GitHub
parent 9f825b9adf
commit e67ac1215a
8 changed files with 61 additions and 63 deletions

View File

@@ -27,7 +27,7 @@ import { useStarredContext } from "./StarredContext";
type Props = {
collection: Collection;
expanded?: boolean;
onDisclosureClick: (ev: React.MouseEvent<HTMLButtonElement>) => void;
onDisclosureClick: (ev?: React.MouseEvent<HTMLButtonElement>) => void;
activeDocument: Document | undefined;
isDraggingAnyCollection?: boolean;
};
@@ -62,7 +62,7 @@ const CollectionLink: React.FC<Props> = ({
// Drop to re-parent document
const [{ isOver, canDrop }, drop] = useDrop({
accept: "document",
drop: (item: DragObject, monitor) => {
drop: async (item: DragObject, monitor) => {
const { id, collectionId } = item;
if (monitor.didDrop()) {
return;
@@ -81,7 +81,8 @@ const CollectionLink: React.FC<Props> = ({
if (
prevCollection &&
prevCollection.permission === null &&
prevCollection.permission !== collection.permission
prevCollection.permission !== collection.permission &&
!document?.isDraft
) {
itemRef.current = item;
@@ -97,7 +98,11 @@ const CollectionLink: React.FC<Props> = ({
),
});
} else {
documents.move(id, collection.id);
await documents.move(id, collection.id);
if (!expanded) {
onDisclosureClick();
}
}
},
canDrop: () => canUpdate,