## Summary - complete Spec 136 canonical admin tenant rollout across admin-visible and shared Filament surfaces - add the shared panel-aware tenant resolver helper, persisted filter-state synchronization, and admin navigation segregation for tenant-sensitive resources - expand regression, guard, and parity coverage for admin-path tenant resolution, stale filters, workspace-wide tenant-default surfaces, and panel split behavior ## Validation - `vendor/bin/sail artisan test --compact tests/Feature/Guards/AdminTenantResolverGuardTest.php` - `vendor/bin/sail artisan test --compact tests/Feature/Filament/TableStatePersistenceTest.php` - `vendor/bin/sail artisan test --compact --filter='CanonicalAdminTenantFilterState|PolicyResource|BackupSchedule|BackupSet|FindingResource|BaselineCompareLanding|RestoreRunResource|InventoryItemResource|PolicyVersionResource|ProviderConnectionResource|TenantDiagnostics|InventoryCoverage|InventoryKpiHeader|AuditLog|EntraGroup'` - `vendor/bin/sail bin pint --dirty --format agent` ## Notes - Livewire v4.0+ compliance is preserved with Filament v5. - Provider registration remains unchanged in `bootstrap/providers.php`. - `PolicyResource` and `PolicyVersionResource` have admin global search disabled explicitly; `EntraGroupResource` keeps admin-aware scoped search with a View page. - Destructive and governance-sensitive actions retain existing confirmation and authorization behavior while using canonical tenant parity. - No new assets were introduced, so deployment asset strategy is unchanged and does not add new `filament:assets` work. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #165
92 lines
3.7 KiB
PHP
92 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
function adminTenantResolverGuardedFiles(): array
|
|
{
|
|
return [
|
|
'app/Filament/Pages/BaselineCompareLanding.php',
|
|
'app/Filament/Pages/TenantDiagnostics.php',
|
|
'app/Filament/Pages/InventoryCoverage.php',
|
|
'app/Filament/Widgets/Inventory/InventoryKpiHeader.php',
|
|
'app/Filament/Pages/Monitoring/Operations.php',
|
|
'app/Filament/Pages/Operations/TenantlessOperationRunViewer.php',
|
|
'app/Filament/Widgets/Operations/OperationsKpiHeader.php',
|
|
'app/Filament/Resources/OperationRunResource.php',
|
|
'app/Filament/Resources/PolicyResource.php',
|
|
'app/Filament/Resources/BackupScheduleResource.php',
|
|
'app/Filament/Resources/BackupScheduleResource/Pages/ListBackupSchedules.php',
|
|
'app/Filament/Resources/BackupSetResource.php',
|
|
'app/Filament/Resources/BackupSetResource/Pages/ListBackupSets.php',
|
|
'app/Filament/Resources/BackupSetResource/Pages/ViewBackupSet.php',
|
|
'app/Filament/Resources/FindingResource.php',
|
|
'app/Filament/Resources/FindingResource/Pages/ListFindings.php',
|
|
'app/Filament/Resources/InventoryItemResource.php',
|
|
'app/Filament/Resources/InventoryItemResource/Pages/ListInventoryItems.php',
|
|
'app/Filament/Resources/PolicyVersionResource.php',
|
|
'app/Filament/Resources/PolicyVersionResource/Pages/ListPolicyVersions.php',
|
|
'app/Filament/Resources/ProviderConnectionResource.php',
|
|
'app/Filament/Resources/AlertDeliveryResource.php',
|
|
'app/Filament/Resources/AlertDeliveryResource/Pages/ListAlertDeliveries.php',
|
|
'app/Filament/Pages/Monitoring/AuditLog.php',
|
|
'app/Filament/Resources/ProviderConnectionResource/Pages/ListProviderConnections.php',
|
|
'app/Filament/Resources/RestoreRunResource.php',
|
|
'app/Filament/Resources/RestoreRunResource/Pages/CreateRestoreRun.php',
|
|
];
|
|
}
|
|
|
|
function adminTenantResolverExceptionFiles(): array
|
|
{
|
|
return [
|
|
'app/Filament/Pages/ChooseTenant.php',
|
|
'app/Http/Controllers/SelectTenantController.php',
|
|
'app/Support/Middleware/EnsureFilamentTenantSelected.php',
|
|
'app/Filament/Resources/EntraGroupResource.php',
|
|
'app/Filament/Concerns/ResolvesPanelTenantContext.php',
|
|
];
|
|
}
|
|
|
|
it('keeps raw panel-native tenant reads out of canonical admin resolver surfaces', function (): void {
|
|
$forbiddenPatterns = [
|
|
'/\bFilament::getTenant\s*\(/',
|
|
'/\bTenant::current\s*\(/',
|
|
];
|
|
|
|
$violations = [];
|
|
|
|
foreach (adminTenantResolverGuardedFiles() as $relativePath) {
|
|
$contents = file_get_contents(base_path($relativePath));
|
|
|
|
expect($contents)->not->toBeFalse();
|
|
|
|
foreach ($forbiddenPatterns as $pattern) {
|
|
if (preg_match($pattern, (string) $contents) === 1) {
|
|
$violations[] = $relativePath;
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
expect($violations)
|
|
->toBeEmpty('Canonical admin surfaces must delegate tenant resolution to OperateHubShell. Offenders: '.implode(', ', $violations));
|
|
});
|
|
|
|
it('documents the approved panel-native exception inventory', function (): void {
|
|
$notes = file_get_contents(base_path('docs/research/admin-canonical-tenant-rollout.md'));
|
|
|
|
expect($notes)->not->toBeFalse();
|
|
|
|
foreach (adminTenantResolverExceptionFiles() as $relativePath) {
|
|
expect($notes)->toContain($relativePath);
|
|
}
|
|
});
|
|
|
|
it('keeps the mixed-surface entra group resource explicit about admin and tenant-panel resolution', function (): void {
|
|
$contents = file_get_contents(base_path('app/Filament/Resources/EntraGroupResource.php'));
|
|
|
|
expect($contents)->not->toBeFalse()
|
|
->and($contents)->toContain('activeEntitledTenant(request())')
|
|
->and($contents)->toContain('Tenant::current()');
|
|
});
|