feat: add collaborator and viewer roles to trips and plans#28
Open
samrford wants to merge 4 commits into
Open
Conversation
Introduces shared access for trips and plans. Owners stay the only ones who can delete or change visibility, while contributors can edit content and viewers can see private resources. Backend - New `trip_collaborators` / `plan_collaborators` membership tables and `trip_invites` / `plan_invites` token tables, with foreign-key cascade on parent delete. - `data.Role` + `GetTripAccess` / `GetPlanAccess` helpers replace the inline `WHERE user_id = $1` checks across trips, plans, checkpoints, plan_days, and plan_items. - `ListTrips` / `ListPlans` UNION owned + collaborator rows and return a per-row `role` field; updates preserve `is_public` for non-owners. - New collaborators / invites handlers expose CRUD over membership and token-based invites with idempotent upgrade-only role on accept. - `makeImageHandler` now grants collaborators access to private cover and checkpoint photos. Frontend - `Trip` / `Plan` types gain `role`; trip & plan list cards show a Contributor / Viewer pill; detail pages gate add/edit on `canEdit`. - New `ShareModal` (people list, role dropdowns, direct invite via `UserPicker`, link generation), `/invite/[token]` landing page, and `/invitations` inbox with sidebar count badge. - `UserSearch` is now a thin wrapper over a generic `UserPicker`. - Signup and login forward `?next=` so post-auth redirects land back on the invite page. Direct invites require explicit acceptance from the recipient. Invite links never expire by default and have unlimited uses until revoked.
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.
Introduces shared access for trips and plans. Owners stay the only ones
who can delete or change visibility, while contributors can edit content
and viewers can see private resources.
Backend
trip_collaborators/plan_collaboratorsmembership tables andtrip_invites/plan_invitestoken tables, with foreign-key cascadeon parent delete.
data.Role+GetTripAccess/GetPlanAccesshelpers replace theinline
WHERE user_id = $1checks across trips, plans, checkpoints,plan_days, and plan_items.
ListTrips/ListPlansUNION owned + collaborator rows and return aper-row
rolefield; updates preserveis_publicfor non-owners.token-based invites with idempotent upgrade-only role on accept.
makeImageHandlernow grants collaborators access to private cover andcheckpoint photos.
Frontend
Trip/Plantypes gainrole; trip & plan list cards show aContributor / Viewer pill; detail pages gate add/edit on
canEdit.ShareModal(people list, role dropdowns, direct invite viaUserPicker, link generation),/invite/[token]landing page, and/invitationsinbox with sidebar count badge.UserSearchis now a thin wrapper over a genericUserPicker.?next=so post-auth redirects land back onthe invite page.
Direct invites require explicit acceptance from the recipient. Invite
links never expire by default and have unlimited uses until revoked.