fix: don't show admin settings dropdown to everyone (backport to 2.35) - #27815
Closed
rowansmithau wants to merge 3 commits into
Closed
fix: don't show admin settings dropdown to everyone (backport to 2.35)#27815rowansmithau wants to merge 3 commits into
rowansmithau wants to merge 3 commits into
Conversation
) ## 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>
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.
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.