Hub 2.18.0: releases picked from a list on New install and Move onto the monorepo

- components/ReleaseSelect.tsx: Latest (with its version) first, then the newest 10 releases,
  Show older versions for the rest; marked latest, running now and what each needs.
- New install and Move onto the monorepo use it (they were free text); the install's Update popup
  and the Updates page use it too. Move onto the monorepo lists Events from 2.2.0 (the first
  monorepo tag).
- docs/VERSION-PICKERS-PLAN.md: this and 2.19.0 (agent releases). Frontend only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 13:11:21 +02:00
co-authored by Claude Opus 5.5
parent 21bda2bb32
commit 65cc06183b
12 changed files with 174 additions and 22 deletions
@@ -145,7 +145,7 @@ export default function DeploymentPage() {
</div>
{popup === "update" && <UpdateModal x={x} releases={releases} onClose={close} onDone={done} />}
{popup === "adopt" && <AdoptModal x={x} onClose={close} onDone={done} />}
{popup === "adopt" && <AdoptModal x={x} releases={releases} onClose={close} onDone={done} />}
{popup === "demo" && <DemoModal x={x} onClose={close} onDone={done} />}
{popup === "uninstall" && <UninstallModal x={x} plan={plan} onClose={close} onDone={done} />}
{(popup === "record" || popup === "forget") && <RemoveModal kind={popup} x={x} stale={d.stale} onClose={close} onRemoved={() => router.push("/servers/installs")} />}
@@ -8,6 +8,8 @@ import { api, errorText } from "@/lib/api";
import { ago } from "@/lib/format";
import { matches, usePaged } from "@/lib/paging";
import { PRODUCT_NAMES } from "@/lib/products";
import type { Release } from "@/lib/types";
import { ReleaseSelect } from "@/components/ReleaseSelect";
import { FormError, Loading, Modal, ModalButtons, PageMessage, PageTitle, Pager, SearchInput, useSubmit } from "@/components/ui";
import { ServersNav, StatusPill, pct, shownStatus, type Deployment, type ServerSummary } from "@/components/servers";
@@ -23,9 +25,13 @@ const changedFrom = <T extends Record<string, string>>(form: T, empty: T) => (Ob
function NewInstallModal({ servers, onClose }: { servers: ServerSummary[]; onClose: () => void }) {
const router = useRouter();
const [customers, setCustomers] = useState<Customer[]>([]);
const [releases, setReleases] = useState<Release[]>([]);
const [form, setForm] = useState(emptyNew);
const { busy, error, run } = useSubmit();
useEffect(() => { api<Customer[]>("/api/admin/customers").then(setCustomers).catch(() => {}); }, []);
useEffect(() => {
api<Customer[]>("/api/admin/customers").then(setCustomers).catch(() => {});
api<Release[]>("/api/admin/releases").then(setReleases).catch(() => {});
}, []);
const submit = (e: React.FormEvent) => {
e.preventDefault();
@@ -48,7 +54,7 @@ function NewInstallModal({ servers, onClose }: { servers: ServerSummary[]; onClo
<form onSubmit={submit} className="grid gap-3 md:grid-cols-2">
<div className="md:col-span-2">
<label className="label" htmlFor="n-product">Product</label>
<select id="n-product" className="input" {...f("product")}>
<select id="n-product" className="input" value={form.product} onChange={e => setForm({ ...form, product: e.target.value, version: "" })}>
<option value="events">Cross Events</option>
<option value="accounts">Accounts (the church&apos;s sign-in)</option>
</select>
@@ -86,7 +92,10 @@ function NewInstallModal({ servers, onClose }: { servers: ServerSummary[]; onClo
})}
</div>
</div>
<div><label className="label" htmlFor="n-ver">Release</label><input id="n-ver" className="input" placeholder="latest" {...f("version")} /></div>
<div>
<label className="label" htmlFor="n-ver">Release</label>
<ReleaseSelect key={form.product} id="n-ver" releases={releases.filter(r => r.product === form.product)} value={form.version} onChange={version => setForm({ ...form, version })} />
</div>
<div className="space-y-3 md:col-span-2">
<p className="text-xs text-slate-500">The Hub makes the licence, picks two ports, and the agent installs within a minute. You get the report and the FastPanel steps by email.</p>
<FormError error={error} />
@@ -6,6 +6,7 @@ import { api, ApiError, errorText } from "@/lib/api";
import { fmtDate } from "@/lib/format";
import { usePaged } from "@/lib/paging";
import { PRODUCT_NAMES } from "@/lib/products";
import { ReleaseSelect } from "@/components/ReleaseSelect";
import type { Release } from "@/lib/types";
import { Loading, Message, PageTitle, Pager, Tabs } from "@/components/ui";
import { ServersNav, StatusPill, toInput, fromInput, type Deployment, type Job } from "@/components/servers";
@@ -44,7 +45,6 @@ export default function UpdatesPage() {
const deployments = useMemo(() => (all || []).filter(d => d.product === product), [all, product]);
const ownReleases = useMemo(() => releases.filter(r => r.product === product), [releases, product]);
const latest = ownReleases.find(r => r.latest)?.version;
const byVersion = useMemo(() => [...new Set(deployments.map(versionOf))].sort(), [deployments]);
const upcomingPaged = usePaged(upcoming, upcoming.length, 20);
@@ -114,10 +114,7 @@ export default function UpdatesPage() {
<div className="grid gap-3 md:grid-cols-2">
<div>
<label className="label" htmlFor="b-v">{name} release</label>
<select id="b-v" className="input" value={form.version} onChange={e => setForm({ ...form, version: e.target.value })}>
<option value="">Latest{latest ? ` (${latest})` : ""}</option>
{ownReleases.map(r => <option key={r.id} value={r.version}>{r.version}{r.latest ? " (latest)" : ""}{r.requires?.length ? ` · needs ${r.requires.map(q => `${PRODUCT_NAMES[q.product]} ${q.version}`).join(", ")}` : ""}</option>)}
</select>
<ReleaseSelect key={product} id="b-v" releases={ownReleases} value={form.version} onChange={version => setForm({ ...form, version })} />
{product === "events" && <p className="mt-1 text-xs text-slate-500">Each church&apos;s Accounts stays on its version, unless this release needs a newer one: then it&apos;s updated first in the same deploy, or installed first if the church has none. The confirmation lists what happens.</p>}
</div>
{form.emergency && form.asap
+64
View File
@@ -0,0 +1,64 @@
"use client";
import React, { useMemo, useState } from "react";
import { PRODUCT_NAMES, type Product } from "@/lib/products";
/** Compares dotted versions (1.10.0 after 1.9.2); negative when a is older. */
export function compareVersions(a: string, b: string) {
const x = a.split(".").map(n => parseInt(n, 10) || 0);
const y = b.split(".").map(n => parseInt(n, 10) || 0);
for (let i = 0; i < Math.max(x.length, y.length); i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) - (y[i] || 0);
return 0;
}
/** What a release in the list needs: its version, and optionally whether it's the latest and what it requires. */
export type PickableRelease = { version: string; latest?: boolean; requires?: { product: Product; version: string }[] };
const SHOWN = 10;
/**
* Hub 2.18.0: pick a release from a list instead of typing it. First "Latest (x.y.z)" (value "",
* so the Hub picks the newest when the job is made), then the releases newest first: the newest 10
* until "Show older versions" is clicked. `current` is marked "running now"; with `currentPickable`
* false it can't be chosen. `from` leaves out anything older.
*/
export function ReleaseSelect({ id, releases, value, onChange, current, currentPickable = true, from, latestLabel = "Latest" }: {
id: string; releases: PickableRelease[]; value: string; onChange: (version: string) => void;
current?: string | null; currentPickable?: boolean; from?: string; latestLabel?: string;
}) {
const [all, setAll] = useState(false);
const sorted = useMemo(
() => releases.filter(r => !from || compareVersions(r.version, from) >= 0).sort((a, b) => compareVersions(b.version, a.version)),
[releases, from],
);
const newest = sorted.find(r => r.latest) || sorted[0];
// The chosen one stays in the list even when it's older than the first 10.
const shown = all ? sorted : sorted.filter((r, i) => i < SHOWN || r.version === value);
const hidden = sorted.length - shown.length;
return (
<div>
<select id={id} className="input" value={value} onChange={e => onChange(e.target.value)}>
<option value="">{latestLabel}{newest ? ` (${newest.version})` : ""}</option>
{shown.map(r => {
const running = !!current && r.version === current;
const notes = [
r.latest ? "latest" : null,
running ? "running now" : null,
].filter(Boolean);
return (
<option key={r.version} value={r.version} disabled={running && !currentPickable}>
{r.version}{notes.length ? ` (${notes.join(", ")})` : ""}{r.requires?.length ? ` · needs ${r.requires.map(q => `${PRODUCT_NAMES[q.product]} ${q.version}`).join(", ")}` : ""}
</option>
);
})}
</select>
{hidden > 0 && (
<button type="button" className="mt-1 text-xs text-indigo-700 hover:underline" onClick={() => setAll(true)}>
Show older versions ({hidden})
</button>
)}
{!sorted.length && <p className="mt-1 text-xs text-slate-500">No releases yet (see the Releases page).</p>}
</div>
);
}
+10 -2
View File
@@ -3,10 +3,15 @@
import React, { useState } from "react";
import { FormError, Modal, ModalButtons, useSubmit } from "@/components/ui";
import { fromInput, toInput } from "@/components/servers";
import { ReleaseSelect } from "@/components/ReleaseSelect";
import type { Release } from "@/lib/types";
import { H, changed, post, withWarnings, type Done, type Install } from "./shared";
/** The first Cross Events release tagged in the monorepo; older ones are the old repository's tags, which adopt can't check out. */
const MONOREPO_EVENTS_FROM = "2.2.0";
/** Move an old (2.1.x) Events install onto the monorepo: `crosscode adopt` at a planned time. */
export function AdoptModal({ x, onClose, onDone }: { x: Install; onClose: () => void; onDone: Done }) {
export function AdoptModal({ x, releases, onClose, onDone }: { x: Install; releases: Release[]; onClose: () => void; onDone: Done }) {
const [form0] = useState(() => ({ eventsDir: "", version: "", address: "", at: toInput(new Date(Date.now() + 5 * H)) }));
const [adopt, setAdopt] = useState(form0);
const { busy, error, run } = useSubmit();
@@ -27,7 +32,10 @@ export function AdoptModal({ x, onClose, onDone }: { x: Install; onClose: () =>
<div className="grid gap-3 sm:grid-cols-2">
<div className="sm:col-span-2"><label className="label" htmlFor="a-d">The old install&apos;s folder</label><input id="a-d" className="input font-mono" required placeholder="/var/www/hope-events" value={adopt.eventsDir} onChange={e => setAdopt({ ...adopt, eventsDir: e.target.value })} /></div>
<div><label className="label" htmlFor="a-a">The church&apos;s address</label><input id="a-a" className="input" required={!eventsSub} placeholder={eventsSub ? x.domain.slice("events.".length) : "hope.co.za"} value={adopt.address} onChange={e => setAdopt({ ...adopt, address: e.target.value })} /></div>
<div><label className="label" htmlFor="a-v">Release</label><input id="a-v" className="input" placeholder="latest" value={adopt.version} onChange={e => setAdopt({ ...adopt, version: e.target.value })} /></div>
<div>
<label className="label" htmlFor="a-v">Release</label>
<ReleaseSelect id="a-v" releases={releases.filter(r => r.product === "events")} from={MONOREPO_EVENTS_FROM} value={adopt.version} onChange={version => setAdopt({ ...adopt, version })} />
</div>
<div><label className="label" htmlFor="a-at">When</label><input id="a-at" type="datetime-local" className="input" value={adopt.at} onChange={e => setAdopt({ ...adopt, at: e.target.value })} /></div>
</div>
<FormError error={error} />
@@ -2,9 +2,9 @@
import React, { useState } from "react";
import type { Release } from "@/lib/types";
import { PRODUCT_NAMES } from "@/lib/products";
import { FormError, Modal, ModalButtons, useSubmit } from "@/components/ui";
import { fromInput, toInput } from "@/components/servers";
import { ReleaseSelect } from "@/components/ReleaseSelect";
import { H, changed, post, productName, withWarnings, type Done, type Install } from "./shared";
/**
@@ -33,10 +33,7 @@ export function UpdateModal({ x, releases, onClose, onDone }: { x: Install; rele
<div className="grid gap-3 sm:grid-cols-2">
<div>
<label className="label" htmlFor="u-v">Release</label>
<select id="u-v" className="input" value={upd.version} onChange={e => setUpd({ ...upd, version: e.target.value })}>
<option value="">Latest</option>
{mine.map(r => <option key={r.id} value={r.version}>{r.version}{r.latest ? " (latest)" : ""}{r.requires?.length ? ` · needs ${r.requires.map(q => `${PRODUCT_NAMES[q.product]} ${q.version}`).join(", ")}` : ""}</option>)}
</select>
<ReleaseSelect id="u-v" releases={mine} value={upd.version} onChange={version => setUpd({ ...upd, version })} current={x.install?.version || x.version} />
<p className="mt-1 text-xs text-slate-500">Now on {x.install?.version || x.version || "an unknown version"}.</p>
</div>
{asap