## Summary - retire the tenant panel runtime and converge operator routing on the workspace-first admin shell - update tenant, operations, and required-permissions navigation helpers to use canonical workspace-scoped URLs - repair the focused feature coverage, add the Spec 280 browser smoke, and record the implementation close-out in the requirements checklist ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/WorkspaceFoundation tests/Feature/Workspaces tests/Feature/ManagedEnvironment tests/Feature/RequiredPermissions tests/Feature/Operations tests/Feature/MonitoringOperationsTest.php` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Spec280WorkspaceTenancyEnvironmentRoutingSmokeTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Note - `origin/platform` is not present on the remote; `platform-dev` is the clean base branch that limits this PR to the Spec 280 prep commit plus the implementation commit. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #340
67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\Tenants\TenantPageCategory;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
final class ClearTenantContextController
|
|
{
|
|
public function __invoke(Request $request): RedirectResponse
|
|
{
|
|
Filament::setTenant(null, true);
|
|
|
|
$workspaceContext = app(WorkspaceContext::class);
|
|
|
|
$workspaceContext->clearRememberedTenantContext($request);
|
|
|
|
$previousUrl = url()->previous();
|
|
|
|
$previousHost = parse_url((string) $previousUrl, PHP_URL_HOST);
|
|
$previousPath = (string) (parse_url((string) $previousUrl, PHP_URL_PATH) ?? '');
|
|
|
|
if ($previousHost !== null && $previousHost !== $request->getHost()) {
|
|
return redirect()->to(OperationRunLinks::index());
|
|
}
|
|
|
|
if ($this->isTenantScopedEvidencePath($previousPath)) {
|
|
return redirect()->route('admin.evidence.overview');
|
|
}
|
|
|
|
if (TenantPageCategory::fromPath($previousPath) === TenantPageCategory::TenantBound) {
|
|
$workspace = $workspaceContext->currentWorkspace($request);
|
|
|
|
if ($workspace !== null) {
|
|
return redirect()->route('admin.workspace.managed-tenants.index', ['workspace' => $workspace]);
|
|
}
|
|
|
|
return redirect()->route('admin.home');
|
|
}
|
|
|
|
if ($previousPath === '' || $previousPath === '/admin/clear-tenant-context') {
|
|
return redirect()->to(OperationRunLinks::index());
|
|
}
|
|
|
|
return redirect()->to((string) $previousUrl);
|
|
}
|
|
|
|
private function isTenantScopedEvidencePath(string $previousPath): bool
|
|
{
|
|
if ($previousPath === '/admin/evidence') {
|
|
return true;
|
|
}
|
|
|
|
if (! str_starts_with($previousPath, '/admin/evidence/')) {
|
|
return false;
|
|
}
|
|
|
|
return ! str_starts_with($previousPath, '/admin/evidence/overview');
|
|
}
|
|
}
|