Hub 2.6.0: paged lists, job status filters, one-product updates, installs found on servers

- Jobs: Succeeded/Cancelled filters, product, type and church search, paged
  on the server; audit log and alerts paged on the server with search;
  every other list paged.
- Updates: one product at a time with its own releases; an Events update
  pins the church's Accounts (or updates it when the release needs it, or
  installs it first); fixes the requirement check comparing an object.
- A status job adds installs found on a server and ties them to their
  registration; unlinked registered sites trigger one (daily); heartbeats
  tie install records too; the install page shows its registration.
13 new tests (209).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 20:09:31 +02:00
co-authored by Claude Opus 5.5
parent ff176681a7
commit de6a14c229
24 changed files with 641 additions and 130 deletions
+12 -18
View File
@@ -1,27 +1,21 @@
"use client";
import React, { useEffect, useMemo, useState } from "react";
import React, { useEffect, useState } from "react";
import Link from "next/link";
import { api, errorText } from "@/lib/api";
import { ago, fmtDate } from "@/lib/format";
import { matches, usePaged } from "@/lib/paging";
import { useServerPaged } from "@/lib/paging";
import type { InstallEvent } from "@/lib/types";
import { Badge, Loading, PageTitle, Pager, SearchInput } from "@/components/ui";
/** Open alerts, and the history of everything that happened to installs. */
/** Open alerts, and the history of everything that happened to installs, a page at a time (Hub 2.6.0: paged on the server). */
export default function AlertsPage() {
const [openOnly, setOpenOnly] = useState(true);
const [events, setEvents] = useState<InstallEvent[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [query, setQuery] = useState("");
useEffect(() => {
setEvents(null);
api<InstallEvent[]>(`/api/admin/events${openOnly ? "?open=true" : ""}`).then(setEvents).catch(e => setError(errorText(e)));
}, [openOnly]);
const shown = useMemo(() => (events || []).filter(e => matches(query, e.message, e.level, e.install?.name, e.install?.url)), [events, query]);
const paged = usePaged(shown, `${query}|${openOnly}`);
const [q, setQ] = useState("");
useEffect(() => { const t = setTimeout(() => setQ(query.trim()), 300); return () => clearTimeout(t); }, [query]);
const paged = useServerPaged<InstallEvent>("/api/admin/events", { open: openOnly ? "true" : "", q }, r => r.events as InstallEvent[]);
const events = paged.rows;
const error = paged.error;
return (
<>
@@ -32,13 +26,13 @@ export default function AlertsPage() {
<SearchInput className="w-full sm:ml-auto sm:w-72" value={query} onChange={setQuery} placeholder="Search alerts or install" />
</div>
{error && <p className="text-sm text-red-700">{error}</p>}
{!events ? <Loading /> : events.length === 0 ? <p className="text-sm text-slate-500">{openOnly ? "No open alerts. 🎉" : "Nothing yet."}</p> : (
{!events ? <Loading /> : events.length === 0 && !q ? <p className="text-sm text-slate-500">{openOnly ? "No open alerts. 🎉" : "Nothing yet."}</p> : (
<div className="card overflow-x-auto p-0">
<table className="w-full text-sm">
<thead className="bg-slate-50 text-left text-xs text-slate-500"><tr><th className="p-3">When</th><th className="p-3">Install</th><th className="p-3">What</th><th className="p-3">State</th></tr></thead>
<tbody>
{paged.rows.length === 0 && <tr><td colSpan={4} className="p-3 text-slate-500">No alerts match.</td></tr>}
{paged.rows.map(e => (
{events.length === 0 && <tr><td colSpan={4} className="p-3 text-slate-500">No alerts match.</td></tr>}
{events.map(e => (
<tr key={e.id} className="border-t align-top">
<td className="p-3 whitespace-nowrap text-xs text-slate-500">{fmtDate(e.createdAt)}</td>
<td className="p-3">{e.install ? <Link href={`/installs/${e.install.id}`} className="text-indigo-700 hover:underline">{e.install.name}</Link> : "—"}</td>
@@ -48,7 +42,7 @@ export default function AlertsPage() {
))}
</tbody>
</table>
<Pager {...paged} />
<Pager page={paged.page} pages={paged.pages} setPage={paged.setPage} total={paged.total} pageSize={paged.pageSize} />
</div>
)}
</>