Hub 2.4.0: demo sites, and demo data loaded from the Hub

Mark a Cross Events install as a demo site, then load a demo set (small,
events, ministry, multicampus) with a seed-demo job (agent 1.2.0+,
crosscode demo: backup, demo data, restart). Typing the short name for both.
Deployment.isDemo (migration), contracts 1.7.0 vendored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 10:41:03 +02:00
co-authored by Claude Opus 5.5
parent 36987a9b69
commit dbfa4116c4
15 changed files with 149 additions and 14 deletions
@@ -28,6 +28,7 @@ export default function DeploymentPage() {
const [upd, setUpd] = useState({ version: "", at: toInput(new Date(Date.now() + 5 * H)), emergency: false, reason: "", totp: "" });
const [adopt, setAdopt] = useState({ eventsDir: "", version: "", address: "", at: toInput(new Date(Date.now() + 5 * H)) });
const [un, setUn] = useState({ at: toInput(new Date(Date.now() + 7 * 24 * H)), totp: "", confirm: "" });
const [demo, setDemo] = useState({ profile: "events", confirm: "", markConfirm: "" });
const load = useCallback(() => api<Detail>(`/api/admin/deployments/${id}`).then(setD).catch(e => setMsg({ type: "err", text: errorText(e) })), [id]);
useEffect(() => { load(); }, [load]);
@@ -107,6 +108,36 @@ export default function DeploymentPage() {
</form>
)}
{x.product === "events" && ["live", "waiting_for_proxy"].includes(x.status) && (
<div className="card space-y-3">
<h2 className="font-medium">Demo site</h2>
{!x.isDemo ? (
<form className="grid gap-3 md:grid-cols-[1fr_auto] md:items-end" onSubmit={e => { e.preventDefault(); act(`/api/admin/deployments/${x.id}/demo`, { isDemo: true, confirm: demo.markConfirm }, "Marked as a demo site."); }}>
<p className="text-sm text-slate-500 md:col-span-2">A demo site&apos;s data can be replaced with demo data from here. Only mark sites used for showing Cross Events, never a church&apos;s real site.</p>
<div><label className="label" htmlFor="d-m">Type {x.shortName}</label><input id="d-m" className="input" value={demo.markConfirm} onChange={e => setDemo({ ...demo, markConfirm: e.target.value })} /></div>
<button className="btn-secondary" disabled={demo.markConfirm !== x.shortName}>Mark as a demo site</button>
</form>
) : (
<>
<form className="grid gap-3 md:grid-cols-3 md:items-end" onSubmit={e => { e.preventDefault(); if (window.confirm(`Replace ALL of ${x.shortName}'s data with the "${demo.profile}" demo? A backup is taken first; one admin account is kept.`)) act(`/api/admin/deployments/${x.id}/seed-demo`, { profile: demo.profile, confirm: demo.confirm }, "Queued: the agent loads the demo data on its next poll (see Jobs below). You get an email when it's done."); }}>
<p className="text-sm text-slate-500 md:col-span-3">Replaces everything (events, people, payments) with a demo set, keeping the site settings and {x.adminEmail || "the site's first admin"}. Demo logins use the password Demo@1234.</p>
<div><label className="label" htmlFor="d-p">Demo</label>
<select id="d-p" className="input" value={demo.profile} onChange={e => setDemo({ ...demo, profile: e.target.value })}>
<option value="small">Small church: the essentials</option>
<option value="events">Events and conferences</option>
<option value="ministry">Weekly ministry: courses, kids, volunteers</option>
<option value="multicampus">Three campuses</option>
</select>
</div>
<div><label className="label" htmlFor="d-c">Type {x.shortName}</label><input id="d-c" className="input" value={demo.confirm} onChange={e => setDemo({ ...demo, confirm: e.target.value })} /></div>
<button className="btn-danger" disabled={demo.confirm !== x.shortName}>Load demo data</button>
</form>
<button type="button" className="text-sm text-slate-500 underline" onClick={() => act(`/api/admin/deployments/${x.id}/demo`, { isDemo: false }, "No longer a demo site.")}>It isn&apos;t a demo site any more</button>
</>
)}
</div>
)}
<div className="card overflow-x-auto">
<h2 className="font-medium">Jobs</h2>
<table className="mt-3 w-full text-sm">