Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ unified-ui version it builds into its image.

## [Unreleased]

### Added

- What reads an item, as tables: on a unified-api source's page the endpoints whose output it is part of (marked where it limits the hosts) and the views it is a member of; on a unified-gitops project's page the webhooks hearing it; on a unified-gitops webhook's page the projects it hears, beside its applications. History stays the last table on every page that has one.
- A History panel on a unified-api source's page (its last syncs: why and by whom, what each covered, the hosts and groups it brought or why it failed, how long it took) and on a project's page in both apps (its last pulls: why and by whom, the commit each moved the checkout from and to, with links), from the new `history` fields: unified-api 0.37.0 and unified-gitops 0.4.0; an older instance shows none. One `RunHistory` table in `@opusprojects/unified-ui`.
- An Order menu ends every list page's toolbar (both apps): A to Z and Z to A, A to Z the default; on Sources also Fresh to Stale and Stale to Fresh, with worst first (Stale to Fresh) staying its default. The choice is remembered per list in the browser; arrow keys, Enter and Escape work, and on a narrow screen it opens leftwards when it would not fit. `useListFilter` takes the card's name, the orders offered and a key, `ListPage` a `name`, and `ListToolbar` its `orders` (`orderOptions()`, or `orderOptions([good, bad])` for the health ones).

### Changed

- unified-api project page: its Endpoints are a table (Endpoint, Output, Sources ready, State), like its Sources and Connectors, in place of a list of links.
- unified-api credential page: its Projects are a table (Project, Last pull, State), as its Sources above them and a credential's projects in unified-gitops, in place of a list of links.
- Cron schedules read in words, as intervals do: "daily at 04:15 UTC", "every 4h", "every 2h, at :15", "Mon–Fri at 06:00 UTC", "yearly on 1 Jan at 00:00 UTC", the expression on hover (`formatSchedule` and `Schedule` in `@opusprojects/unified-ui`); on a source's card and page and a project's, where a project on a schedule showed nothing on its card. One too irregular to say plainly is shown as written.
- unified-api connector page: its Sources table is the one every other page lists sources with (Source, Hosts, Groups, Data from, State), in place of its own (Source, Timeout, State). A source's own timeout shows on its page.

### Fixed

- unified-api Topology: every card takes one width. Side by side they were matched to the widest only when that fit, and otherwise kept their own widths (one edge narrower than the rest); now the room is shared evenly instead, while each share is at least a card's 360px, what a card holds adapting (fewer chips before "+N more"). Stacked, they stretched to what each level's indent left; now they are one width too.
- A project's Last attempt and Last success (its page and card, both apps) restart when it is pulled, as Data from does after a Sync: they were counted on from the first answer whenever the next one reported the same age, so a Pull seemed not to reset them. The same for an application's Last check (card and tables), the projects on a credential's page, a source's Last success and the last cache save on Configuration.
- Tables size each column from its content's real width, rounded up, and again when that content or the fonts change: a state pill ("Not synced yet" on a connector's sources) could overhang its column by a fraction of a pixel and give the table a horizontal scrollbar on a screen with classic scrollbars.
- unified-api source page: between about 860 and 980px wide the hosts list kept its full width and squeezed the selected host beside it to a sliver, its search and switches overflowing the card. The two now stack until both have room (measured against the page's column, not the window), and side by side the hosts give way first.
- Metrics: the API routes table scrolled sideways at 1280px when a route was long. A table too narrow for its columns now cuts its widest text column short with an ellipsis, the whole value on hover.
- Overview (both apps): its first row of cards filled in one by one as each list arrived, the row reflowing each time. Each card now holds its place as a placeholder of its size while its list loads (`AreaCardSkeleton`); a restricted key gets none for the lists it may not read.
- Counts group thousands with a comma everywhere in both apps, 1,023 rather than 1023: cards, facts, tables, health summaries, the overview, pagination, "+N more", run and sync messages. They followed the browser's language, which in Spanish wrote 1023 and 10.000; one `formatCount` (and `countOf`, "1,023 hosts") in `@opusprojects/unified-ui` now formats them all the same way.

## [0.5.0] - 2026-10-27

### Added
Expand Down
19 changes: 15 additions & 4 deletions apps/unified-api/src/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ export function useSourceList() {
});
}

export function useSources() {
// Every source, each with its detail. `only`, when given, fetches the
// details of those sources alone (the others' rows carry none): a page
// listing three sources need not poll every source's detail, each with its
// history, every 15 seconds. The cache keys are the detail pages', so they
// share what is fetched.
export function useSources(
only?: (summary: { source_id: string; kind: string }) => boolean,
) {
const list = useSourceList();
const wanted = (list.data ?? []).filter((s) => !only || only(s));

const details = useQueries({
queries: (list.data ?? []).map((source) => ({
queries: wanted.map((source) => ({
queryKey: ["source", source.source_id],
queryFn: async () =>
unwrap(
Expand All @@ -47,9 +55,12 @@ export function useSources() {
})),
});

const rows: SourceRow[] = (list.data ?? []).map((summary, index) => ({
const byId = new Map(
wanted.map((source, index) => [source.source_id, details[index]?.data]),
);
const rows: SourceRow[] = (list.data ?? []).map((summary) => ({
summary,
detail: details[index]?.data,
detail: byId.get(summary.source_id),
}));

return { ...list, rows };
Expand Down
41 changes: 41 additions & 0 deletions apps/unified-api/src/api/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,12 @@ export interface components {
/** @description The credential it pulls with, when the repository needs one */
credential_id?: string | null;
git_url: string;
/**
* @description Its last pulls, newest first (up to 50, kept in memory since this
* process started): when, why and by whom, and the commit each moved
* the checkout from and to.
*/
history: components["schemas"]["RunInfo"][];
name: string;
project_id: string;
/** @description The commit the checkout is at (full id); null without a checkout */
Expand Down Expand Up @@ -1227,6 +1233,35 @@ export interface components {
sources: components["schemas"]["DeltaInfo"];
views: components["schemas"]["DeltaInfo"];
};
RunInfo: {
/**
* @description Who asked, for a manual run: the API key's name or the signed-in user.
* Admin keys only.
*/
by?: string | null;
/** Format: int64 */
duration_ms: number;
/** @description Why it failed; absent when it worked */
error?: string | null;
groups?: number | null;
/** @description What a sync that worked brought */
hosts?: number | null;
revision?: string | null;
/** @description The commit a pull found the checkout at, and left it at */
revision_before?: string | null;
/** @description What a sync covered: "full", "host:a,b" or "group:x" */
scope?: string | null;
/**
* Format: int64
* @description When it started, unix seconds
*/
started_at: number;
/**
* @description "scheduled", "manual" (Sync, Pull, the API), "refresh" (an on-demand
* read) or "startup" (the clones at boot, a project added by a reload)
*/
trigger: string;
};
ScopeInfo: {
/**
* @description True when the claim is "everything my inventory dependency knows"
Expand Down Expand Up @@ -1327,6 +1362,12 @@ export interface components {
*/
federated: boolean;
gathering?: components["schemas"]["Gathering"] | null;
/**
* @description Its last syncs, newest first (up to 50, kept in memory since this
* process started): when, why, what each covered and how it ended.
* Empty for a view, which syncs nothing.
*/
history: components["schemas"]["RunInfo"][];
is_fresh: boolean;
/** @description "source" or "view" */
kind: string;
Expand Down
37 changes: 25 additions & 12 deletions apps/unified-api/src/features/config/ConfigPage.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Link } from "react-router";
import {
EmptyState,
LiveAge,
SecretsPanel,
SignInPanels,
Fact,
formatBytes,
formatCount,
formatSpan,
LiveAge,
Notice,
PageHeader,
Panel,
SecretsPanel,
SignInPanels,
SkeletonSummary,
formatBytes,
formatSpan,
} from "@opusprojects/unified-ui";
import { ValueList } from "@opusprojects/unified-ui";
import type { Schemas } from "../../api/client";
Expand Down Expand Up @@ -114,26 +115,38 @@ export function ConfigPage() {
admins.
</EmptyState>
)}
{settings.data && <ServerPanels settings={settings.data} />}
{settings.data && (
<ServerPanels
settings={settings.data}
at={settings.dataUpdatedAt}
/>
)}
<SignIn auth={auth.data} />
</>
)}
</>
);
}

function ServerPanels({ settings }: { settings: Settings }) {
function ServerPanels({
settings,
at,
}: {
settings: Settings;
// When the settings were fetched: the last save restarts on every answer.
at: number;
}) {
const { server, cache, projects, secrets, config_api } = settings;
const projectList = useProjects().data;
const credentialList = useCredentials().data;
const missing = credentialList?.filter((c) => !c.resolves).length ?? 0;
const credentialSummary = !credentialList
? "…"
: missing > 0
? `${missing} of ${credentialList.length} missing`
: `${credentialList.length}, all working`;
? `${formatCount(missing)} of ${formatCount(credentialList.length)} missing`
: `${formatCount(credentialList.length)}, all working`;
const checkouts = projectList
? `${projectList.filter((p) => p.checkout_present).length} of ${projectList.length} on disk`
? `${formatCount(projectList.filter((p) => p.checkout_present).length)} of ${formatCount(projectList.length)} on disk`
: "…";
return (
<>
Expand Down Expand Up @@ -222,9 +235,9 @@ function ServerPanels({ settings }: { settings: Settings }) {
{cache.persistence_path == null ? (
"Never"
) : cache.consecutive_failures > 0 ? (
`Failing, ${cache.consecutive_failures} in a row`
`Failing, ${formatCount(cache.consecutive_failures)} in a row`
) : cache.last_saved_age_seconds != null ? (
<LiveAge seconds={cache.last_saved_age_seconds} />
<LiveAge seconds={cache.last_saved_age_seconds} at={at} />
) : (
"Not yet"
)}
Expand Down
60 changes: 6 additions & 54 deletions apps/unified-api/src/features/connectors/ConnectorDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ import {
Fact,
HealthPill,
LinesView,
ListName,
ListTable,
Notice,
PageHeader,
Panel,
SkeletonSummary,
formatSpan,
type ListColumn,
} from "@opusprojects/unified-ui";
import type { HealthState } from "@opusprojects/unified-client";
import type { Schemas } from "../../api/client";
import { useConnector } from "../../api/queries";
import { DetailTitle, detailStyles as common } from "@opusprojects/unified-ui";
import { ICONS } from "../../sections";
import { SourceTable } from "../../shared/SourceTable";
import {
BUILT_IN,
connectorLabels,
Expand All @@ -32,7 +29,6 @@ import {
} from "./model";

type Connector = Schemas["ConnectorInfo"];
type User = Connector["used_by"][number];

// What each fact means, behind its label, starting with its key in the
// connector's YAML, which is where it is changed.
Expand All @@ -54,7 +50,7 @@ const HINTS: Record<string, string> = {
"Host args":
"host_args. Arguments added when a sync asks for named hosts only (an on-demand refresh).",
Timeout:
"timeout_seconds. How long one sync may run. A source may set its own; the table below shows the one each source syncs under.",
"timeout_seconds. How long one sync may run. A source may set its own, which its page shows.",
};

export function ConnectorDetailPage() {
Expand Down Expand Up @@ -108,7 +104,7 @@ export function ConnectorDetailPage() {
)}
<Panel
title="Sources"
hint="The sources using this connector: their connector names it. Each syncs under its own timeout when it sets one, the connector's otherwise."
hint="The sources using this connector: their connector names it."
>
<UsedBy connector={connector} />
</Panel>
Expand Down Expand Up @@ -240,56 +236,12 @@ function ItemFacts({ connector }: { connector: Connector }) {
);
}

// A source's state as the connector reports it: enough for this table,
// whose rows link to the source's page for the full story.
const userState = (user: User): HealthState =>
user.failing ? "failing" : user.synced ? "fresh" : "pending";

const USER_LABELS = { pending: "Not synced yet" };

// The sources using it, as every other page lists sources.
function UsedBy({ connector }: { connector: Connector }) {
const columns: ListColumn<User>[] = [
{
key: "source",
label: "Source",
role: "name",
title: (u) => u.source_id,
render: (u) => (
<ListName
name={u.name}
link={(className, children) => (
<Link
className={className}
to={`/sources/${encodeURIComponent(u.source_id)}`}
>
{children}
</Link>
)}
id={u.source_id}
/>
),
},
{
key: "timeout",
label: "Timeout",
render: (u) => formatSpan(u.timeout_seconds),
},
{
key: "state",
label: "State",
role: "state",
render: (u) => <HealthPill state={userState(u)} labels={USER_LABELS} />,
},
];
return (
<ListTable
columns={columns}
rows={[...connector.used_by].sort((a, b) =>
a.source_id.localeCompare(b.source_id),
)}
rowKey={(u) => u.source_id}
<SourceTable
ids={connector.used_by.map((u) => u.source_id)}
empty="No source uses this connector."
noun="sources"
/>
);
}
10 changes: 8 additions & 2 deletions apps/unified-api/src/features/connectors/ConnectorsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
HealthSummary,
ListToolbar,
Notice,
orderOptions,
PageHeader,
pageStyles as styles,
ResourceCard,
SkeletonGrid,
SkeletonSummary,
pageStyles as styles,
useRememberedCount,
} from "@opusprojects/unified-ui";
import { useListFilter } from "@opusprojects/unified-client";
Expand Down Expand Up @@ -48,7 +49,11 @@ const searchText = (connector: Connector) =>
export function ConnectorsPage() {
const connectors = useConnectors();
const items = connectors.data ?? [];
const filter = useListFilter(items, connectorState, searchText);
const filter = useListFilter(items, connectorState, searchText, {
name: (c) => c.connector_id,
key: "connectors",
orders: ["az", "za"],
});
const remembered = useRememberedCount(
"connectors",
connectors.isSuccess ? connectors.data?.length : undefined,
Expand Down Expand Up @@ -84,6 +89,7 @@ export function ConnectorsPage() {
/>
<ListToolbar
filter={filter}
orders={orderOptions()}
label="Search connectors"
placeholder="Search by name, type, path, project or source"
/>
Expand Down
3 changes: 2 additions & 1 deletion apps/unified-api/src/features/connectors/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { HealthState } from "@opusprojects/unified-client";
import type { Schemas } from "../../api/client";
import { formatCount } from "@opusprojects/unified-ui";

// How connectors are judged and described, shared by their list, their own
// page and a project's page, so a card and the page it opens never disagree.
Expand Down Expand Up @@ -33,7 +34,7 @@ export function connectorState(connector: Connector): HealthState {
// "1 of 3" beside a failing pill: how much of what it serves is affected.
export const stateDetail = (connector: Connector) =>
connector.health.failing > 0
? `${connector.health.failing} of ${connector.health.sources}`
? `${formatCount(connector.health.failing)} of ${formatCount(connector.health.sources)}`
: undefined;

// What the two built-ins are, in this app's words: they have no script to
Expand Down
Loading
Loading