"use client"; import React, { useState } from "react"; import { api } from "@/lib/api"; import { ago, fmtDate } from "@/lib/format"; import { FormError, Modal } from "@/components/ui"; import { ModalButtons } from "@/components/customer/ReadCard"; import { useSubmit, type Detail, type Install } from "./shared"; export type RemoveKind = "record" | "forget"; /** * Take an install off the Hub without running anything on its server: * - "record": its install failed and the server already cleaned up (frees the short name); * - "forget" (2.12.0): no heartbeat for a day, and the site is gone from the server by other means. */ export function RemoveModal({ kind, x, stale, onClose, onRemoved }: { kind: RemoveKind; x: Install; stale: Detail["stale"]; onClose: () => void; onRemoved: () => void }) { const [typed, setTyped] = useState(""); const { busy, error, run } = useSubmit(); const record = kind === "record"; const save = (e: React.FormEvent) => { e.preventDefault(); const sure = record ? `Remove the record of ${x.shortName}? Its install failed, so nothing of it is on the server.` : `Remove ${x.domain} from the Hub? Nothing runs on the server: use this only when the site is already gone from it.`; if (!window.confirm(sure)) return; run(async () => { if (record) await api(`/api/admin/deployments/${x.id}`, { method: "DELETE" }); else await api(`/api/admin/deployments/${x.id}/forget`, { method: "POST", body: { confirm: typed } }); onRemoved(); }); }; return (
{record ?

This install failed and the server already removed what it made, so there's nothing to export or uninstall. Removing the record frees the short name.

:

No heartbeat since {stale.since ? `${fmtDate(stale.since)} (${ago(stale.since)})` : "it was made"}. If the site is no longer on {x.server.name} (uninstalled by hand, or the server was rebuilt), remove it here: nothing runs on the server, what was planned for it is cancelled, its ports are freed after 30 days and its licence's heartbeats are refused. If it's still there, uninstall it instead.

} {!record &&
setTyped(e.target.value)} />
}
); }