## Summary - add a shared baseline compare summary assessment and assessor for compact trust propagation - harden dashboard, landing, and banner baseline compare surfaces against false all-clear claims - add focused Pest coverage for dashboard, landing, banner, reason translation, and canonical detail parity ## Validation - vendor/bin/sail bin pint --dirty --format agent - vendor/bin/sail artisan test --compact tests/Feature/Baselines/BaselineCompareSummaryAssessmentTest.php tests/Feature/Baselines/BaselineCompareExplanationFallbackTest.php tests/Feature/Filament/BaselineCompareNowWidgetTest.php tests/Feature/Filament/NeedsAttentionWidgetTest.php tests/Feature/Filament/BaselineCompareExplanationSurfaceTest.php tests/Feature/Filament/BaselineCompareLandingWhyNoFindingsTest.php tests/Feature/Filament/BaselineCompareCoverageBannerTest.php tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.php tests/Feature/Filament/OperationRunBaselineTruthSurfaceTest.php tests/Feature/ReasonTranslation/ReasonTranslationExplanationTest.php ## Notes - Livewire compliance: Filament v5 / Livewire v4 stack unchanged - Provider registration: unchanged, Laravel 12 providers remain in bootstrap/providers.php - Global search: no searchable resource behavior changed - Destructive actions: none introduced by this change - Assets: no new assets registered; existing deploy process remains unchanged Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #196
60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Widgets\Tenant;
|
|
|
|
use App\Filament\Pages\BaselineCompareLanding;
|
|
use App\Models\Tenant;
|
|
use App\Support\Baselines\BaselineCompareStats;
|
|
use App\Support\OperationRunLinks;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Widgets\Widget;
|
|
|
|
class BaselineCompareCoverageBanner extends Widget
|
|
{
|
|
protected static bool $isLazy = false;
|
|
|
|
protected string $view = 'filament.widgets.tenant.baseline-compare-coverage-banner';
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
protected function getViewData(): array
|
|
{
|
|
$tenant = Filament::getTenant();
|
|
|
|
if (! $tenant instanceof Tenant) {
|
|
return [
|
|
'shouldShow' => false,
|
|
];
|
|
}
|
|
|
|
$stats = BaselineCompareStats::forTenant($tenant);
|
|
$summaryAssessment = $stats->summaryAssessment();
|
|
$runUrl = null;
|
|
|
|
if ($stats->operationRunId !== null) {
|
|
$runUrl = OperationRunLinks::view($stats->operationRunId, $tenant);
|
|
}
|
|
|
|
$landingUrl = BaselineCompareLanding::getUrl(tenant: $tenant);
|
|
$nextActionUrl = match ($summaryAssessment->nextActionTarget()) {
|
|
'run' => $runUrl,
|
|
'landing' => $landingUrl,
|
|
default => null,
|
|
};
|
|
$shouldShow = in_array($summaryAssessment->stateFamily, ['caution', 'stale', 'unavailable', 'in_progress'], true)
|
|
|| ($summaryAssessment->stateFamily === 'action_required' && $summaryAssessment->evaluationResult === 'failed_result');
|
|
|
|
return [
|
|
'shouldShow' => $shouldShow,
|
|
'landingUrl' => $landingUrl,
|
|
'runUrl' => $runUrl,
|
|
'nextActionUrl' => $nextActionUrl,
|
|
'summaryAssessment' => $summaryAssessment->toArray(),
|
|
'state' => $stats->state,
|
|
];
|
|
}
|
|
}
|