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
+27
View File
@@ -1,4 +1,5 @@
import { useEffect, useMemo, useState } from "react";
import { api, errorText } from "@/lib/api";
/** True when every word of the query appears in one of the fields (case-insensitive). */
export function matches(query: string, ...fields: (string | number | null | undefined)[]) {
@@ -20,3 +21,29 @@ export function usePaged<T>(items: T[], resetKey: unknown, pageSize = 25) {
const rows = useMemo(() => items.slice((current - 1) * pageSize, current * pageSize), [items, current, pageSize]);
return { rows, page: current, pages, setPage, total: items.length, pageSize };
}
/**
* A list paged on the server (Hub 2.6.0: jobs, alerts, the audit log). `path` without paging;
* `params` are the filters, and a change in them goes back to the first page. `pick` takes the
* rows out of the answer. `reload()` fetches the same page again.
*/
export function useServerPaged<T>(path: string, params: Record<string, string>, pick: (r: Record<string, unknown>) => T[], pageSize = 50) {
const [page, setPage] = useState(1);
const [data, setData] = useState<{ rows: T[]; total: number; pages: number } | null>(null);
const [error, setError] = useState<string | null>(null);
const [tick, setTick] = useState(0);
const key = JSON.stringify(params);
useEffect(() => { setPage(1); }, [key]);
useEffect(() => {
let alive = true;
const q = new URLSearchParams({ ...Object.fromEntries(Object.entries(params).filter(([, v]) => v !== "")), page: String(page), pageSize: String(pageSize) });
setError(null);
api<Record<string, unknown> & { total: number; pages: number }>(`${path}?${q}`)
.then(r => { if (alive) setData({ rows: pick(r), total: r.total, pages: r.pages }); })
.catch(e => { if (alive) setError(errorText(e)); });
return () => { alive = false; };
// eslint-disable-next-line react-hooks/exhaustive-deps -- `key` stands for `params`; `pick` is a fixed accessor
}, [path, key, page, pageSize, tick]);
const reload = () => setTick(t => t + 1);
return { rows: data?.rows ?? null, total: data?.total ?? 0, pages: data?.pages ?? 1, page, setPage, pageSize, error, reload };
}