fix: consolidate tenant creation + harden selection flows #131

Merged
ahmido merged 12 commits from 107-workspace-chooser into dev 2026-02-22 19:54:26 +00:00
Owner

Summary

  • Removes the legacy Tenant CRUD create page (/admin/tenants/create) so tenant creation is handled exclusively via the onboarding wizard.
  • Updates tenant selection flows and pages to prevent Livewire polling/notification-related 404s on workspace-scoped routes.
  • Aligns empty-state UX with enterprise patterns (avoid duplicate CTAs).

Key changes

  • Tenant creation
    • Removed CreateTenant page + route from TenantResource.
    • TenantResource::canCreate() now returns false (CRUD creation disabled).
    • Tenants list now surfaces an Add tenant action that links to onboarding (admin.onboarding).
  • Onboarding wizard
    • Removed redundant legacy step-cards from the blade view (Wizard schema is the source of truth).
    • Disabled topbar on the onboarding page to avoid lazy-loaded notifications.
  • Choose tenant
    • Enterprise UI redesign + workspace context.
    • Uses Livewire selectTenant() instead of a form POST.
    • Disabled topbar and gated BODY_END hook to avoid background polling.
  • Baseline profiles
    • Hide header create action when table is empty to avoid duplicate CTAs.

Tests

  • vendor/bin/sail artisan test --compact --filter='Onboarding|ManagedTenantOnboarding'
  • vendor/bin/sail artisan test --compact --filter='ManagedTenantsLivewireUpdate'
  • vendor/bin/sail artisan test --compact --filter='TenantSetup|TenantResourceAuth|TenantAdminAuth|ListTenants'
  • vendor/bin/sail artisan test --compact --filter='BaselineProfile'
  • vendor/bin/sail artisan test --compact --filter='ChooseTenant|TenantMake|TenantScoping|AdminTenantScoped|AdminHomeRedirect|WorkspaceContext'

Notes

  • Filament v5 / Livewire v4 compatible.
  • No new assets introduced; no deploy pipeline changes required.
## Summary - Removes the legacy Tenant CRUD create page (`/admin/tenants/create`) so tenant creation is handled exclusively via the onboarding wizard. - Updates tenant selection flows and pages to prevent Livewire polling/notification-related 404s on workspace-scoped routes. - Aligns empty-state UX with enterprise patterns (avoid duplicate CTAs). ## Key changes - Tenant creation - Removed `CreateTenant` page + route from `TenantResource`. - `TenantResource::canCreate()` now returns `false` (CRUD creation disabled). - Tenants list now surfaces an **Add tenant** action that links to onboarding (`admin.onboarding`). - Onboarding wizard - Removed redundant legacy step-cards from the blade view (Wizard schema is the source of truth). - Disabled topbar on the onboarding page to avoid lazy-loaded notifications. - Choose tenant - Enterprise UI redesign + workspace context. - Uses Livewire `selectTenant()` instead of a form POST. - Disabled topbar and gated BODY_END hook to avoid background polling. - Baseline profiles - Hide header create action when table is empty to avoid duplicate CTAs. ## Tests - `vendor/bin/sail artisan test --compact --filter='Onboarding|ManagedTenantOnboarding'` - `vendor/bin/sail artisan test --compact --filter='ManagedTenantsLivewireUpdate'` - `vendor/bin/sail artisan test --compact --filter='TenantSetup|TenantResourceAuth|TenantAdminAuth|ListTenants'` - `vendor/bin/sail artisan test --compact --filter='BaselineProfile'` - `vendor/bin/sail artisan test --compact --filter='ChooseTenant|TenantMake|TenantScoping|AdminTenantScoped|AdminHomeRedirect|WorkspaceContext'` ## Notes - Filament v5 / Livewire v4 compatible. - No new assets introduced; no deploy pipeline changes required.
ahmido added 12 commits 2026-02-22 19:53:43 +00:00
F1: Replace 'EnsureActiveWorkspace' with 'EnsureWorkspaceSelected' in spec (3 occurrences) — aligns with R1 decision
F2: Add audit logging to SwitchWorkspaceController (T036) + context_bar reason — closes FR-005 gap
F3: Remove stale WorkspaceContext.php MODIFY from plan project structure
F4/F5: Add WorkspaceRedirectResolver.php + 2 missing test files to plan project structure
F6: Add single-workspace sub-case (EC3) note to T030
F7: Add archived workspace scenario (EC2) note to T024
Spec 107: Workspace Chooser v1 (Enterprise) + In-App Switch Entry Point

## Core changes
- Refactor EnsureWorkspaceSelected middleware: 7-step algorithm with
  auto-resume (single membership + last_workspace_id), stale session
  detection, ?choose=1 forced chooser, workspace-optional path bypass
- Create WorkspaceRedirectResolver for DRY tenant-count branching
  (0→managed-tenants, 1→tenant-dashboard, >1→choose-tenant)
- Add WorkspaceAutoSelected + WorkspaceSelected audit enum cases
- Rewrite ChooseWorkspace page: role badges, tenant counts,
  wire:click selection, audit logging, WorkspaceRedirectResolver
- Add 'Switch workspace' user menu item in AdminPanelProvider
- Rewrite SwitchWorkspaceController with audit + resolver
- Replace inline tenant branching in routes/web.php with resolver

## New test files (6)
- WorkspaceRedirectResolverTest (5 tests
Spec 107: Workspace Chooser v1 (Enterprise) + In-App Switch Entry Point

## Core changes
- Refactor EnsureWorkspaceSelected middleware: 7-step algorithmst
## Core changes
- Refactor EnsureWorkspaceSelected middleware: 7-stepes - Refactor Ensng  auto-resume (single membership + last_workspace_id), stale sessioid  detection, ?choose=1 forced chooser, w (security invariant preserve- Create WorkspaceRedirectResolver for DRY tenant-count branching

  (0→managed-tenants, 1→tenant-dashboapped (8163 assertions)
- Replace flat div cards with semantic <button> elements
- Add workspace icon (building-office-2) per card
- Add role-specific icons (shield, cog, wrench, eye)
- Use primary color scheme for 'Last used' highlight (was amber)
- Add loading spinner overlay on workspace selection
- Add hover arrow indicator + shadow elevation on hover
- Add focus ring for keyboard accessibility
- Better empty state with icon + actionable copy
- Proper dark mode support throughout
- Responsive grid (1→2→3 columns)
- Manage workspaces link with cog icon
The full panel layout renders DatabaseNotifications (lazy-loaded) and
BulkOperationProgress (polling), whose Livewire update requests fail
with 404 due to persistent middleware route-binding issues on this
manually-routed page.

Switch to simple layout matching ChooseWorkspace/ChooseTenant/NoAccess
pattern — appropriate for this transitional/landing page.

Add test verifying Livewire updates succeed on managed-tenants page.
ahmido merged commit e15eee8f26 into dev 2026-02-22 19:54:26 +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#131
No description provided.