8000 fix: Skip permission checks on the app when moving document using DnD by hmacr · Pull Request #8333 · outline/outline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 9 commits into from
Feb 6, 2025

Conversation

hmacr
Copy link
Collaborator
@hmacr hmacr commented Feb 4, 2025

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).

@auto-assign auto-assign bot requested a review from tommoor February 4, 2025 11:35
if (err instanceof AuthorizationError) {
toast.error(
t(
"You do not have permission to move {{ documentName }} document",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection",
"You do not have permission to move {{ documentName }} to the {{ collectionName }} collection",

if (err instanceof AuthorizationError) {
toast.error(
t(
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"You do not have permission to move {{ documentName }} document to {{ collectionName }} collection",
"You do not have permission to move {{ documentName }} to the {{ collectionName }} collection",

@tommoor
Copy link
Member
tommoor commented Feb 5, 2025

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({
Copy link
Member

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

Copy link
Collaborator Author

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).

@tommoor
Copy link
Member
tommoor commented Feb 5, 2025

One more – I can no longer drag a document into a manually sorted collection by dragging over the collection name, it's disabled

@hmacr
Copy link
Collaborator Author
hmacr commented Feb 5, 2025

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?

@tommoor
Copy link
Member
tommoor commented Feb 5, 2025

Oh I had it the wrong way around – it's for collections that are not manually sorted.

@hmacr
Copy link
Collaborator Author
hmacr commented Feb 5, 2025

it's for collections that are not manually sorted

Ah ok - good catch!

/>
</DropToImport>
<Relative ref={parentRef}>
<div ref={dropRef}>
Copy link
Member

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])}>

Copy link
Collaborator Author

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..

@tommoor tommoor merged commit 676e89a into main Feb 6, 2025
11 checks passed
@hmacr hmacr deleted the hmacr/8313-fix-manual-sort branch February 7, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manual sorting does not work until document policies are loaded
2 participants
0