feat(frontend): currentProjectID in session + sidebar project switcher (#14) - #31
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Closes #14.
What
Phase 4, part one: the session now remembers which project the user is working in, and the sidebar gets a switcher to change it.
SessionDatagainscurrentProjectID, plus agetCurrentProjectID(request)helper.GET /projects, drops the stored id when the project is gone or the user lost access to it, auto-selects the first reachable project, and passesuser,csrfToken,projects, andcurrentProjectdown. When it re-points the session it redirects to the same URL, so child loaders run against the corrected cookie instead of the stale one they were handed./projects/new, which lands in [Phase 4] Add /projects/new and /projects pages; implement first-time flow #15). With no projects it collapses to a single "New project" call to action./projects/switch— POST-only action. Validates CSRF, re-checks membership server-side (the id comes from the browser), writes the session, and redirects back to the originating page so every loader revalidates. A switch to a project the user can no longer reach leaves the session untouched and redirects back, where the layout re-points it.ProjectandgetProjects().Drive-by fix
/eventsreturned a 500 whenever the SDK key was rejected — it is the one page still reading through the public SDK route rather than the internal API, so it had none of thenoProjectguards its siblings got in Phase 3. It now shows the same empty state as the other pages, and a rejected key renders an alert over an empty table instead of taking the page down./events/:idand the delete action had the identical crash path and are guarded too.Routing
/eventsthrough the internal project-scoped API is #17 and needs a new broker route, so it is not attempted here.Notes for review
feat/multi-tenancy, notmain—GET /projectsdoes not exist onmain.redirectTorejects absolute, protocol-relative, and backslash-prefixed targets.?projectId=from the query string; migrating them to the session is [Phase 4] Update API client and existing pages to use current project scope #17.Verification
npm run typecheck,oxlint, andoxfmt --checkare clean on every touched file. Verified live against the local Docker stack:/eventsno longer 500s with no active project.