import { useEffect, useRef } from "preact/hooks"; import { useI18n } from "../../../shared/i18n/context"; interface UpdateModalProps { open: boolean; onClose: () => void; mode: "git" | "docker" | "electron"; commits: { hash: string; message: string }[]; release: { version: string; body: string; url: string } | null; onApply: () => void; applying: boolean; restarting: boolean; restartFailed: boolean; } export function UpdateModal({ open, onClose, mode, commits, release, onApply, applying, restarting, restartFailed, }: UpdateModalProps) { const { t } = useI18n(); const dialogRef = useRef(null); useEffect(() => { const dialog = dialogRef.current; if (!dialog) return; if (open && !dialog.open) { dialog.showModal(); } else if (!open && dialog.open) { dialog.close(); } }, [open]); // Close on backdrop click const handleBackdropClick = (e: MouseEvent) => { if (e.target === dialogRef.current && !restarting && !applying) { onClose(); } }; // Close on Escape const handleCancel = (e: Event) => { if (restarting || applying) { e.preventDefault(); } }; if (!open) return null; return (
{/* Header */}

{t("updateTitle")}

{!restarting && !applying && ( )}
{/* Body */}
{restarting ? (
{t("updateRestarting")}
) : restartFailed ? (
{t("restartFailed")}
) : mode === "git" ? (
    {commits.map((c) => (
  • {c.hash} {c.message}
  • ))}
) : ( <> {release && (
                  {release.body}
                
)} )}
{/* Footer */} {!restarting && !restartFailed && (
{mode === "git" ? ( ) : mode === "docker" ? ( ) : ( {t("downloadUpdate")} )}
)} {/* Close button for restartFailed state */} {restartFailed && (
)}
); }