TenantAtlas/apps/platform/app/Support/Navigation/WorkspaceHubNavigation.php
ahmido e324bd7bd6 feat: canonicalize admin scope links and queries (341) (#413)
## Summary
- remove remaining legacy scope query hint parsing from shared workspace and environment scoping seams so hubs only narrow via explicit `environment_id`
- align canonical link generation across workspace hubs, provider connections, audit log, alerts, and decision register flows
- add focused Spec 341 regression coverage for canonical link/query behavior and legacy alias rejection
- include the Spec 341 artifacts and move the review screenshots into `specs/341-canonical-link-query-cleanup/artifacts/screenshots/`
- ignore local `.playwright-mcp` browser tool output so it does not pollute future commits or pull requests

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Navigation --filter=Spec341`
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Navigation/Spec341CanonicalLinkQueryCleanupTest.php tests/Feature/Navigation/WorkspaceHubEnvironmentFilterContractTest.php tests/Feature/ProviderConnections/ProviderConnectionsWorkspaceHubContractTest.php`
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`
- `git diff --check`

## Notes
- Livewire v4 compliance unchanged
- Filament provider registration remains in `apps/platform/bootstrap/providers.php`
- no globally searchable resource behavior was changed in this slice
- no destructive action behavior was changed
- no new Filament assets; deploy `filament:assets` posture is unchanged

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #413
2026-05-31 22:46:39 +00:00

69 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Navigation;
use App\Models\ManagedEnvironment;
use App\Support\OperateHub\OperateHubShell;
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;
}
$resolved = app(OperateHubShell::class)->resolvedContext(request());
if ($resolved->tenant instanceof ManagedEnvironment) {
return $resolved->tenant;
}
$tenant = Filament::getTenant();
if ($tenant instanceof ManagedEnvironment) {
return $tenant;
}
return app(WorkspaceContext::class)->rememberedEnvironment(request());
}
}