- Install page (/servers/installs/[id]): header with status, Schedule update and a ⋯ menu (move onto the monorepo, demo site, uninstall, remove from the Hub, remove the record); tiles for site/registration, version, server, ports and last heartbeat. - Tabs: Jobs, Settings (.env), Exports; the tab in the URL (?tab=settings). - Every action is a popup (Update, Adopt, Demo, Uninstall, Remove) using the 2.14.0 Modal: asks before discarding, error by its button. Confirmations unchanged. - EnvPanel: read view in the tab, each file edited in a popup. - Banners for not registered, stale (no heartbeat for a day) and a planned uninstall. - Shared PageMessage (also on the customer page); ModalButtons gets danger/disabled. - Logic split into components/install/ (useSubmit, post with LIVE_EVENT re-confirm, uninstallPlan). Frontend only: no migration, no API changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.8 KiB
TypeScript
48 lines
2.8 KiB
TypeScript
"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 (
|
|
<Modal title={record ? "Remove the record" : "Remove from the Hub"} onClose={onClose} dirty={!!typed}>
|
|
<form onSubmit={save} className="space-y-4">
|
|
{record
|
|
? <p className="text-sm text-slate-500">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.</p>
|
|
: <p className="text-sm text-slate-500">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.</p>}
|
|
{!record && <div><label className="label" htmlFor="f-c">Type {x.shortName}</label><input id="f-c" className="input" autoComplete="off" value={typed} onChange={e => setTyped(e.target.value)} /></div>}
|
|
<FormError error={error} />
|
|
<ModalButtons busy={busy} busyLabel="Working…" onCancel={onClose} label={record ? "Remove the record" : "Remove from the Hub"} danger disabled={!record && typed !== x.shortName} />
|
|
</form>
|
|
</Modal>
|
|
);
|
|
}
|