feat: share pages and cloud workspaces with people and teams

Merged
SA
1mo ago
+9837-784

Share pages and cloud workspaces with individual people and teams, alongside general access. Stacked on #8317; merge after it has deployed.

What changes

  • Grantees: members, teams, and people outside the org. Someone outside is invited to the organization (Free plans see the existing upgrade prompt instead), and their share becomes a member share when they accept.
  • Roles: pages have Can view / Can comment, per person and for general access (pages.organization_role). Cloud workspaces have Full access only, and no public link.
  • General access: "Only people invited" (was "Just me") / org / anyone with the link (pages only). Going public and narrowing ask first.
  • Desktop & web: one shared ShareAccess popover (@superset/ui/share-access) for pages and workspaces: invite field with email completion, role menus with Remove/Undo, a "Shared with me" pages tab, and share/unshare entries in the workspace timeline. View-only readers don't get the comment toggle.
  • Mobile: share sheets for pages and cloud workspaces (Share on a cloud workspace now opens it instead of the iOS share sheet), an Invite screen using the native search bar with a level per person, and bottom sheets for each person's access and for general access.

API (packages/trpc)

  • New: page.sharing.{get,add,remove,setRole}, page.setOrganizationRole, cloudWorkspace.sharing.{get,add,remove}. Owner only; every grantee is validated against the organization.
  • Access goes through pageAccess/pageReadableBy and canOpenWorkspace/visibleTo, which add direct and team shares. Comment writes, including comment image uploads, need comment access. Page tools (page.tools) count shares too, so someone a private page is shared with can use its tools.
  • Compatibility with released clients: page.list scopes gain shared; page.counts gains shared; page.access gains canComment/canManage; activity rows gain shareTarget. mine now also filters on the creator, which keeps its meaning now that other people's private pages can be shared with you. No existing field is removed or retyped.
  • Behaviour to note: anyone a workspace is shared with has full access, which includes archiving it, the same as org members on an org-visible workspace.
  • Invitation shares: afterAddMember turns them into member shares on accept; afterCancelInvitation/afterRejectInvitation delete them; expired ones stay hidden (listGrantees only lists pending, unexpired invitations) until the invitation row goes and the FK cascades. afterRemoveMember removes a departing member's shares.
  • Grantees are checked against the resource's organization in validateGrantees (notInOrganization); the database does not enforce it.

Verification

  • Desktop (CDP), web (headless Chrome), and iOS (Limrun simulator), each against a seeded test org on a dev Neon branch, with database rows checked after each step. Invites went only to Resend test addresses.
  • API permission checks: direct and team access, revoke on removal, NOT_FOUND for people without access, no onward sharing, outsiders refused, invite acceptance converts the share, view vs comment enforced.
  • Tests: shared, trpc, ui, auth, i18n, mobile, and the touched desktop suites pass (--isolate). check:i18n passes with all 16 locales translated, check:plugins passes, and Biome is clean.
  • Typecheck: the only errors are better-auth plugin types that fail identically on main with a fresh install in this sandbox.

Not covered / follow-ups

  • The Free-plan upgrade prompt was not exercised.
  • A rare mobile freeze was seen during simulator testing (undefined is not a function, then React's "Should not already be working"). It could not be reproduced and had no stack trace.
  • "Cancel invite" removes the share but leaves the org invitation pending.

Summary by CodeRabbit

  • New Features
    • Share pages and cloud workspaces with people, teams, or email invitees; manage access levels, invitations, and general visibility.
    • Find pages shared with you in a dedicated dashboard tab.
    • View workspace sharing and access changes in the activity timeline.
    • Manage sharing from mobile with dedicated access, invite, and permission screens.
  • Access Controls
    • Page comment controls now reflect your permission level; shared pages support view or comment access.
    • Invitation and membership changes update pending shares accordingly.