-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Skip permission checks on the app when moving document using DnD #8333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (err instanceof AuthorizationError) { | ||
toast.error( | ||
t( | ||
"You do not have permission to move {{ documentName }} document", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"You do not have permission to move {{ documentName }} document", | |
"The document {{ documentName }} cannot be moved here", |
if (err instanceof AuthorizationError) { | ||
toast.error( | ||
t( | ||
"You do not have permission to move {{ documentName }} document to {{ parentDocumentName }} document", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"You do not have permission to move {{ documentName }} document to {{ parentDocumentName }} document", | |
"{{ documentName }} cannot be moved within {{ parentDocumentName }}", |
if (err instanceof AuthorizationError) { | ||
toast.error( | ||
t( | ||
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection", | |
"You do not have permission to move {{ documentName }} to the {{ collectionName }} collection", |
app/components/ConfirmMoveDialog.tsx
Outdated
if (err instanceof AuthorizationError) { | ||
toast.error( | ||
t( | ||
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection", | |
"You do not have permission to move {{ documentName }} to the {{ collectionName }} collection", |
Just did a round of testing and it looks like we lost the ability to drag a document to the first position in a collection |
|
||
// Drop to reorder document | ||
const [{ isOverReorder, isDraggingAnyDocument }, dropToReorder] = useDrop({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to be the culprit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index
was missing in the non-modal useDropToChangeCollection
flow.. A neat side effect is that, dropping on a collection will now move the document to the first position (consistent with doc creation flow).
One more – I can no longer drag a document into a manually sorted collection by dragging over the collection name, it's disabled |
I'm not able to repro this 🤔 Collection is disabled when the user does not have permission to create docs. Another scenario is related to dragging membership docs onto a collection (this is left as-is to not increase the scope). Any of these cases maybe? |
Oh I had it the wrong way around – it's for collections that are not manually sorted. |
Ah ok - good catch! |
/> | ||
</DropToImport> | ||
<Relative ref={parentRef}> | ||
<div ref={dropRef}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you adding the extra div here just to get the ref
? If so lets use mergeRefs instead
<Relative ref={mergeRefs([parentRef, dropRef])}>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I incorrectly assumed merge-refs would not work here..
Closes #8313
Removed permission checks for document in the app - server will now perform the necessary validation.
I also noted a couple of improvs and refactors around the DnD which I'll raise as a follow-on PR (specifically, better drop indicator to differentiate between moving inside a collection vs another parent document).