Repository navigation
Add opt-in teams to the starter kit - #45
Merged
Merged
Conversation
INERTIA_TEAMS=1 (or the prompt, default no) adds teams to the starter kit, ported from Laravel's starter kits for React, Vue and Svelte: - a personal team per user, plus shared teams - owner/admin/member roles checked with Action Policy - email invitations, accepted or declined from the dashboard; the email links to the sign in page, which shows what the visitor was invited to; expired invitations are deleted daily - team switcher and team settings pages - team pages under /:team_slug, with /dashboard redirecting to the current team so sign in and existing links keep working Deleting an account is refused while it owns a team other people belong to. The sync workflow now also generates each kit with teams and opens a PR against a teams branch in the kit repo. Kits without teams change in three one-line places: the settings menu highlights nested pages, and two tests no longer depend on the dashboard or on the first fixture user.
Type team roles with the MembershipRole enum Typelizer generates from the model, and give permissions their own serializer, so the Alba variant no longer repeats the role and permission names as strings. The hand-written TeamPermissions type is dropped there, like the other types the serializers generate.
Give the invitation context its own serializer instead of a raw TypeScript string repeated in two page serializers, and name the role type MembershipRole, as Typelizer does. In Alba kits both hand-written types are now removed in favour of the generated ones.
Pages declared their props by hand even in kits where Typelizer generates the same types from the page serializers. Pages now import the props type by the name the serializer generates (SettingsTeamsShow, SessionsNew, ...). Kits without Alba keep a hand-written copy in types/index.ts; Alba kits strip it, like the model types, so the generated one is used.
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.
What
INERTIA_TEAMS=1(or the new prompt, default no) adds teams to the starter kit, for React, Vue and Svelte. It is a port of theteamsbranch of Laravel's starter kits./:team_slug/..., so links, bookmarks and browser tabs keep pointing at the same team. Opening a team's page makes it the current teamHow it is built
template/shared/starter_teamsand is copied on top of the starter backend. Existing files that need a few extra lines (User,ApplicationController, routes, shared props) carry<% if use_teams %>blocks instead of being duplicated.Fieldcomponents, Typelizer route helpers, snake_case props./dashboardstays as a redirect to the current team's dashboard, so sign in, sign up and existing links keep working without changes.template/shared/starter_teams_alba, and the generated types replace the hand-written ones as before.Published kits
The sync workflow now generates every kit twice and opens two PRs per kit: one against
mainas before, one against ateamsbranch (generated withINERTIA_TEAMS=1). The first run creates theteamsbranch frommain.Where it differs from Laravel, on purpose
Kits without teams
Three one-line changes:
startsWith)Verified
rake test(256 runs) andstandardrbpass; the newsvelte_starter_kit_teamse2e config passes.Not verified