Merge branch 'feat/version-pickers'
This commit is contained in:
@@ -5,6 +5,18 @@ versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.18.0] - 2026-11-23
|
||||
|
||||
Frontend only: no migration, no API changes.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Releases are picked from a list, not typed.** New install and Move onto the monorepo now list the
|
||||
product's releases, like the install's Update popup and the Updates page: first Latest (with its
|
||||
version), then the newest 10, with **Show older versions** for the rest. Each is marked latest,
|
||||
running now (when updating an install) or with what it needs ("needs Accounts 1.2.0").
|
||||
- Move onto the monorepo lists Cross Events releases from 2.2.0, the first in the monorepo.
|
||||
|
||||
## [2.17.0] - 2026-11-23
|
||||
|
||||
Frontend only: no migration, no API changes. With 2.16.0, every add and edit that was an action on a
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-backend",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^1.3.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"private": true,
|
||||
"description": "Cross Events Hub — API for managing Cross Events installs, licences and heartbeats",
|
||||
"main": "src/index.js",
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# Version pickers plan
|
||||
|
||||
Status: 2.18.0 done; 2.19.0 in progress · 2026-11-23
|
||||
|
||||
Three forms still ask for a version as free text, though the Hub knows (or could know) every release.
|
||||
This plan turns them into a list to pick from, and gives the Hub the agent's releases so Update agent
|
||||
can do the same.
|
||||
|
||||
## Where versions are typed today
|
||||
|
||||
| Form | Today | What the Hub knows |
|
||||
|---|---|---|
|
||||
| **New install** (`app/(hub)/servers/installs/page.tsx`) | Free text "Release", placeholder "latest" | Every product release; the backend already refuses an unknown version (`releaseFor` in `utils/jobs.js`) |
|
||||
| **Move onto the monorepo** (`components/install/AdoptModal.tsx`) | Free text "Release", placeholder "latest" | The same |
|
||||
| **Update agent** (`app/(hub)/servers/[id]/page.tsx`) | Free text, placeholder "agent@1.0.1" | Nothing: the Hub has no agent releases; the contract only checks the form `agent@x.y.z` |
|
||||
|
||||
The install's **Update** popup and the **Updates** page already have a list of releases.
|
||||
|
||||
For the agent, the monorepo has `agent@1.0.0`…`agent@1.5.0` tags and the agent's self-update checks
|
||||
the tag out. Missing: notes (`apps/agent/WHATS-NEW.md`; without it a sync reports "not found"), and a
|
||||
place in the Hub for them. Releases hang off the `Product` enum, which licences, billing, customer
|
||||
products and notices also use, so the agent doesn't become a product.
|
||||
|
||||
## Decisions (2026-11-23)
|
||||
|
||||
- Older versions are offered too (to go back to one): the newest 10, with **Show older versions** to
|
||||
see the rest. Latest stays the default.
|
||||
- Agent releases and their notes show on the Releases page.
|
||||
- The agent's notes are written from its history, for every tag (1.0.0–1.5.0), in crosscode-platform.
|
||||
|
||||
## Hub 2.18.0: pickers for products (frontend only)
|
||||
|
||||
1. **`components/ReleaseSelect.tsx`**: first "Latest (3.6.1)" (sends no version, as today), then the
|
||||
product's releases newest first, the newest 10 until **Show older versions (n)** is clicked; each
|
||||
marked "(latest)", "running now" and "needs Accounts 1.2.0" where it applies. `UpdateModal` and the
|
||||
Updates page use it too, so all four look the same.
|
||||
2. **New install**: the popup loads the releases; the list is the chosen product's, and changing the
|
||||
product goes back to Latest.
|
||||
3. **Move onto the monorepo**: the same list, Cross Events releases from 2.2.0 (the first one in the
|
||||
monorepo; the 2.1.x releases are the old repository's tags, which `adopt` can't check out).
|
||||
|
||||
No backend changes: the backend already checks the version.
|
||||
|
||||
## Hub 2.19.0: agent releases (migration)
|
||||
|
||||
0. **crosscode-platform**: `apps/agent/WHATS-NEW.md`, a `## 1.x.y` section per tag (1.0.0–1.5.0; written, not committed yet).
|
||||
Read from the default branch, so no new tag is needed.
|
||||
1. **`AgentRelease`** (version unique, notes, urgent, releasedAt), its own model and migration, so
|
||||
`Product` and everything on it is untouched.
|
||||
2. **Sync**: a release source can be for the **Server agent** as well as a product; the default
|
||||
sources gain it (monorepo, `agent@`, `apps/agent/WHATS-NEW.md`). Same rule as products: nothing is
|
||||
removed unless every source was read and tags were found.
|
||||
3. **API**: `GET /api/admin/agent-releases`; server summaries carry the latest agent version; an
|
||||
update-agent job for a version that isn't a known agent release is refused (like `releaseFor`).
|
||||
4. **Hub**: Update agent is a `ReleaseSelect` (Latest by default, the running version marked and not
|
||||
pickable, the chosen version's notes under it); the Servers list and a server's page show
|
||||
"agent 1.4.0 · 1.5.0 available"; the Releases page has a **Server agent** filter (from git only, no
|
||||
Add).
|
||||
|
||||
Later, not in this plan: **Update every agent** on the Servers page (one job per server behind).
|
||||
|
||||
## Checks
|
||||
|
||||
`npx tsc --noEmit`, `npx next build` (and `npx jest` in `backend` for 2.19.0). Each release gets its
|
||||
CHANGELOG entry and a `vX.Y.Z` tag, then the docs commits in crosscode-platform.
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.536.0",
|
||||
"next": "^15.5.24",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.17.0",
|
||||
"version": "2.18.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3200",
|
||||
|
||||
@@ -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'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's Accounts stays on its version, unless this release needs a newer one: then it'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
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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'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'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
|
||||
|
||||
Reference in New Issue
Block a user