## Summary - introduce a shared operator outcome taxonomy with semantic axes, severity bands, and next-action policy - apply the taxonomy to operations, evidence/review completeness, baseline semantics, and restore semantics - harden badge rendering, tenant-safe filtering/search behavior, and operator-facing summary/notification wording - add the spec kit artifacts, reference documentation, and regression coverage for diagnostic-vs-primary state handling ## Testing - focused Pest coverage for taxonomy registry and badge guardrails - operations presentation and notification tests - evidence, baseline, restore, and tenant-scope regression tests ## Notes - Livewire v4.0+ compliance is preserved in the existing Filament v5 stack - panel provider registration remains unchanged in bootstrap/providers.php - no new globally searchable resource was added; adopted resources remain tenant-safe and out of global search where required - no new destructive action family was introduced; existing actions keep their current authorization and confirmation behavior - no new frontend asset strategy was introduced; existing deploy flow with filament:assets remains unchanged Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #186
128 lines
7.1 KiB
PHP
128 lines
7.1 KiB
PHP
@php
|
|
$preview = $getState() ?? [];
|
|
$actionPresentation = static function (array $item): array {
|
|
$action = is_string($item['action'] ?? null) ? $item['action'] : null;
|
|
|
|
return match ($action) {
|
|
'create' => ['label' => 'Will create', 'color' => 'success'],
|
|
'update' => ['label' => 'Will update existing', 'color' => 'info'],
|
|
default => ['label' => \Illuminate\Support\Str::headline((string) ($action ?? 'action')), 'color' => 'gray'],
|
|
};
|
|
};
|
|
$foundationItems = collect($preview)->filter(function ($item) {
|
|
return is_array($item) && array_key_exists('decision', $item) && array_key_exists('sourceId', $item);
|
|
});
|
|
$policyItems = collect($preview)->reject(function ($item) {
|
|
return is_array($item) && array_key_exists('decision', $item) && array_key_exists('sourceId', $item);
|
|
});
|
|
@endphp
|
|
|
|
@if (empty($preview))
|
|
<p class="text-sm text-gray-600">No preview has been generated yet.</p>
|
|
@else
|
|
<div class="space-y-4">
|
|
@if ($foundationItems->isNotEmpty())
|
|
<div class="space-y-2">
|
|
<div class="text-xs font-semibold uppercase tracking-wide text-gray-500">Foundations</div>
|
|
@foreach ($foundationItems as $item)
|
|
@php
|
|
$decision = $item['decision'] ?? 'mapped_existing';
|
|
$decisionSpec = \App\Support\Badges\BadgeRenderer::spec(\App\Support\Badges\BadgeDomain::RestorePreviewDecision, $decision);
|
|
@endphp
|
|
<div class="rounded border border-gray-200 bg-white p-3 shadow-sm">
|
|
<div class="flex items-center justify-between text-sm text-gray-800">
|
|
<span class="font-semibold">{{ $item['sourceName'] ?? $item['sourceId'] ?? 'Foundation' }}</span>
|
|
<x-filament::badge :color="$decisionSpec->color" :icon="$decisionSpec->icon" size="sm">
|
|
{{ $decisionSpec->label }}
|
|
</x-filament::badge>
|
|
</div>
|
|
<div class="mt-1 text-xs text-gray-600">
|
|
{{ $item['type'] ?? 'foundation' }}
|
|
</div>
|
|
@if (! empty($item['targetName']))
|
|
<div class="mt-1 text-xs text-gray-600">
|
|
Target: {{ $item['targetName'] }}
|
|
</div>
|
|
@endif
|
|
@if (! empty($item['reason']))
|
|
<div class="mt-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800">
|
|
{{ $item['reason'] }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
|
|
@if ($policyItems->isNotEmpty())
|
|
<div class="space-y-2">
|
|
<div class="text-xs font-semibold uppercase tracking-wide text-gray-500">Policies</div>
|
|
@foreach ($policyItems as $item)
|
|
@php
|
|
$restoreMode = $item['restore_mode'] ?? null;
|
|
$actionState = $actionPresentation(is_array($item) ? $item : []);
|
|
@endphp
|
|
<div class="rounded border border-gray-200 bg-white p-3 shadow-sm">
|
|
<div class="flex items-center justify-between text-sm text-gray-800">
|
|
<span class="font-semibold">{{ $item['policy_identifier'] ?? 'Policy' }}</span>
|
|
<div class="flex items-center gap-2">
|
|
@if ($restoreMode === 'preview-only')
|
|
@php
|
|
$restoreModeSpec = \App\Support\Badges\BadgeRenderer::spec(\App\Support\Badges\BadgeDomain::PolicyRestoreMode, $restoreMode);
|
|
@endphp
|
|
<x-filament::badge :color="$restoreModeSpec->color" :icon="$restoreModeSpec->icon" size="sm">
|
|
{{ $restoreModeSpec->label }}
|
|
</x-filament::badge>
|
|
@endif
|
|
<span class="rounded bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-700">
|
|
{{ $actionState['label'] }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="mt-1 text-xs text-gray-600">
|
|
{{ $item['policy_type'] ?? 'type' }} • {{ $item['platform'] ?? 'platform' }}
|
|
</div>
|
|
|
|
@if (! empty($item['validation_warning']))
|
|
<div class="mt-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800">
|
|
{{ $item['validation_warning'] }}
|
|
</div>
|
|
@endif
|
|
|
|
@if (! empty($item['compliance_action_warning']))
|
|
<div class="mt-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800">
|
|
{{ $item['compliance_action_warning'] }}
|
|
</div>
|
|
@endif
|
|
@if (! empty($item['compliance_action_summary']) && is_array($item['compliance_action_summary']))
|
|
@php
|
|
$summary = $item['compliance_action_summary'];
|
|
$missingTemplates = $item['compliance_action_missing_templates'] ?? [];
|
|
$total = (int) ($summary['total'] ?? 0);
|
|
$missing = (int) ($summary['missing'] ?? 0);
|
|
@endphp
|
|
|
|
<div class="mt-2 text-xs text-gray-600">
|
|
Compliance notifications: {{ $total }} total • {{ $missing }} missing
|
|
</div>
|
|
|
|
@if (! empty($missingTemplates) && is_array($missingTemplates))
|
|
<details class="mt-2 rounded border border-amber-200 bg-amber-50 px-2 py-1 text-xs text-amber-900">
|
|
<summary class="cursor-pointer font-semibold">Missing notification templates</summary>
|
|
<div class="mt-2 space-y-1">
|
|
@foreach ($missingTemplates as $templateId)
|
|
<div class="rounded border border-amber-200 bg-white px-2 py-1 text-[11px] text-gray-800">
|
|
{{ $templateId }}
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</details>
|
|
@endif
|
|
@endif
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endif
|