*/ protected function getViewData(): array { $tenant = Filament::getTenant(); if (! $tenant instanceof Tenant) { return [ 'pollingInterval' => null, 'items' => [], 'healthyChecks' => [], ]; } $tenantId = (int) $tenant->getKey(); $compareStats = BaselineCompareStats::forTenant($tenant); $compareAssessment = $compareStats->summaryAssessment(); $items = []; $highSeverityCount = (int) Finding::query() ->where('tenant_id', $tenantId) ->where('finding_type', Finding::FINDING_TYPE_DRIFT) ->where('status', Finding::STATUS_NEW) ->where('severity', Finding::SEVERITY_HIGH) ->count(); if ($highSeverityCount > 0) { $items[] = [ 'title' => 'High severity drift findings', 'body' => "{$highSeverityCount} finding(s) need review.", 'badge' => 'Drift', 'badgeColor' => 'danger', ]; } if ($compareAssessment->stateFamily !== 'positive') { $items[] = [ 'title' => 'Baseline compare posture', 'body' => $compareAssessment->headline, 'supportingMessage' => $compareAssessment->supportingMessage, 'badge' => 'Baseline', 'badgeColor' => $compareAssessment->tone, 'nextStep' => $compareAssessment->nextActionLabel(), ]; } $activeRuns = ActiveRuns::existForTenant($tenant) ? (int) \App\Models\OperationRun::query()->where('tenant_id', $tenantId)->active()->count() : 0; if ($activeRuns > 0) { $items[] = [ 'title' => 'Operations in progress', 'body' => "{$activeRuns} run(s) are active.", 'badge' => 'Operations', 'badgeColor' => 'warning', ]; } $items = array_slice($items, 0, 5); $healthyChecks = []; if ($items === []) { $healthyChecks = [ [ 'title' => 'Baseline compare looks trustworthy', 'body' => $compareAssessment->headline, ], [ 'title' => 'No high severity drift is open', 'body' => 'No high severity drift findings are currently open for this tenant.', ], [ 'title' => 'No active operations', 'body' => 'Nothing is currently running for this tenant.', ], ]; } return [ 'pollingInterval' => ActiveRuns::existForTenant($tenant) ? '10s' : null, 'items' => $items, 'healthyChecks' => $healthyChecks, ]; } }