## Summary - enforce the canonical workspace/environment scope contract for workspace hubs and environment-owned surfaces - replace first-party Operations deep links that leaked Filament `tableFilters[...]` internals with stable product-level query behavior - add the sidebar scope indicator and split environment-page navigation into explicit `Workspace-wide` and `Workspace admin` groups - remove redundant tenantless `All environments` scope badges from workspace-wide pages while preserving explicit environment filter affordances - include the Spec 338 artifacts, guard tests, and browser smoke coverage for the new contract ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Navigation/Spec338EnvironmentSidebarSeparationTest.php tests/Feature/Navigation/Spec338OperationRunLinksQueryContractTest.php tests/Feature/Navigation/Spec338SidebarScopeIndicatorTest.php tests/Feature/Filament/PanelNavigationSegregationTest.php` - `cd apps/platform && ./vendor/bin/sail php vendor/bin/pest tests/Browser/Spec338ScopeContractSmokeTest.php --compact` ## Notes - Livewire v4 compliance unchanged - Filament provider registration remains in `bootstrap/providers.php` - no destructive action behavior changed - no migrations, env var changes, or new Filament asset registration Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #409
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Navigation;
|
|
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
|
|
final class WorkspaceHubNavigation
|
|
{
|
|
public static function workspaceWideGroup(string $fallbackGroup): string
|
|
{
|
|
return NavigationScope::isEnvironmentSurface()
|
|
? __('localization.navigation.workspace_wide')
|
|
: $fallbackGroup;
|
|
}
|
|
|
|
public static function workspaceAdminGroup(): string
|
|
{
|
|
return NavigationScope::isEnvironmentSurface()
|
|
? __('localization.navigation.workspace_admin')
|
|
: __('localization.navigation.settings');
|
|
}
|
|
|
|
public static function environmentFilteredUrl(string $url): string
|
|
{
|
|
$url = WorkspaceHubRegistry::cleanUrl($url);
|
|
|
|
$environment = self::environmentContext();
|
|
|
|
if (! $environment instanceof ManagedEnvironment) {
|
|
return $url;
|
|
}
|
|
|
|
return url()->query($url, [
|
|
'environment_id' => (int) $environment->getKey(),
|
|
]);
|
|
}
|
|
|
|
public static function cleanUrl(string $url): string
|
|
{
|
|
return WorkspaceHubRegistry::cleanUrl($url);
|
|
}
|
|
|
|
public static function environmentContext(): ?ManagedEnvironment
|
|
{
|
|
if (! NavigationScope::isEnvironmentSurface()) {
|
|
return null;
|
|
}
|
|
|
|
$tenant = Filament::getTenant();
|
|
|
|
if ($tenant instanceof ManagedEnvironment) {
|
|
return $tenant;
|
|
}
|
|
|
|
return app(WorkspaceContext::class)->rememberedEnvironment(request());
|
|
}
|
|
}
|