feat(106): Required Permissions sidebar stays on workspace nav #129

Merged
ahmido merged 5 commits from 106-required-permissions-sidebar-context into dev 2026-02-22 02:42:45 +00:00
Owner

Summary

Fixes the sidebar context bug where navigating to the Required Permissions page (/admin/tenants/{id}/required-permissions) would switch the sidebar from workspace navigation to tenant-scoped navigation, confusing users.

Problem

The EnsureFilamentTenantSelected middleware detected a tenant ID in the URL and called setTenant(), which switched the entire sidebar to tenant-scoped navigation. The Required Permissions page is logically a workspace-level page that happens to reference a tenant — it should keep showing workspace nav.

Changes

Middleware (EnsureFilamentTenantSelected.php)

  • isWorkspaceScopedPageWithTenant() — new private helper that detects workspace-scoped pages containing a tenant parameter via regex
  • Livewire referer bypass — checks if a Livewire request originates from a workspace-scoped page and preserves workspace nav
  • setTenant() bypass — skips tenant activation and rememberLastTenantId() for workspace-scoped pages

Tests

  • RequiredPermissionsSidebarTest.php (NEW) — 7 tests covering:
    • Workspace nav visible on required-permissions page
    • Tenant nav absent on required-permissions page
    • Direct URL access preserves workspace nav
    • 404 for non-member tenants
    • 404 for tenants without entitlement
    • Tenant pages still show tenant sidebar (regression guard)
    • Scoped tenant resolves correctly on tenant pages

Pre-existing test fixes

  • RequiredPermissionsEmptyStateTest — fixed URL assertion (dynamic TenantResource::getUrl() instead of hardcoded /admin/onboarding)
  • RequiredPermissionsLinksTest — fixed URL assertion + multiline HTML data-testid assertion
  • RequiredPermissionsFiltersTest — fixed entra_permissions config leak from branch 105

Test Results

Suite Result
RequiredPermissions (26 tests) 26 pass (73 assertions)
Full regression (1571 tests) 1562 pass, 2 fail (pre-existing OpsUx), 7 skipped

The 2 failures are pre-existing in OpsUx/OperationCatalogCoverageTest and OpsUx/OperationSummaryKeysSpecTest — unrelated to this feature.

Spec Artifacts

  • specs/106-required-permissions-sidebar-context/plan.md
  • specs/106-required-permissions-sidebar-context/tasks.md
  • specs/106-required-permissions-sidebar-context/research.md
  • specs/106-required-permissions-sidebar-context/data-model.md
  • specs/106-required-permissions-sidebar-context/quickstart.md
## Summary Fixes the sidebar context bug where navigating to the **Required Permissions** page (`/admin/tenants/{id}/required-permissions`) would switch the sidebar from workspace navigation to tenant-scoped navigation, confusing users. ## Problem The `EnsureFilamentTenantSelected` middleware detected a tenant ID in the URL and called `setTenant()`, which switched the entire sidebar to tenant-scoped navigation. The Required Permissions page is logically a **workspace-level** page that happens to reference a tenant — it should keep showing workspace nav. ## Changes ### Middleware (`EnsureFilamentTenantSelected.php`) - **`isWorkspaceScopedPageWithTenant()`** — new private helper that detects workspace-scoped pages containing a tenant parameter via regex - **Livewire referer bypass** — checks if a Livewire request originates from a workspace-scoped page and preserves workspace nav - **`setTenant()` bypass** — skips tenant activation and `rememberLastTenantId()` for workspace-scoped pages ### Tests - **`RequiredPermissionsSidebarTest.php`** (NEW) — 7 tests covering: - Workspace nav visible on required-permissions page - Tenant nav absent on required-permissions page - Direct URL access preserves workspace nav - 404 for non-member tenants - 404 for tenants without entitlement - Tenant pages still show tenant sidebar (regression guard) - Scoped tenant resolves correctly on tenant pages ### Pre-existing test fixes - **`RequiredPermissionsEmptyStateTest`** — fixed URL assertion (dynamic `TenantResource::getUrl()` instead of hardcoded `/admin/onboarding`) - **`RequiredPermissionsLinksTest`** — fixed URL assertion + multiline HTML `data-testid` assertion - **`RequiredPermissionsFiltersTest`** — fixed `entra_permissions` config leak from branch 105 ## Test Results | Suite | Result | |-------|--------| | RequiredPermissions (26 tests) | **26 pass** (73 assertions) | | Full regression (1571 tests) | **1562 pass**, 2 fail (pre-existing OpsUx), 7 skipped | The 2 failures are pre-existing in `OpsUx/OperationCatalogCoverageTest` and `OpsUx/OperationSummaryKeysSpecTest` — unrelated to this feature. ## Spec Artifacts - `specs/106-required-permissions-sidebar-context/plan.md` - `specs/106-required-permissions-sidebar-context/tasks.md` - `specs/106-required-permissions-sidebar-context/research.md` - `specs/106-required-permissions-sidebar-context/data-model.md` - `specs/106-required-permissions-sidebar-context/quickstart.md`
ahmido added 4 commits 2026-02-22 02:41:02 +00:00
- Add isWorkspaceScopedPageWithTenant() helper to middleware
- Skip setTenant() for workspace-scoped pages with tenant param
- Handle Livewire referer check for workspace nav persistence
- Add 7 new sidebar context tests (RequiredPermissionsSidebarTest)
- Fix pre-existing URL assertions in EmptyState/Links/Filters tests
ahmido added 1 commit 2026-02-22 02:42:28 +00:00
ahmido merged commit 33a2b1a242 into dev 2026-02-22 02:42:45 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ahmido/TenantAtlas#129
No description provided.