Skip to content

Allow publication members to manage leaflets - #357

Merged
bschlagel merged 3 commits into
mainfrom
claude/draft-delete-archive-consistency-vls2y7
Jul 27, 2026
Merged

Allow publication members to manage leaflets#357
bschlagel merged 3 commits into
mainfrom
claude/draft-delete-archive-consistency-vls2y7

Conversation

@jaredpereira

Copy link
Copy Markdown
Contributor

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:

  • Delete leaflets in their publication
  • Archive/unarchive leaflets in their publication
  • Access the same manage options in /home, publication dashboard drafts, and post lists

Changes

Backend (actions/deleteLeaflet.ts)

  • Import isConfirmedContributor to check contributor status
  • Update deleteLeaflet() to allow deletion by publication members (owners or confirmed contributors), not just owners
  • Refactor archivePost() and unarchivePost() to use new setArchivedInPublications() helper
  • New setArchivedInPublications() function handles archive state for all publication members

Frontend (LeafletOptions.tsx)

  • New useCanManagePost() hook consolidates member check logic (owner or contributor)
  • Replace scattered ownership checks with the new hook
  • Update delete permission logic to allow members to delete published posts in their publication
  • Fix cache mutations to handle contributor_leaflets data alongside owned leaflets

Frontend (HomeLayout.tsx)

  • Update "hasArchived" check to include archived state from contributed leaflets
  • Fix HomeLeafletList() to read archived state from publication's draft list for contributed leaflets

Frontend (PageSWRDataProvider.tsx)

  • Add publicationUri field to track which publication a leaflet belongs to (published or draft)

Checklist

  • Looks good on mobile and desktop
  • Undo/redo works correctly (archive mutations properly update cache)
  • Keyboard interactions handled (menu navigation unchanged)
  • No build errors

Test Plan

Verify that a confirmed contributor can:

  1. Delete a leaflet in their publication (previously only owner could)
  2. Archive/unarchive leaflets in their publication from /home and publication dashboard
  3. See manage options in all three locations (/home, draft list, post list)
  4. Undo archive/unarchive operations correctly

https://claude.ai/code/session_017wxGwFe3uCZ9MhpmvRDo8n

…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
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
minilink Ready Ready Preview, Comment Jul 24, 2026 10:50pm

Request Review

jaredpereira and others added 2 commits July 24, 2026 18:37
…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>
@bschlagel
bschlagel merged commit 7aa4e5e into main Jul 27, 2026
2 checks passed
@bschlagel
bschlagel deleted the claude/draft-delete-archive-consistency-vls2y7 branch July 27, 2026 19:15
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.

3 participants