Repository navigation
feat(settings): choose which left-menu sections each role sees (menu access, part 3) - #1704
Merged
Merged
Conversation
… part 1)
Menu access, part 1 of 7: the data and the rule, with no UI yet.
- 00374 adds organization_menu_roles, the sections a role (not admin)
doesn't see. Members of the organization read it and the server
writes it.
- On profiles it adds menu_shown, menu_hidden and can_manage_menus,
which only the server sets (00228's guard is extended), and
work_areas and work_areas_asked_at, which the person sets.
- lib/menu-access.ts holds the rule: the role's sections, then the
person's exceptions, narrowed to their work areas.
- Action Center is always on.
- Nobody takes a section off an admin's menu; only their own work
areas narrow it.
- A section is named by its route, so a new one shows by default.
- lib/actions/menu-access.ts covers getMyMenu, the Settings data, the
role table, per-person exceptions and menu managers (admin only).
It also writes the person's own work areas.
Hide only: pages still open from a link, roles and data access don't
change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…enu access, part 2) The dashboard layout reads the viewer's menu once (getMyMenu, part 1) and hands the sections it leaves out to a MenuAccessProvider. Both menus filter by them through shouldShowDashboardNavItem: - the sidebar drops a group whose sections are all off the menu, title and all; - the mobile menu drops the active brand's Prompts link with the Prompts section. If the menu can't be read, the whole menu shows. Hide only: an address still opens its page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A removed member keeps their profile and an invitation moves it to the next organization, so a menu manager of one organization arrived in another still able to change its menus, with their old exceptions. A trigger now clears menu_shown, menu_hidden and can_manage_menus on a new organization and can_manage_menus on a new role, unless the same update sets them; it fires after the guard, so the guard still checks what the person asked for. Also reloads PostgREST's schema at the end of 00374, validates setMenuManager's flag with Zod, and tests that the work-area check in the database lists exactly the app's work areas. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…access, part 3)
A new Settings section, Menu access, for admins and the managers they let
change menus. Others don't see it in Settings, and its address tells them
who can.
- A table of the menu's sections by its groups, with a column per role:
- each box saves at once, and is put back with a toast if the save
fails;
- Admin is always Everything, and Action Center can't be turned off;
- "Use a set…" fills a role from a work area's ready-made set, or
Everything.
- Fixed column shares keep the table inside Settings' column at 1024 px.
- en.json carries the copy and the nine work areas' names and lines, so
the Account and welcome-step parts can use them too.
- MenuAccessProvider also carries whether the viewer can change menus.
The plan dialog for a workspace whose plan has ended follows once ansvisor#1599
lands.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…areas "What do you work on?" is for new sign-ups and people joining from an invite, once. Without this, every existing person would get the step at their next sign-in. They can still pick work areas in Settings › Account. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… access, part 2 review) The dashboard layout read the viewer's menu through getMyMenu, a second user check and profile read after its own: two or three requests in a row on every render. The menu columns now come with the profile the layout already reads. The role's row (none for admins) is read alongside the organization and the brands. menuOfProfile builds the menu from both, and getMyMenu uses the same. - A role row that can't be read is logged (console.error) and the menu shows whole, rather than the failure passing silently. - The sidebar no longer reads the tracked prompts' count while Prompts is off the menu. - Tests cover a group dropped with its title when all its sections are hidden, the whole menu without a menu to go by, the count not read, the mobile menu leaving hidden sections off (the brand's Prompts link with Prompts), and readRoleHidden. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ettings # Conflicts: # web/src/app/[locale]/(dashboard)/layout.tsx
…let "Use a set…" fit (menu access, part 3 review) - A failed save on Menu access reads the role table again, instead of putting back the state from before it, which also undid a later save that had gone through. - No router.refresh after a save: setRoleMenu's revalidatePath already brings the menu up to date, so each click no longer renders twice. - The role columns get a little more of the table, and the select's chevron is smaller, so "Use a set…" isn't cut at 1024 px with the sidebar open. - Tests: picking a ready-made set saves it; a failed save next to a successful one keeps the successful one; Settings lists Menu access only for someone who can change menus. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…menu access, part 3 review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 8 tasks
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
- Own change. The diff from part 2's head (c323a26) to c00f8e1: f87fd5b (feature), fc4d5f4 and c00f8e1 (review fixes), and three merges of part 2. It touches no migration, so 00374 is the same as in part 1. On today's main, only part 1's
supabase/schema.sqlconflicts.en.jsonchanged on main too, but merges cleanly. - Who sees it. The layout now passes
canManageMenusto the provider. Settings lists Menu access only for admins and the managers an admin allowed. Anyone else who opens/dashboard/settings/menu-accessfrom a link sees a short "not allowed" card, and their settings are never read. The server still decides:getMenuAccessSettingsandsetRoleMenuboth callrequireMenuManager, work only on the caller's organization, andsetRoleMenurefuses any role outside manager, analyst and agency partner. So nobody can change the admins' row, whatever the client sends. - Hide only. The admins' column is ticked and can't be changed, and so is Action Center for every role. The note says the pages still open from a link and that nothing about what a role can do changes, which matches parts 1 and 2.
- Saving. Each box saves the role's whole list in the menu's order, and the change shows at once. When a save fails, the section shows an error message and reloads the settings from the server, so another save that did go through stays. "Use a set…" stays a placeholder (
value=""plusitems), so you can pick the same set again. "Everything" hides nothing. Each set hides the sections its work area doesn't name, and never Action Center. The Select hasitemson its root, as our Select rule asks. - Copy. The role names come from the existing
settings.team_role_*keys, and the section names fromnav, so the table reads like the menu.en.jsonis the only locale file. - Tests. I ran the section's tests, the Settings view and
_sectionstests, and part 2's sidebar, mobile-nav, navigation, menu-access and actions tests on the PR's tree: 83 tests pass.menu-access.test.tsreadssupabase/migrations, so I laid that folder out next toweb.tscshows no errors in the changed files. It does report 13 errors elsewhere, from packages missing in my test setup; those are the same without this change. - Deploy. This part depends on part 2's layout, so the same merge condition applies: 00374 goes on the database first.
Follow-ups (none block):
- Picking a set replaces every box the role had, with no undo and no confirmation. Either ask first ("Replace Manager's sections with Brand & PR?") or show an "Undo" toast that saves the previous list back.
- Wording of
settings.menuAccess.notAllowed. "Only admins, and managers an admin lets, choose…" reads as if a word is missing. Suggest: "Only admins, and managers an admin has allowed, can choose what each role sees on the menu." hiddenForSethides every section the set doesn't name. A person's work areas, in contrast, keep any section no work area names (AREA_SECTIONSinhiddenMenuSections). Today every menu section is in some work area, so the result is the same. But a section added later would be hidden by a set and kept by work areas. Use the same rule here (skip sections not in any area) so the two can't drift apart.
This was referenced Oct 28, 2026
Merged
Merged
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.
Summary
Menu access, part 3: a new Settings › Menu access section. Stacked on #1703 (part 2), which is stacked on #1702.
MenuAccessProvidernow also carriescanManageMenusfromgetMyMenu. Others don't see it in Settings' list. At its address they get one line saying who can, and nothing is read. The server actions check again (requireMenuManager).setRoleMenu, which revalidates the layout, so the sidebar follows without a client refresh); a failed save shows a toast and reads the settings again, so two quick clicks never leave the table out of step with what was saved;en.jsonundersettings.menuAccess, including the nine work areas' names and lines for the later Account and welcome-step parts.Related issue
None.
Type of change
feat— New featureHow to test
Same setup as part 2 (00374 on the dev database). Demo user
1111…, demo org2222….cd web && yarn dev, then sign in as[email protected]/demo123.select role, hidden_sections from organization_menu_roles where organization_id = '2222…';showsanalyst {content}.update profiles set role = 'manager' where id = '1111…';Reload. Settings has no Menu access,/dashboard/settings/menu-accesssays who can change menus, and the sidebar follows the Manager column from step 4. Thenupdate profiles set can_manage_menus = true where id = '1111…';Reload: Menu access is back and loads.update profiles set role = 'admin', can_manage_menus = false where id = '1111…'; delete from organization_menu_roles where organization_id = '2222…';Checklist
yarn lintpasses (0 errors; 7 warnings in files this PR doesn't touch)yarn typecheckpassesyarn formatleaves no changesyarn testandyarn buildpass, run on part 6's tip: 465 files, 4,561 tests; build OK (on part 6's tip 8c2e172).bash supabase/build-schema.shleavesschema.sqlunchangedmenu-access-section.test.tsx, incl. Use a set… and a failed save after a second click;_settings-view.test.tsx: Menu access listed only for menu managers)npm run version:check(fails on main too: docker-compose images 0.2.0)🤖 Generated with Claude Code