@props(['status', 'title' => 'Application status', 'containerName' => 'Container']) @php $rawStatus = str((string) $status)->lower()->trim()->value(); $statusParts = explode(':', $rawStatus); $containerStatus = $statusParts[0] ?? 'unknown'; $healthStatus = $statusParts[1] ?? null; $monitoringExcluded = in_array('excluded', $statusParts, true); if ($healthStatus === null && preg_match('/^([^()]+)\(([^)]+)\)$/', $rawStatus, $matches)) { $containerStatus = trim($matches[1]); $healthStatus = trim($matches[2]); } $containerLabel = str($containerStatus ?: 'unknown')->headline()->value(); $healthLabel = match (true) { $monitoringExcluded => 'Monitoring disabled', $healthStatus === 'healthy' => 'Healthy', $healthStatus === 'unhealthy' => 'Unhealthy', $healthStatus === 'starting' => 'Starting', default => 'Not configured', }; $containerType = match (true) { str($containerStatus)->startsWith('running') => 'success', str($containerStatus)->startsWith(['starting', 'restarting']) => 'warning', default => 'error', }; $healthType = match (true) { $monitoringExcluded => 'warning', $healthStatus === 'healthy' => 'success', $healthStatus === 'unhealthy' => 'error', default => 'warning', }; [$summaryLabel, $summaryType] = match (true) { $containerType === 'error' => [$containerLabel, 'error'], $healthType === 'error' => ['Degraded', 'error'], $containerType === 'warning' => [$containerLabel, 'warning'], $monitoringExcluded => ["{$containerLabel} (monitoring disabled)", 'warning'], $healthStatus === 'starting' => ["{$containerLabel} (healthcheck starting)", 'warning'], $healthType === 'warning' => ["{$containerLabel} (no healthcheck)", 'warning'], default => [$containerLabel, 'success'], }; @endphp
$summaryType === 'success', 'bg-warning' => $summaryType === 'warning', 'bg-error' => $summaryType === 'error', ])> {{ $summaryLabel }}