fix: surface compliance mapping in restore UI

This commit is contained in:
Ahmed Darrazi 2025-12-28 16:23:33 +01:00
parent a985bff287
commit 426a59e00b
4 changed files with 50 additions and 10 deletions

View File

@ -88,6 +88,32 @@
{{ $item['compliance_action_warning'] }} {{ $item['compliance_action_warning'] }}
</div> </div>
@endif @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> </div>
@endforeach @endforeach
</div> </div>

View File

@ -192,10 +192,10 @@
@if (! empty($item['compliance_action_summary']) && is_array($item['compliance_action_summary'])) @if (! empty($item['compliance_action_summary']) && is_array($item['compliance_action_summary']))
@php @php
$summary = $item['compliance_action_summary']; $summary = $item['compliance_action_summary'];
$complianceOutcomes = $item['compliance_action_outcomes'] ?? []; $complianceOutcomes = is_array($item['compliance_action_outcomes'] ?? null)
$complianceIssues = collect($complianceOutcomes) ? $item['compliance_action_outcomes']
->filter(fn ($outcome) => ($outcome['status'] ?? null) === 'skipped') : [];
->values(); $complianceEntries = collect($complianceOutcomes)->values();
@endphp @endphp
<div class="mt-2 text-xs text-gray-700"> <div class="mt-2 text-xs text-gray-700">
@ -203,18 +203,26 @@
{{ (int) ($summary['skipped'] ?? 0) }} skipped {{ (int) ($summary['skipped'] ?? 0) }} skipped
</div> </div>
@if ($complianceIssues->isNotEmpty()) @if ($complianceEntries->isNotEmpty())
<details class="mt-2 rounded border border-amber-200 bg-amber-50 px-2 py-1 text-xs text-amber-900"> <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">Compliance notification details</summary> <summary class="cursor-pointer font-semibold">Compliance notification details</summary>
<div class="mt-2 space-y-2"> <div class="mt-2 space-y-2">
@foreach ($complianceIssues as $outcome) @foreach ($complianceEntries as $outcome)
@php
$outcomeStatus = $outcome['status'] ?? 'unknown';
$outcomeColor = match ($outcomeStatus) {
'mapped' => 'text-green-700 bg-green-100 border-green-200',
'skipped' => 'text-amber-900 bg-amber-100 border-amber-200',
default => 'text-gray-700 bg-gray-100 border-gray-200',
};
@endphp
<div class="rounded border border-amber-200 bg-white p-2"> <div class="rounded border border-amber-200 bg-white p-2">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="font-semibold text-gray-900"> <div class="font-semibold text-gray-900">
Template {{ $outcome['template_id'] ?? 'unknown' }} Template {{ $outcome['template_id'] ?? 'unknown' }}
</div> </div>
<span class="rounded border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-900 bg-amber-100 border-amber-200"> <span class="rounded border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide {{ $outcomeColor }}">
skipped {{ $outcomeStatus }}
</span> </span>
</div> </div>
@if (! empty($outcome['rule_name'])) @if (! empty($outcome['rule_name']))
@ -222,6 +230,11 @@
Rule: {{ $outcome['rule_name'] }} Rule: {{ $outcome['rule_name'] }}
</div> </div>
@endif @endif
@if (! empty($outcome['mapped_template_id']))
<div class="mt-1 text-[11px] text-gray-700">
Mapped to: {{ $outcome['mapped_template_id'] }}
</div>
@endif
@if (! empty($outcome['reason'])) @if (! empty($outcome['reason']))
<div class="mt-1 text-[11px] text-gray-800"> <div class="mt-1 text-[11px] text-gray-800">
{{ $outcome['reason'] }} {{ $outcome['reason'] }}

View File

@ -54,8 +54,8 @@ ## Phase 4: Admin UX
**Purpose**: Surface restore and compliance details clearly in the UI. **Purpose**: Surface restore and compliance details clearly in the UI.
- [ ] T013 Update `resources/views/filament/infolists/entries/restore-preview.blade.php` to surface compliance action/template warnings. - [x] T013 Update `resources/views/filament/infolists/entries/restore-preview.blade.php` to surface compliance action/template warnings.
- [ ] T014 Update `resources/views/filament/infolists/entries/restore-results.blade.php` to show compliance action mapping outcomes and skip reasons. - [x] T014 Update `resources/views/filament/infolists/entries/restore-results.blade.php` to show compliance action mapping outcomes and skip reasons.
**Checkpoint**: Admins can see compliance related mapping results in preview and results. **Checkpoint**: Admins can see compliance related mapping results in preview and results.

View File

@ -188,4 +188,5 @@ public function request(string $method, string $path, array $options = []): Grap
expect($policyPreview['compliance_action_warning'] ?? null)->not->toBeNull(); expect($policyPreview['compliance_action_warning'] ?? null)->not->toBeNull();
expect(($policyPreview['compliance_action_summary']['missing'] ?? 0))->toBe(1); expect(($policyPreview['compliance_action_summary']['missing'] ?? 0))->toBe(1);
expect($policyPreview['compliance_action_missing_templates'] ?? [])->toContain('template-1');
}); });