fix: Allow reordering subdocuments with document-only access (#12493)

* fix: Allow reordering subdocuments with document-only access

When a user has "Manage" (or any move-eligible) permission on a parent
document but no access to its collection, the sidebar drop cursors were
hidden because they gated on collection.isManualSort, and the move
handler bailed out because it built the payload from collection.id.
Fall back to the document's own collectionId and the move policy so the
reorder UX works for sourced document memberships.

* fix: Structure not refetched
parentDocumentId not provided
This commit is contained in:
Tom Moor
2026-05-27 21:33:33 -04:00
committed by GitHub
parent ded7ff994e
commit 7473d5b437
4 changed files with 73 additions and 8 deletions
@@ -2672,6 +2672,50 @@ describe("#documents.move", () => {
});
expect(res.status).toEqual(403);
});
it("should allow reordering subdocuments with document-only admin access", async () => {
const owner = await buildUser();
const collection = await buildCollection({
teamId: owner.teamId,
userId: owner.id,
permission: null,
});
const parent = await buildDocument({
teamId: owner.teamId,
userId: owner.id,
collectionId: collection.id,
});
const childA = await buildDocument({
teamId: owner.teamId,
userId: owner.id,
collectionId: collection.id,
parentDocumentId: parent.id,
});
const childB = await buildDocument({
teamId: owner.teamId,
userId: owner.id,
collectionId: collection.id,
parentDocumentId: parent.id,
});
const user = await buildUser({ teamId: owner.teamId });
await UserMembership.create({
documentId: parent.id,
userId: user.id,
createdById: owner.id,
permission: DocumentPermission.Admin,
});
const res = await server.post("/api/documents.move", user, {
body: {
id: childB.id,
parentDocumentId: parent.id,
index: 0,
},
});
expect(res.status).toEqual(200);
expect(childA).toBeTruthy();
});
});
describe("#documents.restore", () => {