From fa961d7464bfef2c5cb9af833144c8369e37e07c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 28 Sep 2024 09:21:26 -0400 Subject: [PATCH] fix: Drop to reorder cursor appearing where move location is invalid --- app/components/Sidebar/hooks/useDragAndDrop.tsx | 12 ++++++++++-- shared/i18n/locales/en_US/translation.json | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/components/Sidebar/hooks/useDragAndDrop.tsx b/app/components/Sidebar/hooks/useDragAndDrop.tsx index 7226b48c0f..b4d2479d13 100644 --- a/app/components/Sidebar/hooks/useDragAndDrop.tsx +++ b/app/components/Sidebar/hooks/useDragAndDrop.tsx @@ -279,11 +279,19 @@ export function useDropToReorderDocument( >({ accept: "document", canDrop: (item: DragObject) => { - if (item.id === node.id) { + if (item.id === node.id || !policies.abilities(item.id)?.move) { return false; } - return policies.abilities(item.id)?.move; + const params = getMoveParams(item); + if (params?.collectionId) { + return policies.abilities(params.collectionId)?.updateDocument; + } + if (params?.parentDocumentId) { + return policies.abilities(params.parentDocumentId)?.update; + } + + return true; }, drop: async (item) => { if (!collection?.isManualSort && item.collectionId === collection?.id) { diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index cf519fc0b5..eee85c934c 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -646,7 +646,7 @@ "view and edit access": "view and edit access", "view only access": "view only access", "no access": "no access", - "Heads up – moving the document {{ title }} to the {{ newCollectionName }} collection will grant all members of the workspace {{ newPermission }}, they currently have {{ prevPermission }}.": "Heads up – moving the document {{ title }} to the {{ newCollectionName }} collection will grant all members of the workspace {{ newPermission }}, they currently have {{ prevPermission }}.", + "Moving the document {{ title }} to the {{ newCollectionName }} collection will grant all members of the workspace {{ newPermission }}, they currently have {{ prevPermission }}.": "Moving the document {{ title }} to the {{ newCollectionName }} collection will grant all members of the workspace {{ newPermission }}, they currently have {{ prevPermission }}.", "Moving": "Moving", "Search documents": "Search documents", "No documents found for your filters.": "No documents found for your filters.",