@php use Illuminate\Support\Str; // Extract state from Filament ViewEntry $state = $getState(); $status = $state['status'] ?? 'success'; $warnings = $state['warnings'] ?? []; $settings = $state['settings'] ?? []; $settingsTable = $state['settings_table'] ?? null; $policyType = $state['policy_type'] ?? null; $stringifyValue = function (mixed $value): string { if (is_null($value)) { return 'N/A'; } if (is_bool($value)) { return $value ? 'Enabled' : 'Disabled'; } if (is_scalar($value)) { return (string) $value; } if (is_array($value)) { $encoded = json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); return is_string($encoded) ? $encoded : 'N/A'; } if (is_object($value)) { if (method_exists($value, '__toString')) { return (string) $value; } $encoded = json_encode((array) $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); return is_string($encoded) ? $encoded : 'N/A'; } return 'N/A'; }; $shouldRenderBadges = function (mixed $value): bool { if (! is_array($value) || $value === []) { return false; } if (! array_is_list($value)) { return false; } foreach ($value as $item) { if (! is_scalar($item) && ! is_null($item)) { return false; } } return true; }; $asEnabledDisabledBadgeValue = function (mixed $value): ?bool { if (is_bool($value)) { return $value; } if (! is_string($value)) { return null; } $normalized = strtolower(trim($value)); return match ($normalized) { 'enabled', 'true', 'yes', '1' => true, 'disabled', 'false', 'no', '0' => false, default => null, }; }; @endphp
{{-- Warnings --}} @if(!empty($warnings))
@foreach($warnings as $warning)
{{ $warning }}
@endforeach
@endif {{-- Settings Table (for Settings Catalog legacy format) --}} @if($settingsTable && !empty($settingsTable['rows'])) {{ count($settingsTable['rows']) }} {{ Str::plural('setting', count($settingsTable['rows'])) }}
@foreach($settingsTable['rows'] as $row)
{{ $row['definition'] ?? $row['label'] ?? $row['path'] ?? 'Setting' }}
@php $badgeValue = $asEnabledDisabledBadgeValue($row['value'] ?? null); @endphp @if(! is_null($badgeValue)) {{ $badgeValue ? 'Enabled' : 'Disabled' }} @elseif(is_numeric($row['value'])) {{ $row['value'] }} @else {{ $row['value'] ?? 'N/A' }} @endif
@endforeach
@endif {{-- Settings Blocks (for OMA Settings, Key/Value pairs, etc.) --}} @foreach($settings as $block) @php $blockType = is_array($block) ? ($block['type'] ?? null) : null; @endphp @if($blockType === 'table') {{ count($block['rows'] ?? []) }} {{ Str::plural('item', count($block['rows'] ?? [])) }}
@foreach($block['rows'] ?? [] as $row)
{{ $row['label'] ?? $row['path'] ?? 'Setting' }} @if (! empty($row['path']) && ($row['label'] ?? null) !== ($row['path'] ?? null))

{{ (string) $row['path'] }}

@endif @if(!empty($row['description']))

{{ Str::limit($row['description'], 80) }}

@endif
@php $badgeValue = $asEnabledDisabledBadgeValue($row['value'] ?? null); @endphp @if(! is_null($badgeValue)) {{ $badgeValue ? 'Enabled' : 'Disabled' }} @elseif(is_numeric($row['value'])) {{ $row['value'] }} @elseif($shouldRenderBadges($row['value'] ?? null))
@foreach(($row['value'] ?? []) as $item) {{ is_bool($item) ? ($item ? 'Enabled' : 'Disabled') : (string) $item }} @endforeach
@else {{ Str::limit($stringifyValue($row['value'] ?? null), 200) }} @endif
@endforeach
@elseif($blockType === 'keyValue') {{ count($block['entries'] ?? []) }} {{ Str::plural('entry', count($block['entries'] ?? [])) }}
@foreach($block['entries'] ?? [] as $entry)
{{ $entry['key'] }}
@php $rawValue = $entry['value'] ?? null; $isScriptContent = in_array($entry['key'] ?? null, ['scriptContent', 'detectionScriptContent', 'remediationScriptContent'], true) && (bool) config('tenantpilot.display.show_script_content', false); $badgeValue = $asEnabledDisabledBadgeValue($rawValue); @endphp @if($isScriptContent) @php $code = is_string($rawValue) ? $rawValue : $stringifyValue($rawValue); $firstLine = strtok($code, "\n") ?: ''; $grammar = 'powershell'; if ($policyType === 'deviceShellScript') { $shebang = trim($firstLine); if (str_starts_with($shebang, '#!')) { if (str_contains($shebang, 'zsh')) { $grammar = 'zsh'; } elseif (str_contains($shebang, 'bash')) { $grammar = 'bash'; } else { $grammar = 'sh'; } } else { $grammar = 'sh'; } } elseif ($policyType === 'deviceManagementScript' || $policyType === 'deviceHealthScript') { $grammar = 'powershell'; } $highlightedHtml = null; if (class_exists(\Torchlight\Engine\Engine::class)) { try { $highlightedHtml = (new \Torchlight\Engine\Engine())->codeToHtml( code: $code, grammar: $grammar, theme: [ 'light' => 'github-light', 'dark' => 'github-dark', ], withGutter: false, withWrapper: true, ); } catch (\Throwable $e) { $highlightedHtml = null; } } @endphp
Show Hide {{ number_format(Str::length($code)) }} chars
@if (is_string($highlightedHtml) && $highlightedHtml !== '') @once @include('filament.partials.torchlight-dark-overrides') @endonce
{!! $highlightedHtml !!}
@else
{{ $code }}
@endif
@elseif($shouldRenderBadges($rawValue))
@foreach(($rawValue ?? []) as $item) {{ is_bool($item) ? ($item ? 'Enabled' : 'Disabled') : (string) $item }} @endforeach
@elseif(! is_null($badgeValue)) {{ $badgeValue ? 'Enabled' : 'Disabled' }} @else {{ Str::limit($stringifyValue($rawValue), 200) }} @endif
@endforeach
@endif @endforeach {{-- Empty state --}} @if(empty($settings) && (!$settingsTable || empty($settingsTable['rows'])))

No settings data available

This policy may not contain settings, or they are in an unsupported format

@endif