Skip to content

feat(settings): let managers change menus and set a person's own sections (menu access, part 4) - #1705

Merged
gkhngyk merged 20 commits into
ansvisor:mainfrom
cihan-gyk:feature/menu-access-people
Oct 28, 2026
Merged

gkhngyk merged 20 commits into
ansvisor:mainfrom
cihan-gyk:feature/menu-access-people

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Menu access, part 4: under the role table in Settings › Menu access, who can change menus and each person's own sections. Stacked on part 3 (#1704), which is stacked on #1703 and #1702.

  • Who can change menus (MenuManagersCard): every manager with a switch (setMenuManager). Only admins can flip it; a manager who manages menus sees the switches disabled, with a note.
  • People (MenuPeopleCard): every non-admin with role, e-mail, their work areas, and their menu: "{Role}'s menu" or an amber "Custom: +X, −Y", plus "N of 11 sections".
  • Customize: section boxes, marked "shown for them" / "hidden for them" where they differ from the role; Action Center locked; each change saves at once (setMemberMenu); "Use {role}'s menu" resets. A failed save shows a toast and reads the settings again.
  • Rows are one line on a wide card and two at 1024 px (container query).
  • Copy in en.json under settings.menuAccess.

Related issue

None.

Type of change

  • feat — New feature

How to test

Same setup as part 2 (00374 on the dev database). You need a second member in the demo organization (invite one, or add a profile with organization_id = '2222…' and role manager).

  1. Sign in as [email protected] / demo123 (admin), open Settings › Menu access.
  2. Who can change menus: turn the manager's switch on. As that manager, Settings shows Menu access, with the switches disabled.
  3. People: Customize the manager, untick Content. Their badge reads "Custom: −Content", and their sidebar has no Content. "Use Manager's menu" puts it back.
  4. Light and dark themes, 1024 px and 1440 px: no horizontal scroll, the amber badge isn't cut.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint / yarn typecheck / yarn format pass
  • Changes are focused — one concern per PR
  • yarn test and yarn build pass, run on part 6's tip: 465 files, 4,561 tests; build OK (on part 6's tip 8c2e172).
  • Tests added (menu-access-people.test.tsx)
  • npm run version:check (fails on main too: docker-compose images 0.2.0)

🤖 Generated with Claude Code

cihan-gyk and others added 19 commits October 28, 2026 14:02
… 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]>
…ions (menu access, part 4)

Two more cards on Settings › Menu access.

Who can change menus:
- lists the managers;
- an admin switches one on (setMenuManager) to let them use this page;
- a manager who changes menus sees the switches but can't flip them.

People: every non-admin with their role, work areas, menu ("{role}'s
menu", or "Custom: +Prompts, −Content") and how many sections it keeps.
Customize opens their sections:
- ticked as their role has them;
- a change from the role marked "shown for them" or "hidden for them";
- Action Center always on;
- each box saved at once (setMemberMenu);
- "Use {role}'s menu" goes back to the role's.

A failed save puts the switch or box back, with a toast. A row lays out on
one line when the card is wide, and on two when it's narrow (1024 px).

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]>
…access, part 4 review)

As with the role table: a failed save on Who can change menus or People
reads the settings again (onFailed), instead of putting back the state
from before it, which could undo a later save that had gone through. No
router.refresh after a save: setMenuManager and setMemberMenu revalidate
already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups.

What I checked:

  • Own change. Part 4's own diff is a08247c against part 3's head (c00f8e1): menu-access-people.tsx and its test (new), the two cards in menu-access-section.tsx, and 26 keys in en.json. No change to supabase/ here, so 00374 is the same as in part 1. On today's main only part 1's supabase/schema.sql conflicts; this part's en.json keys merge without a conflict.
  • Who can change whose menu. The cards call part 1's actions, and those check again on the server. setMenuManager re-reads the caller and lets only an admin change it, only for a manager in the same organization. setMemberMenu takes an admin or a manager with the menu right, refuses admin rows, and stays inside the caller's organization. The UI matches: admins are left out of People, only managers are in Who can change menus, and a manager sees the switches disabled with "Only admins choose who can change menus."
  • Hide only. Action Center stays ticked and disabled. A box writes only the person's exception to their role. memberMenuWith drops the exception when the box goes back to what the role has, and "Use {role}'s menu" clears both lists.
  • Failed saves. The change shows at once. When the save fails, a toast shows and the settings are read again, so another save that went through stays.
  • Tests and types. On the PR's tree, menu-access-people.test.tsx (9 tests) passes, and so do the other Settings, sidebar and menu-access tests: 19 files, 197 tests. tsc reports nothing in the files this PR touches.

Follow-ups (none block):

  1. settings.menuAccess.person, .workAreas and .menu ("Person", "Their work areas", "Menu") aren't used anywhere, up to part 6. Use them as column headers on the wide layout, or remove them.
  2. People lists the viewer's own row, and a manager who can change menus can edit their own exceptions too. That's fine, since only the menu changes, but isCurrentUser is never shown. Adding "(you)" to that row would make it clear the change is to their own menu.
  3. A "Custom" badge can list an exception that no longer changes anything. For example, "+Content" stays after the role starts showing Content too. When the role table changes, consider dropping exceptions that match the role, or showing in the badge only the ones that still make a difference.

@gkhngyk
gkhngyk merged commit 0843409 into ansvisor:main Oct 28, 2026
4 of 5 checks passed
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants