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

@@ -128,7 +128,7 @@ describe("no collection", () => {
expect(abilities.createChildDocument).toEqual(false);
expect(abilities.delete).toEqual(true);
expect(abilities.download).toEqual(true);
expect(abilities.move).toEqual(false);
expect(abilities.move).toEqual(true);
expect(abilities.permanentDelete).toEqual(false);
expect(abilities.pin).toEqual(false);
expect(abilities.pinToHome).toEqual(false);

View File

@@ -174,14 +174,7 @@ allow(User, "move", Document, (user, document) => {
if (document.deletedAt) {
return false;
}
if (!document.publishedAt) {
return false;
}
invariant(
document.collection,
"collection is missing, did you forget to include in the query scope?"
);
if (cannot(user, "update", document.collection)) {
if (document.collection && cannot(user, "update", document.collection)) {
return false;
}
return user.teamId === document.teamId;