import { useState } from 'react' function fmtDate(iso) { if (!iso) return '—'; try { return new Date(iso).toLocaleString(undefined, { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', }); } catch { return iso; } } function StatusBadge({ status }) { const cls = status === 'completed' ? 'run-status--completed' : status === 'failed' ? 'run-status--failed' : status === 'in_progress' ? 'run-status--in-progress' : ''; const label = status ? status.replace(/_/g, ' ') : '—'; return {label}; } export default function RunsView({ runs }) { const [expanded, setExpanded] = useState(null) // run_uid of the expanded row function toggle(uid) { setExpanded(prev => prev === uid ? null : uid) } return (
{runs.length === 0 ? ( ) : runs.map(run => { const hasError = run.status === 'failed' && run.error_summary const isExpanded = expanded === run.run_uid return [ toggle(run.run_uid) : undefined} title={hasError ? (isExpanded ? 'Click to hide error' : 'Click to view error') : undefined} > , hasError && isExpanded && ( ), ] })}
Started Status Requested Completed Failed
No runs yet.
{fmtDate(run.started_at)} {hasError && ( )} {run.requested_count ?? '—'} {run.completed_count ?? '—'} {run.failed_count ?? '—'}
{run.error_summary}
); }