Skip to content

fix(dashboard): permission-gate the Recycle bin tabs and nav entry#1294

Merged
iammukeshm merged 1 commit into
mainfrom
fix/dashboard-trash-tab-permissions
Jun 9, 2026
Merged

fix(dashboard): permission-gate the Recycle bin tabs and nav entry#1294
iammukeshm merged 1 commit into
mainfrom
fix/dashboard-trash-tab-permissions

Conversation

@iammukeshm

Copy link
Copy Markdown
Member

What

The Trash page (/system/trash) renders five tabs — Products, Brands, Categories, Tickets, Files — that were hard-coded with no permission check. A user with rights to restore some resources but not others could click a tab and hit a 403 error band (e.g. a tenant member without Files access opening the Files tab).

The dashboard already permission-gates its sidebar nav (nav-data.tsvisibleSections); the Trash tabs just never got the same treatment. This closes that gap.

How

  • src/lib/trash-permissions.ts (new) — single source of truth mapping each trash tab → the permission its endpoint enforces (Permissions.Catalog.{Products,Brands,Categories}.Restore, Permissions.Tickets.Restore, Permissions.Files.ViewTrash), plus a flat ALL_TRASH_PERMISSIONS.
  • src/components/layout/nav-data.ts — added anyPerm?: readonly string[] to NavSpec (visible if the user holds any listed permission, AND-combined with perm); gated the Trash sidebar entry on ALL_TRASH_PERMISSIONS so it hides when the user can reach no tab.
  • src/pages/system/trash.tsx — filters tabs to those the user can access; when the hard-coded default (Products) is gated away, falls back to the first visible tab; shows a "no recycle bins available" empty state on a direct visit with zero trash permissions.

The server keeps enforcing every permission with a 403 — this is purely the UX layer.

Tests

tests/system/trash.spec.ts — existing specs now grant the trash permissions in beforeEach (the gate otherwise hides everything); two new specs cover tabs hiding + defaulting to the first visible tab, and the no-access empty state. All 5 green; tsc -b + eslint clean.

Docs

Changelog entry added in the docs repo.

🤖 Generated with Claude Code

The Trash page's five tabs were hard-coded with no permission check, so a
user with rights to restore some resources but not others (e.g. catalog but
not Files) could click a tab and hit a 403 error band. The dashboard already
gates its sidebar nav this way; the Trash tabs just never got the treatment.

Gate each tab on the permission its trash endpoint enforces (the resource's
Restore, or Files.ViewTrash), hide tabs the user can't reach, and fall back to
the first visible tab when the hard-coded default (Products) is gated away. Add
anyPerm[] to NavSpec so the Trash sidebar entry hides when none are reachable,
and show a no-access empty state on a direct visit. Server still enforces 403
as defence-in-depth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iammukeshm iammukeshm merged commit 6128d12 into main Jun 9, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant