import { useEffect, useState } from 'react'; import { CheckCircle2, Loader2, XCircle } from 'lucide-react'; import { EventsOn } from '../../wailsjs/runtime/runtime'; type Step = { id: string; label: string; status: 'pending' | 'running' | 'done' | 'error'; detail?: string; }; // ShutdownProgress is a full-screen overlay that appears while OpsLog is // running its close-time tasks (backup, future LoTW upload, ...). It // listens for `shutdown:start` / `shutdown:update` / `shutdown:done` // events from the backend and renders a checklist that updates as each // task completes. The backend triggers wruntime.Quit() once everything // is finished, so this component never has to dismiss itself. export function ShutdownProgress() { const [steps, setSteps] = useState(null); useEffect(() => { const u1 = EventsOn('shutdown:start', (s: Step[]) => setSteps(s ?? [])); const u2 = EventsOn('shutdown:update', (s: Step[]) => setSteps(s ?? [])); const u3 = EventsOn('shutdown:done', (s: Step[]) => setSteps(s ?? [])); return () => { u1?.(); u2?.(); u3?.(); }; }, []); if (!steps) return null; return (
Closing OpsLog…
{steps.length === 0 ? (
Nothing to do, exiting.
) : steps.map((s) => (
{s.status === 'done' && } {s.status === 'running' && } {s.status === 'error' && } {s.status === 'pending' && }
{s.label}
{s.detail && (
{s.detail}
)}
))}
); }