Skip to content

feat(web): let admins switch to any group - #1590

Merged
joshunrau merged 1 commit into
DouglasNeuroInformatics:mainfrom
joshunrau:feat/admin-group-switcher
Oct 1, 2026
Merged

joshunrau merged 1 commit into
DouglasNeuroInformatics:mainfrom
joshunrau:feat/admin-group-switcher

Conversation

@joshunrau

Copy link
Copy Markdown
Collaborator

Closes #1545

What changed

Admins already hold manage all on the API, but the group switcher only offered the groups on their token. For admins it now lists every group on the platform, from GET /v1/groups. Everyone else still sees only their own groups. The API is unchanged.

  • New hook, useSwitchableGroups (apps/web/src/hooks/): returns every group for an admin (ability.can('manage', 'all'), the same check useNavItems uses) and the token's groups for everyone else. Until the admin's full list loads, the switcher shows the admin's own groups, so it never goes blank.
  • Admins who belong to no group still start with no group selected, as before. They now see the switcher with a translated "Select a group" placeholder.
  • Login is unchanged. If an admin picks a group they aren't a member of, that choice lasts until logout and isn't restored after they log in again.
  • Test selectors: the seeded admin now sees the switcher, which is a combobox. Two admin specs that clicked "the first combobox on the page" now target their own field by testid. The settings page's switcher-position select gets a new testid, group-switcher-position-select.

Verification

  • Unit tests: apps/web/src/hooks/__tests__/useSwitchableGroups.test.ts and apps/web/src/__tests__/group-switcher.test.tsx
  • E2e spec: testing/src/specs/group-switcher.spec.ts. It checks three cases:
    • an admin switches into a group they don't belong to, and the dashboard's summary request is then scoped to it;
    • an admin with no memberships sees the placeholder;
    • a group manager is offered only their own groups.
  • pnpm lint, pnpm test (1525 tests) and pnpm test:e2e (243 tests) all pass locally.

Known limitations

  • Brief flicker: an admin who belongs to exactly one group sees their group as plain text for a moment, until the full list loads and it becomes a dropdown.
  • Deleting the selected group: if an admin deletes the group they currently have selected, it stays selected. This could already happen before this change, and this PR doesn't address it.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

An admin already holds `manage all` on the API, but the group switcher only offered the groups on
their token. Admins are now offered every group on the platform. An admin who belongs to no group
still starts with none selected and sees a placeholder until they pick one.

Admin specs that opened the first combobox on the page now target their own field by testid, since
the switcher is now a combobox for the seeded admin too.

Closes DouglasNeuroInformatics#1545

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshunrau
joshunrau merged commit de4b888 into DouglasNeuroInformatics:main Oct 1, 2026
2 checks passed
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.

Add Group Switcher for Admins

1 participant