Skip to content

fix: don't show admin settings dropdown to everyone (backport to 2.35) - #27815

Closed
rowansmithau wants to merge 3 commits into
release/2.35from
rowan/backport_27481_235
Closed

fix: don't show admin settings dropdown to everyone (backport to 2.35)#27815
rowansmithau wants to merge 3 commits into
release/2.35from
rowan/backport_27481_235

Conversation

@rowansmithau

Copy link
Copy Markdown
Member

created with the help of Mux, as cherry picking b8727d9 from #27481 had conflicts. It was determined that additional commits were necessary.

validated local tests pass as part of creating this.

tracyjohnsonux and others added 3 commits August 4, 2026 00:44
)

## Problem

The desktop `DeploymentDropdown` surfaces **AI** and **AI sessions**
items under Admin settings (behind `canViewAISettings` /
`canViewAIBridge`), but the mobile `MobileMenu` was never updated to
match — its `AdminSettingsSub` only knows about Deployment,
Organizations, Audit logs, Connection logs, and Healthcheck.

This is a leftover from #25582 ("promote AI settings to a top-level
section"), which threaded `canViewAISettings` through `Navbar` /
`NavbarView` / `DeploymentDropdown` but did not touch `MobileMenu.tsx`.
`canViewAIBridge` has the same oversight.

## Fix

- Extend `MobileMenuPermissions` with `canViewAIBridge` and
`canViewAISettings`.
- Render **AI** (→ `/ai/settings`) and **AI Sessions** (→
`/ai-gateway/sessions`) in the mobile Admin settings collapsible, in the
same order as the desktop dropdown.
- Thread the two flags through `NavbarView` into `MobileMenu`.
- Cover the new args in `MobileMenu.stories.tsx` (Admin story now shows
the AI items; Auditor / OrgAdmin / Member keep them hidden).

No backend, permission, or routing changes.

> 🤖 This PR was drafted by Coder Agents on behalf of @tracyjohnsonux and
needs a human review.
> 🤖 This PR was written by Coder Agents on behalf of Jake Howell.

## Problem

#27191 fixed the mobile menu missing the **AI** / **AI sessions** items,
but did so by duplicating the item list. The desktop
`DeploymentDropdown` and mobile `MobileMenu` each hardcode the same
Admin settings links and permission gates. That duplication is exactly
why the two drifted out of sync in the first place, and it will happen
again the next time an item is added.

## Fix

Extract a single source of truth in `adminSettings.ts`:

- `AdminSettingsPermissions` type shared by both surfaces.
- `getAdminSettingsItems(permissions)` builds the ordered item list
using conditional spreads, e.g.

  ```ts
  ...(canViewAISettings ? [{ label: "AI", to: "/ai/settings" }] : []),
  ```

- `canViewAdminSettings(permissions)` for the desktop visibility gate.

`DeploymentDropdown` and `MobileMenu` now just `.map()` over the shared
list, so adding or changing an item is a one-line edit in one place.

No backend, permission, routing, or user-visible behavior changes. Item
labels, links, and order match the current desktop dropdown (mobile now
inherits the same `linkToAuditing` constant instead of a hardcoded
`/audit`, same value).

<details>
<summary>Rationale / approach</summary>

Following Larry Wall's virtues: laziness (one list to maintain, not
two), impatience (kill the class of bug where the two menus silently
diverge), and hubris (leave a shared module nobody has to apologize
for).

Kept `canViewOrganizations` in the permission type and visibility gate
even though Organizations always renders, preserving prior behavior
rather than changing it as part of a refactor.

Validated with `biome check` and `tsc --noEmit`; existing
`MobileMenu.stories.tsx` args already cover the Admin / Auditor /
OrgAdmin / Member permission matrices.

</details>
@rowansmithau
rowansmithau requested a review from aslilac August 4, 2026 01:25
@rowansmithau rowansmithau self-assigned this Aug 4, 2026
@rowansmithau rowansmithau added the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Aug 4, 2026
@github-actions github-actions Bot added the stale This issue is like stale bread. label Aug 13, 2026
@github-actions github-actions Bot closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Changes that might not necessarily be merged, until its approved to proceed with. stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants