TenantAtlas/apps/platform/app/Filament/Widgets/Dashboard/EnvironmentDashboardOverview.php
ahmido 9a564d6bf2 feat: environment dashboard operator guidance consolidation (spec 352) (#423)
Implemented the consolidated operator guidance panel for the environment dashboard. Updated EnvironmentDashboardSummaryBuilder to prioritize and select guidance based on the operator guidance contract. Added comprehensive unit, feature, and browser tests to verify the guidance selection logic and UI rendering.

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #423
2026-06-04 12:56:02 +00:00

98 lines
4.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Widgets\Dashboard;
use App\Models\ManagedEnvironment;
use App\Support\EnvironmentDashboard\EnvironmentDashboardSummaryBuilder;
use Filament\Facades\Filament;
use Filament\Widgets\Widget;
class EnvironmentDashboardOverview extends Widget
{
protected static bool $isLazy = false;
protected int|string|array $columnSpan = 'full';
protected string $view = 'filament.widgets.dashboard.environment-dashboard-overview';
/**
* @return array<string, mixed>
*/
protected function getViewData(): array
{
$tenant = Filament::getTenant();
if (! $tenant instanceof ManagedEnvironment) {
return [
'context' => [
'workspace' => __('localization.dashboard.overview.context_workspace'),
'tenant' => __('localization.dashboard.overview.context_no_tenant'),
'provider' => null,
'providerKey' => null,
'latestActivity' => null,
],
'posture' => [
'status' => __('localization.dashboard.overview.status_unavailable'),
'tone' => 'gray',
'headline' => __('localization.dashboard.overview.tenant_context_unavailable_headline'),
'summary' => __('localization.dashboard.overview.tenant_context_unavailable_summary'),
],
'operatorGuidance' => [
'key' => 'environment.no_context',
'title' => __('localization.dashboard.overview.environment_context_unavailable_headline'),
'status' => __('localization.dashboard.overview.status_unavailable'),
'tone' => 'gray',
'reason' => __('localization.dashboard.overview.tenant_context_unavailable_headline'),
'impact' => __('localization.dashboard.overview.tenant_context_unavailable_summary'),
'actionLabel' => __('localization.dashboard.overview.action_review_environment'),
'actionUrl' => null,
'actionDisabled' => true,
'helperText' => __('localization.dashboard.overview.operator_guidance_unavailable_helper'),
'secondaryActions' => [],
'source' => ['type' => 'environment_context'],
],
'readinessDecision' => [
'question' => 'Is this environment ready, blocked, stale, or requiring review?',
'title' => __('localization.dashboard.overview.environment_context_unavailable_headline'),
'statusLabel' => 'Status',
'status' => __('localization.dashboard.overview.status_unavailable'),
'tone' => 'gray',
'reasonLabel' => 'Reason',
'reason' => __('localization.dashboard.overview.tenant_context_unavailable_headline'),
'impactLabel' => __('localization.dashboard.overview.label_why_this_matters'),
'impact' => __('localization.dashboard.overview.tenant_context_unavailable_summary'),
'proofLabel' => 'Readiness proof',
'proof' => 'Evidence, operation, review, provider, backup, and baseline signals are summarized before diagnostics.',
'nextActionLabel' => __('localization.dashboard.overview.label_recommended_next_action'),
'actionLabel' => __('localization.dashboard.overview.action_review_environment'),
'actionUrl' => null,
'actionDisabled' => true,
'helperText' => __('localization.dashboard.overview.operator_guidance_unavailable_helper'),
'secondaryActions' => [],
],
'kpis' => [],
'recommendedActions' => [],
'governanceStatus' => [],
'readinessCards' => [],
'readinessDimensions' => [],
'readinessProofPanel' => [],
'supportingSignals' => [],
'diagnosticsDisclosure' => [
'label' => 'Diagnostics - Collapsed',
'summary' => 'Support diagnostics stay closed by default and require the existing diagnostics capability.',
'tone' => 'gray',
],
'activeOperationSummary' => null,
'recentOperations' => [],
'pollingInterval' => null,
];
}
return app(EnvironmentDashboardSummaryBuilder::class)
->build($tenant)
->toArray();
}
}