@php $fieldWrapperView = $getFieldWrapperView(); $diffs = $getState() ?? []; $diffs = is_array($diffs) ? $diffs : []; $summary = $summary ?? []; $summary = is_array($summary) ? $summary : []; $previewIntegrity = $previewIntegrity ?? []; $previewIntegrity = is_array($previewIntegrity) ? $previewIntegrity : []; $checksIntegrity = $checksIntegrity ?? []; $checksIntegrity = is_array($checksIntegrity) ? $checksIntegrity : []; $safetyAssessment = $safetyAssessment ?? []; $safetyAssessment = is_array($safetyAssessment) ? $safetyAssessment : []; $ranAt = $ranAt ?? ($previewIntegrity['generated_at'] ?? null); $ranAtLabel = null; if (is_string($ranAt) && $ranAt !== '') { try { $ranAtLabel = \Carbon\CarbonImmutable::parse($ranAt)->format('Y-m-d H:i'); } catch (\Throwable) { $ranAtLabel = $ranAt; } } $integritySpec = \App\Support\Badges\BadgeRenderer::spec( \App\Support\Badges\BadgeDomain::RestorePreviewDecision, $previewIntegrity['state'] ?? 'not_generated' ); $policiesTotal = (int) ($summary['policies_total'] ?? 0); $policiesChanged = (int) ($summary['policies_changed'] ?? 0); $assignmentsChanged = (int) ($summary['assignments_changed'] ?? 0); $scopeTagsChanged = (int) ($summary['scope_tags_changed'] ?? 0); $diffsOmitted = (int) ($summary['diffs_omitted'] ?? 0); $integritySummary = $previewIntegrity['display_summary'] ?? 'Generate a preview before real execution.'; $nextAction = $safetyAssessment['primary_next_action'] ?? 'generate_preview'; $nextActionLabel = \App\Support\RestoreSafety\RestoreSafetyCopy::primaryNextAction(is_string($nextAction) ? $nextAction : 'generate_preview'); $limitedKeys = static function (array $items, int $limit = 8): array { $keys = array_keys($items); if (count($keys) <= $limit) { return $keys; } return array_slice($keys, 0, $limit); }; @endphp
{{ $integritySpec->label }} @if (($checksIntegrity['state'] ?? null) === 'current') Checks current @endif @if (($safetyAssessment['state'] ?? null) === 'ready_with_caution') Calm readiness suppressed @endif
What the preview proves
{{ $integritySummary }}
Primary next step
{{ $nextActionLabel }}
{{ $policiesChanged }}/{{ $policiesTotal }} policies changed {{ $assignmentsChanged }} assignments changed {{ $scopeTagsChanged }} scope tags changed @if ($diffsOmitted > 0) {{ $diffsOmitted }} diffs omitted (limit) @endif
@if (($previewIntegrity['invalidation_reasons'] ?? []) !== [])
Invalidated by: {{ implode(', ', array_map(static fn (string $reason): string => \Illuminate\Support\Str::replace('_', ' ', $reason), $previewIntegrity['invalidation_reasons'])) }}
@endif
@if ($diffs === [])
No preview diff is recorded for this scope yet.
@else
@foreach ($diffs as $entry) @php $entry = is_array($entry) ? $entry : []; $name = $entry['display_name'] ?? $entry['policy_identifier'] ?? 'Item'; $type = $entry['policy_type'] ?? 'type'; $platform = $entry['platform'] ?? 'platform'; $action = $entry['action'] ?? 'update'; $diff = is_array($entry['diff'] ?? null) ? $entry['diff'] : []; $diffSummary = is_array($diff['summary'] ?? null) ? $diff['summary'] : []; $added = (int) ($diffSummary['added'] ?? 0); $removed = (int) ($diffSummary['removed'] ?? 0); $changed = (int) ($diffSummary['changed'] ?? 0); $assignmentsDelta = (bool) ($entry['assignments_changed'] ?? false); $scopeTagsDelta = (bool) ($entry['scope_tags_changed'] ?? false); $diffOmitted = (bool) ($entry['diff_omitted'] ?? false); $diffTruncated = (bool) ($entry['diff_truncated'] ?? false); $changedKeys = $limitedKeys(is_array($diff['changed'] ?? null) ? $diff['changed'] : []); $addedKeys = $limitedKeys(is_array($diff['added'] ?? null) ? $diff['added'] : []); $removedKeys = $limitedKeys(is_array($diff['removed'] ?? null) ? $diff['removed'] : []); @endphp
{{ $action }} {{ $added }} added {{ $removed }} removed {{ $changed }} changed @if ($assignmentsDelta) assignments @endif @if ($scopeTagsDelta) scope tags @endif @if ($diffTruncated) truncated @endif
@if ($diffOmitted)
Diff details omitted due to preview limits. Narrow scope to see more items in detail.
@elseif ($changedKeys !== [] || $addedKeys !== [] || $removedKeys !== [])
@if ($changedKeys !== [])
Changed keys (sample)
    @foreach ($changedKeys as $key)
  • {{ $key }}
  • @endforeach
@endif @if ($addedKeys !== [])
Added keys (sample)
    @foreach ($addedKeys as $key)
  • {{ $key }}
  • @endforeach
@endif @if ($removedKeys !== [])
Removed keys (sample)
    @foreach ($removedKeys as $key)
  • {{ $key }}
  • @endforeach
@endif
@endif
@endforeach
@endif