import React from "react"; import { Button } from "@/components/ui/button"; import { useToast } from "@/hooks/use-toast"; import { AlertTriangle, CheckCircle2, Copy, Loader2, XCircle, } from "lucide-react"; import type { InstallState, LogEntry } from "@/hooks/useInstallExtra"; interface InstallProgressProps { state: InstallState; error: string | null; logs: LogEntry[]; logBoxRef: React.RefObject; onInstall: () => void; onRetry: () => void; installHint: string; packageName: string; idleTitle: string; idleDescription: React.ReactNode; doneDescription: React.ReactNode; } export function installTitle(state: InstallState, idleTitle: string): string { switch (state) { case "done": return "Install Complete"; case "error": return "Install Failed"; case "installing": return "Installing…"; default: return idleTitle; } } export function InstallTitleIcon({ state }: { state: InstallState }) { if (state === "done") return ; if (state === "error") return ; if (state === "installing") return ; return ; } export const InstallProgress: React.FC = ({ state, error, logs, logBoxRef, onInstall, onRetry, installHint, packageName, idleDescription, doneDescription, }) => { const { toast } = useToast(); const handleCopy = async () => { try { await navigator.clipboard.writeText(installHint); toast({ title: "Copied", description: installHint }); } catch { toast({ title: "Copy failed", description: "Select the command and copy manually.", variant: "destructive", }); } }; return ( <> {state === "idle" && ( <>

{idleDescription}

{installHint}
)} {state === "installing" && (

Installing{" "} {packageName} . This usually takes about 10 seconds.

)} {state === "done" && (
{doneDescription}
)} {state === "error" && ( <>

{error || "Install failed."}

)} {state === "error" && logs.length > 0 && (
{logs.map((log, idx) => (
{log.message}
))}
)} ); }; export const RestartInstructions: React.FC<{ purpose: string }> = ({ purpose, }) => ( <>

Install complete. Restart{" "} lelab {" "} to enable {purpose}:

  1. Press{" "} Ctrl+C {" "} in the terminal running{" "} lelab .
  2. Run{" "} lelab {" "} again.
);