Skip to content

Commit eefd5fe

Browse files
committed
feat(studio): real admin overview from /admin/graphql (EBE-108 phase 1)
AdminScreen showed placeholder/empty cards. Now real data: - useAdminInfo queries /admin/graphql worker_health + users + system_carrier_ connections in one call → users count, system-connections count, worker status. - AdminScreen: Version (from /v1/references), License, Users, System connections, and a live Background-worker availability pill. Live-verified (worker available, users=1). govern+render-smoke 36/36; tsc/build clean. NOTE: deeper admin/platform CRUD (user management, configs editor, markups/fees, permission groups, task executions) remains as follow-up depth on EBE-108.
1 parent c3be85b commit eefd5fe

3 files changed

Lines changed: 39 additions & 12 deletions

File tree

apps/studio/src/lib/karrio/hooks/govern.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,34 @@ export function useTeam() {
5050
}
5151

5252
// --- Admin overview (ADMIN GraphQL `worker_health`) -------------------------
53-
const WORKER_HEALTH_QUERY = `query { worker_health { is_available } }`;
53+
const ADMIN_OVERVIEW_QUERY = `query {
54+
worker_health { is_available }
55+
users { edges { node { id } } }
56+
system_carrier_connections { edges { node { id active } } }
57+
}`;
58+
59+
type AdminOverviewRaw = {
60+
worker_health?: { is_available?: boolean };
61+
users?: { edges: Array<{ node: { id: string } }> };
62+
system_carrier_connections?: { edges: Array<{ node: { id: string; active?: boolean } }> };
63+
};
5464

5565
export function useAdminInfo() {
5666
const ctx = useKarrioCtx();
5767
return useQuery({
5868
queryKey: ["admin-info", keyExtra(ctx)],
5969
queryFn: async (): Promise<AdminInfo> => {
60-
const data = await adminGraphql<{ worker_health?: { is_available?: boolean } }>(
61-
ctx,
62-
WORKER_HEALTH_QUERY,
63-
);
64-
const health = data.worker_health;
70+
const data = await adminGraphql<AdminOverviewRaw>(ctx, ADMIN_OVERVIEW_QUERY);
71+
const available = data.worker_health?.is_available;
72+
const conns = data.system_carrier_connections?.edges ?? [];
6573
return {
6674
license: "Open Source",
67-
runtimes: health
68-
? [{ name: "Background worker", memory: health.is_available ? "available" : "unavailable" }]
69-
: [],
75+
users: data.users?.edges?.length ?? 0,
76+
system_connections: conns.length,
77+
worker_available: available,
78+
runtimes: [
79+
{ name: "Background worker", memory: available ? "available" : available === false ? "unavailable" : "—" },
80+
],
7081
resources: [],
7182
};
7283
},

apps/studio/src/lib/karrio/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ export type AdminInfo = {
273273
version?: string;
274274
tenants?: number;
275275
license?: string;
276+
users?: number;
277+
system_connections?: number;
278+
worker_available?: boolean;
276279
resources?: { label: string; used: number; total: number }[];
277280
runtimes?: { name: string; memory?: string; calls?: number; p99?: string }[];
278281
};

apps/studio/src/screens/govern/AdminScreen.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
// AdminScreen.tsx — Govern › Overview (E1).
1+
// AdminScreen.tsx — Govern › Overview (E1). Real admin data via /admin/graphql
2+
// (worker health, users, system connections) + version from references.
23
import { useMemo } from "react";
34
import { PageHeader } from "~/components/ui/primitives";
45
import { useAdminInfo } from "~/lib/karrio/hooks";
6+
import { useReferences } from "~/lib/karrio/references";
57

68
export function AdminScreen() {
79
const { data } = useAdminInfo();
10+
const { data: refs } = useReferences();
811
const info = data ?? {};
912
const resources = useMemo(() => info.resources ?? [], [info]);
1013
const runtimes = useMemo(() => info.runtimes ?? [], [info]);
14+
const version = (refs?.VERSION as string) ?? info.version;
1115

1216
return (
1317
<div className="page" data-testid="screen-admin">
1418
<PageHeader title="Overview" />
1519
<div className="stat-grid" data-testid="admin-cards">
16-
<div className="stat-card"><div className="kvstat-label">Version</div><div className="kvstat-value mono">{info.version ?? "—"}</div></div>
17-
<div className="stat-card"><div className="kvstat-label">Tenants</div><div className="kvstat-value">{info.tenants ?? "—"}</div></div>
20+
<div className="stat-card"><div className="kvstat-label">Version</div><div className="kvstat-value mono">{version ?? "—"}</div></div>
1821
<div className="stat-card"><div className="kvstat-label">License</div><div className="kvstat-value">{info.license ?? "—"}</div></div>
22+
<div className="stat-card" data-testid="admin-users"><div className="kvstat-label">Users</div><div className="kvstat-value">{info.users ?? "—"}</div></div>
23+
<div className="stat-card" data-testid="admin-system-connections"><div className="kvstat-label">System connections</div><div className="kvstat-value">{info.system_connections ?? "—"}</div></div>
24+
<div className="stat-card" data-testid="admin-worker">
25+
<div className="kvstat-label">Background worker</div>
26+
<div className="kvstat-value">
27+
<span className={"pill " + (info.worker_available ? "delivered" : info.worker_available === false ? "cancelled" : "draft")}>
28+
{info.worker_available ? "available" : info.worker_available === false ? "down" : "—"}
29+
</span>
30+
</div>
31+
</div>
1932
</div>
2033

2134
<div className="card" style={{ padding: 16, marginBottom: 16 }}>

0 commit comments

Comments
 (0)