🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

chore: unify admin settings menu items - #27209

Merged
jakehwll merged 2 commits into
mainfrom
jakehwll/refactor-admin-settings-menu
Jul 14, 2026
Merged

chore: unify admin settings menu items#27209
jakehwll merged 2 commits into
mainfrom
jakehwll/refactor-admin-settings-menu

Conversation

@jakehwll

Copy link
Copy Markdown
Contributor

🤖 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.

    ...(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).

Rationale / approach

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.

…enu items

Extract the Admin settings menu items into a single getAdminSettingsItems
helper so the desktop DeploymentDropdown and mobile MobileMenu render the
same list from one source of truth. Previously each surface hardcoded the
items and their permission gates, which is how the mobile menu drifted out
of sync with the desktop dropdown for the AI and AI sessions items.
@jakehwll jakehwll changed the title refactor(site/src/modules/dashboard/Navbar): unify admin settings menu items chore: unify admin settings menu items Jul 14, 2026
@jakehwll
jakehwll marked this pull request as ready for review July 14, 2026 02:06
@jakehwll
jakehwll requested a review from jeremyruppel July 14, 2026 02:23

@jeremyruppel jeremyruppel 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.

SUPER nice 👍

@jakehwll
jakehwll merged commit 5785211 into main Jul 14, 2026
26 of 27 checks passed
@jakehwll
jakehwll deleted the jakehwll/refactor-admin-settings-menu branch July 14, 2026 13:33
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 14, 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.

2 participants