TenantAtlas/resources/views/filament/system/pages/ops/view-run.blade.php
Ahmed Darrazi add45df609 feat(113): UX polish — Filament-native section components, system panel theme, live scope selector
- Rewrote runbooks.blade.php and view-run.blade.php using <x-filament::section>
  instead of raw Tailwind div cards (cards now render correctly)
- Created resources/css/filament/system/theme.css and registered viteTheme()
  on SystemPanelProvider — fixes missing Tailwind utilities in system panel
- Added ->live() to scope Radio field so Single tenant selector appears immediately
- Extended spec.md with US4 (UX Polish), FR-010–FR-014
- Extended tasks.md with Phase 7 (T050–T057)
2026-02-27 02:10:03 +01:00

180 lines
7.9 KiB
PHP

@php
/** @var \App\Models\OperationRun $run */
$run = $this->run;
$scope = (string) data_get($run->context, 'runbook.scope', 'unknown');
$targetTenantId = data_get($run->context, 'runbook.target_tenant_id');
$reasonCode = data_get($run->context, 'reason.reason_code');
$reasonText = data_get($run->context, 'reason.reason_text');
$platformInitiator = data_get($run->context, 'platform_initiator', []);
$statusSpec = \App\Support\Badges\BadgeRenderer::spec(
\App\Support\Badges\BadgeDomain::OperationRunStatus,
(string) $run->status,
);
$outcomeSpec = (string) $run->status === 'completed'
? \App\Support\Badges\BadgeRenderer::spec(
\App\Support\Badges\BadgeDomain::OperationRunOutcome,
(string) $run->outcome,
)
: null;
$summaryCounts = $run->summary_counts;
$hasSummary = is_array($summaryCounts) && count($summaryCounts) > 0;
@endphp
<x-filament-panels::page>
<div class="space-y-6">
{{-- Run header --}}
<x-filament::section>
<x-slot name="heading">
Run #{{ (int) $run->getKey() }}
</x-slot>
<x-slot name="description">
{{ \App\Support\OperationCatalog::label((string) $run->type) }}
</x-slot>
<x-slot name="afterHeader">
<div class="flex items-center gap-2">
<x-filament::badge
:color="$statusSpec->color"
:icon="$statusSpec->icon"
>
{{ $statusSpec->label }}
</x-filament::badge>
@if ($outcomeSpec)
<x-filament::badge
:color="$outcomeSpec->color"
:icon="$outcomeSpec->icon"
>
{{ $outcomeSpec->label }}
</x-filament::badge>
@endif
</div>
</x-slot>
<div class="space-y-4">
{{-- Key details --}}
<dl class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
<div>
<dt class="text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400">Scope</dt>
<dd class="mt-1">
@if ($scope === 'single_tenant')
<x-filament::badge color="info" size="sm">
Single tenant {{ is_numeric($targetTenantId) ? '#'.(int) $targetTenantId : '' }}
</x-filament::badge>
@elseif ($scope === 'all_tenants')
<x-filament::badge color="warning" size="sm">
All tenants
</x-filament::badge>
@else
<span class="text-sm font-medium text-gray-950 dark:text-white">{{ $scope }}</span>
@endif
</dd>
</div>
<div>
<dt class="text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400">Started</dt>
<dd class="mt-1 text-sm font-medium text-gray-950 dark:text-white">
{{ $run->started_at?->toDayDateTimeString() ?? '—' }}
</dd>
</div>
<div>
<dt class="text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400">Completed</dt>
<dd class="mt-1 text-sm font-medium text-gray-950 dark:text-white">
{{ $run->completed_at?->toDayDateTimeString() ?? '—' }}
</dd>
</div>
<div>
<dt class="text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400">Initiator</dt>
<dd class="mt-1 text-sm font-medium text-gray-950 dark:text-white">
{{ (string) ($run->initiator_name ?? '—') }}
@if (is_array($platformInitiator) && ($platformInitiator['email'] ?? null))
<div class="text-xs text-gray-500 dark:text-gray-400">{{ (string) $platformInitiator['email'] }}</div>
@endif
</dd>
</div>
</dl>
{{-- Reason --}}
@if (is_string($reasonCode) && is_string($reasonText) && trim($reasonCode) !== '' && trim($reasonText) !== '')
<div class="flex items-start gap-3 rounded-lg bg-gray-50 px-4 py-3 dark:bg-white/5">
<x-heroicon-m-document-text class="mt-0.5 h-4 w-4 shrink-0 text-gray-400" />
<div>
<span class="text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400">Reason</span>
<div class="mt-1 text-sm text-gray-950 dark:text-white">
<x-filament::badge color="gray" size="sm">{{ $reasonCode }}</x-filament::badge>
<span class="ml-1">{{ $reasonText }}</span>
</div>
</div>
</div>
@endif
</div>
</x-filament::section>
{{-- Summary counts --}}
@if ($hasSummary)
<x-filament::section>
<x-slot name="heading">
Summary counts
</x-slot>
<div class="space-y-4">
<div class="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4">
@foreach ($summaryCounts as $key => $value)
<div class="rounded-lg bg-gray-50 px-4 py-3 dark:bg-white/5">
<p class="text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400">
{{ \Illuminate\Support\Str::headline((string) $key) }}
</p>
<p class="mt-1 text-xl font-bold text-gray-950 dark:text-white">
{{ is_numeric($value) ? number_format((int) $value) : $value }}
</p>
</div>
@endforeach
</div>
<details>
<summary class="cursor-pointer text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300">
Show raw JSON
</summary>
<div class="mt-2">
@include('filament.partials.json-viewer', ['value' => $summaryCounts])
</div>
</details>
</div>
</x-filament::section>
@endif
{{-- Failures --}}
@if (! empty($run->failure_summary))
<x-filament::section>
<x-slot name="heading">
<div class="flex items-center gap-2 text-danger-600 dark:text-danger-400">
<x-heroicon-m-exclamation-circle class="h-5 w-5" />
Failures
</div>
</x-slot>
@include('filament.partials.json-viewer', ['value' => $run->failure_summary])
</x-filament::section>
@endif
{{-- Context --}}
<x-filament::section collapsible :collapsed="true">
<x-slot name="heading">
Context (raw)
</x-slot>
@include('filament.partials.json-viewer', ['value' => $run->context ?? []])
</x-filament::section>
</div>
</x-filament-panels::page>