Allow publication members to manage leaflets - #357
Merged
Conversation
…he dashboard Confirmed contributors of a publication previously got owner-only gating in the leaflet options menu and its server actions, so drafts and posts of publications they belong to behaved differently on /home than in the publication dashboard's draft and post lists: - Published posts fell into the draft menu (no Unpublish/Delete Post) because the menu keyed off the document URI containing the viewer's DID, which only matches the publication owner, even though deletePost/unpublishPost already authorize confirmed contributors. - Delete Forever on a publication draft was shown but failed server-side, since deleteLeaflet only allowed the publication owner. - Archive only set the viewer's homepage flag; the draft stayed in the publication's draft list because archivePost/unarchivePost only updated leaflets_in_publications for the owner. Now membership (owner or confirmed contributor, via identity.publications / contributor_publications against the leaflet's publication URI) drives the menu, deleteLeaflet accepts confirmed contributors, and archiving updates the publication row for members. Delete is hidden on publication drafts for non-members instead of failing after the fact. Contributed leaflets on /home also surface the publication's archived state instead of hardcoding false, so archived contributor drafts move into the archived filter like owned ones. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wxGwFe3uCZ9MhpmvRDo8n
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…de/draft-delete-archive-consistency-vls2y7
…te take effect The /home and looseleafs lists never recognized a leaflet as published because the identity query fetched leaflets_in_publications and leaflets_to_documents without their documents embed, which useLeafletPublicationStatus needs to compute documentUri/isPublished. So published publication posts fell into the draft menu instead of getting Copy Post Link / Unpublish / Delete Post, and published looseleafs showed neither those options nor the "Published" label. Fetching the documents embed (for both owned and contributed leaflets) fixes all three surfaces, since they share LeafletList and LeafletOptions. On the publication dashboard's post list, Unpublish and Delete appeared to do nothing: the server actions succeeded, but the list renders from the publication SWR cache's `documents`, which nothing updated, and the success toast fired regardless of the action result. Now unpublish clears the published-document references in both the identity and publication caches (resurfacing the leaflet in the dashboard's draft list, mirroring how get_publication_data derives drafts), delete also drops the post from `documents`, deleteLeaflet is awaited, and a failed action shows an error toast instead of claiming success. The unpublish subtext now says "Turn this post back into a draft" for standalone looseleafs, since they have no publication drafts list to move into. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends leaflet management permissions to include confirmed contributors of a publication, not just the publication owner. This allows any member (owner or contributor) to:
Changes
Backend (
actions/deleteLeaflet.ts)isConfirmedContributorto check contributor statusdeleteLeaflet()to allow deletion by publication members (owners or confirmed contributors), not just ownersarchivePost()andunarchivePost()to use newsetArchivedInPublications()helpersetArchivedInPublications()function handles archive state for all publication membersFrontend (
LeafletOptions.tsx)useCanManagePost()hook consolidates member check logic (owner or contributor)contributor_leafletsdata alongside owned leafletsFrontend (
HomeLayout.tsx)HomeLeafletList()to read archived state from publication's draft list for contributed leafletsFrontend (
PageSWRDataProvider.tsx)publicationUrifield to track which publication a leaflet belongs to (published or draft)Checklist
Test Plan
Verify that a confirmed contributor can:
https://claude.ai/code/session_017wxGwFe3uCZ9MhpmvRDo8n