Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(site): keep organizations out of the admin-settings gate - #27251

Closed
jakehwll wants to merge 3 commits into
mainfrom
jakehwll/devex-546-bug-users-should-not-see-admin-settings-dropdown
Closed

fix(site): keep organizations out of the admin-settings gate#27251
jakehwll wants to merge 3 commits into
mainfrom
jakehwll/devex-546-bug-users-should-not-see-admin-settings-dropdown

Conversation

@jakehwll

@jakehwll jakehwll commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Fixes #26695

Problem

On a licensed/multi-org deployment, a regular member sees an Admin settings dropdown (containing Organizations) even though they are not an admin.

Root cause: canViewAdminSettings surfaced the menu when any permission was set, and canViewOrganizations was one of them. That flag is true for ordinary members (e.g. viewAnyMembers), so the menu appeared for non-admins. MobileMenu duplicated the same check inline.

Change

Minimal gating fix, keeping Organizations where it already lives:

  • canViewAdminSettings now ignores canViewOrganizations and gates purely on genuine admin permissions (deployment, audit, connection log, AI, health).
  • MobileMenu reuses canViewAdminSettings instead of its own inline Object.values(...).some(...), so desktop and mobile share one source of truth.
  • getAdminSettingsItems is unchanged: Organizations stays in the Admin settings menu and is shown whenever the menu is shown (i.e. the user has an admin permission).

Net effect: members with only organization-view access no longer see the Admin settings menu; admins keep the menu with Organizations in it. Diff is 3 files.

Testing

  • pnpm lint:types, biome check, and knip pass.
  • New unit test adminSettings.test.ts: canViewAdminSettings returns false for organization access alone and true for a genuine admin permission; getAdminSettingsItems always lists Organizations.
  • Existing NavbarView/MobileMenu stories and the roles.spec.ts e2e (Organizations under Admin settings) continue to pass.
Relationship to #26731

This is an alternative to community PR #26731, which fixed the same issue but introduced a canView/canManage organization split across ~22 files and relocated Organizations into the user menu. This PR keeps Organizations in the Admin settings menu and only corrects the gate, in ~3 files with no permission-model changes.

…dmin menu

Non-admin members no longer see the Admin settings dropdown just because
they can view organizations. Organizations is not an admin setting, so it
now lives in the user menu (desktop user dropdown and mobile user
settings) for anyone who can view organizations, and the Admin settings
menu is gated purely on genuine admin permissions.

Fixes #26695
@linear-code

linear-code Bot commented Jul 15, 2026

Copy link
Copy Markdown

DEVEX-546

Organizations is no longer an item in the Admin settings menu, so the
roles e2e no longer expects it there.
@jakehwll jakehwll changed the title fix(site/src/modules/dashboard/Navbar): move organizations out of admin menu fix(site): move organizations out of admin menu Jul 16, 2026
@jakehwll
jakehwll marked this pull request as ready for review July 20, 2026 04:06
@jakehwll
jakehwll requested a review from jeremyruppel July 20, 2026 04:06
@coderagents

coderagents Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

The approach in this PR was reworked. Organizations now stays under the Admin settings dropdown (getAdminSettingsItems still lists it, covered by the new adminSettings.test.ts "always includes Organizations" test). The change now only prevents the Admin settings menu from surfacing for org-only members; it no longer relocates Organizations to the user menu.

Because the Admin settings > Organizations navigation path is unchanged, the previously flagged doc updates are no longer needed.

Updates Needed

  • docs/admin/users/organizations.md - Steps route through Admin settings > Organizations. (nav path unchanged in 4a25de7)
  • docs/admin/provisioners/manage-provisioner-jobs.md - "Admin settings > Organizations > Provisioner Jobs". (nav path unchanged in 4a25de7)
  • docs/admin/users/idp-sync.md - "Admin settings, select Organizations, then IdP Sync". (nav path unchanged in 4a25de7)
  • docs/ai-coder/agents/getting-started.md - "Admin settings > Organizations". (nav path unchanged in 4a25de7)

No documentation changes are required for this PR.


Automated review via Coder Agents

@jakehwll
jakehwll requested review from aqandrew and aslilac July 21, 2026 05:56

@aslilac aslilac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

moving admin settings under the user dropdown for people who do actually have administrative abilities is not the right fix. we already rejected a pr that did basically this exact same thing. 😅

Non-admin members no longer see the Admin settings menu just because they
can view organizations. canViewAdminSettings now ignores canViewOrganizations,
and MobileMenu reuses it instead of its own inline check, so both desktop and
mobile gate the menu on genuine admin permissions. Organizations remains an
item in the menu for admins.

Fixes #26695
@jakehwll jakehwll changed the title fix(site): move organizations out of admin menu fix(site): keep organizations out of the admin-settings gate Jul 22, 2026
@jakehwll
jakehwll requested a review from aslilac July 23, 2026 04:09
@jakehwll

Copy link
Copy Markdown
Contributor Author

Closing in favour of #27481

@jakehwll jakehwll closed this Jul 24, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: users should not see admin settings dropdown

2 participants