fix(site): backport admin settings dropdown visibility fix to release… · coder/coder@350070e · GitHub
Skip to content

Commit 350070e

Browse files
fix(site): backport admin settings dropdown visibility fix to release/2.34 (#27851)
Backport of #27481 to `release/2.34`. ## Problem `canViewAnyOrganization` included `viewAnyMembers`, a permission every user now has because of workspace sharing. This meant the Admin settings dropdown (and the Organizations entry within it) showed up for every user, not just admins. ## Fix - Removed `permissions.viewAnyMembers` from `canViewAnyOrganization` in `site/src/modules/permissions/index.ts`. - Updated `site/e2e/tests/roles.spec.ts` to match, including a new regression test for org members with no roles. ## Note on scope Upstream #27481 also refactored `DeploymentDropdown`/`MobileMenu` into a shared `AdminSettings.tsx` component driven by a single permissions object. That refactor doesn't apply to `release/2.34`: this branch's `DeploymentDropdown` and `MobileMenu` already gate the Admin settings menu with equivalent per-permission checks, so only the actual permission fix and its test coverage are backported here. ## Validation - `pnpm exec biome check` on the two changed files: clean. - Confirmed pre-existing `tsc` errors in this branch are unrelated environment/dependency issues (reproduced identically on a clean `release/2.34` checkout). > 🤖 This PR was created with the help of Coder Agents, and needs a human review. 🧑💻 --------- Co-authored-by: Jeremy Ruppel <jeremy.ruppel@gmail.com>
1 parent b080be4 commit 350070e

4 files changed

Lines changed: 36 additions & 19 deletions

File tree

site/e2e/tests/roles.spec.ts

Lines changed: 20 additions & 8 deletions

site/src/modules/dashboard/Navbar/DeploymentDropdown.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const DeploymentDropdown: FC<DeploymentDropdownProps> = ({
6767

6868
const DeploymentDropdownContent: FC<DeploymentDropdownProps> = ({
6969
canViewDeployment,
70+
canViewOrganizations,
7071
canViewAuditLog,
7172
canViewConnectionLog,
7273
canViewAIBridge,
@@ -80,9 +81,11 @@ const DeploymentDropdownContent: FC<DeploymentDropdownProps> = ({
8081
<Link to="/deployment">Deployment</Link>
8182
</DropdownMenuItem>
8283
)}
83-
<DropdownMenuItem asChild>
84-
<Link to="/organizations">Organizations</Link>
85-
</DropdownMenuItem>
84+
{canViewOrganizations && (
85+
<DropdownMenuItem asChild>
86+
<Link to="/organizations">Organizations</Link>
87+
</DropdownMenuItem>
88+
)}
8689
{canViewAISettings && (
8790
<DropdownMenuItem asChild>
8891
<Link to="/ai/settings">AI</Link>

site/src/modules/dashboard/Navbar/MobileMenu.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ const ProxySettingsSub: FC<ProxySettingsSubProps> = ({ proxyContextValue }) => {
208208

209209
const AdminSettingsSub: FC<MobileMenuPermissions> = ({
210210
canViewDeployment,
211+
canViewOrganizations,
211212
canViewAuditLog,
212213
canViewConnectionLog,
213214
canViewHealth,
@@ -239,12 +240,14 @@ const AdminSettingsSub: FC<MobileMenuPermissions> = ({
239240
<Link to="/deployment">Deployment</Link>
240241
</DropdownMenuItem>
241242
)}
242-
<DropdownMenuItem
243-
asChild
244-
className={cn(itemStyles.default, itemStyles.sub)}
245-
>
246-
<Link to="/organizations">Organizations</Link>
247-
</DropdownMenuItem>
243+
{canViewOrganizations && (
244+
<DropdownMenuItem
245+
asChild
246+
className={cn(itemStyles.default, itemStyles.sub)}
247+
>
248+
<Link to="/organizations">Organizations</Link>
249+
</DropdownMenuItem>
250+
)}
248251
{canViewAuditLog && (
249252
<DropdownMenuItem
250253
asChild

site/src/modules/permissions/index.ts

Lines changed: 1 addition & 2 deletions

0 commit comments

Comments
 (0)