Skip to content

Commit 0a9668d

Browse files
jdonelsonclaude
andcommitted
console: link freshness rows to workflow, add schema/cluster column
Every object name now links to its workflow graph in Object Explorer. This fixes tables, which opened an empty Maintained Objects drawer. A new column shows each row's schema (by cluster) or cluster (by schema), linking to the page gathered by it. It replaces the namespace line under the name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 971f4cd commit 0a9668d

11 files changed

Lines changed: 309 additions & 68 deletions

‎console/src/platform/clusters/queries.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ describe("buildFreshnessData", () => {
401401
objectName: "orders_mv",
402402
schemaName: "public",
403403
databaseName: "materialize",
404+
schemaId: "u3",
405+
clusterId: "u1",
406+
clusterName: "quickstart",
404407
objectType: "materialized-view",
405408
},
406409
];

‎console/src/platform/clusters/queries.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,11 @@ export function useFreshnessObjectsWhere(
10301030
.map((object): FreshnessObject => ({
10311031
objectId: object.id,
10321032
objectName: object.name,
1033+
schemaId: object.schemaId,
10331034
schemaName: object.schemaName,
10341035
databaseName: object.databaseName,
1036+
clusterId: object.clusterId,
1037+
clusterName: object.clusterName,
10351038
objectType: object.objectType,
10361039
}));
10371040
// JSON keeps a null name apart from an empty one, and no name can break it.
@@ -1049,8 +1052,12 @@ export function useFreshnessObjectsWhere(
10491052
export interface FreshnessObject {
10501053
objectId: string;
10511054
objectName: string | null;
1055+
schemaId: string | null;
10521056
schemaName: string | null;
10531057
databaseName: string | null;
1058+
/** Null for an object that runs on no cluster, such as a table. */
1059+
clusterId: string | null;
1060+
clusterName: string | null;
10541061
objectType: string;
10551062
}
10561063

‎console/src/platform/freshness/FreshnessPage.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {
6767
describeThreshold,
6868
Predicate,
6969
PREDICATE_LABELS,
70+
qualifiedSchemaName,
7071
} from "./freshnessRows";
7172
import { FreshnessTable } from "./FreshnessTable";
7273
import {
@@ -252,7 +253,11 @@ const FreshnessView = ({
252253
All {rows.length} objects are within target.
253254
</Box>
254255
) : (
255-
<FreshnessTable rows={breaching} itemLabel="objects" />
256+
<FreshnessTable
257+
rows={breaching}
258+
scope={scope}
259+
itemLabel="objects"
260+
/>
256261
)}
257262
</AccordionPanel>
258263
</AccordionItem>
@@ -265,7 +270,7 @@ const FreshnessView = ({
265270
No objects with freshness data {SCOPE_LABELS[scope].place}.
266271
</Box>
267272
) : (
268-
<FreshnessTable rows={rows} itemLabel="objects" />
273+
<FreshnessTable rows={rows} scope={scope} itemLabel="objects" />
269274
)}
270275
</AccordionPanel>
271276
</AccordionItem>
@@ -305,16 +310,14 @@ const FreshnessPage = () => {
305310
const thresholdControl = useThresholdControl(threshold, setThreshold);
306311

307312
const scopeLabels = SCOPE_LABELS[scope];
308-
// A schema is named with its database, because every database has its own
309-
// `public` and the bare names would be indistinguishable in the menu.
310313
const options: SelectOption[] = (
311314
scope === "cluster"
312315
? clusters
313316
.filter((c) => !isSystemCluster(c.id))
314317
.map((c) => ({ id: c.id, name: c.name }))
315318
: schemas.map((s) => ({
316319
id: s.id,
317-
name: s.databaseName ? `${s.databaseName}.${s.name}` : s.name,
320+
name: qualifiedSchemaName(s.databaseName, s.name),
318321
}))
319322
).sort((a, b) => a.name.localeCompare(b.name));
320323
const selectedId = scope === "cluster" ? clusterId : schemaId;

‎console/src/platform/freshness/FreshnessTable.test.tsx‎

Lines changed: 105 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ import { describe, expect, it } from "vitest";
1515
import { NULL_LAG_TEXT } from "~/api/materialize/freshness/lagHistory";
1616
import { renderComponent } from "~/test/utils";
1717

18+
import { FreshnessScope } from "./constants";
1819
import { FreshnessRow, UNREADABLE } from "./freshnessRows";
1920
import { FreshnessTable } from "./FreshnessTable";
2021

2122
const buildRow = (overrides: Partial<FreshnessRow>): FreshnessRow => ({
2223
key: "u1",
2324
objectName: "orders_mv",
24-
namespace: "materialize.public",
25+
databaseName: "materialize",
26+
schemaId: "u3",
27+
schemaName: "public",
28+
clusterId: "u1",
29+
clusterName: "quickstart",
2530
objectType: "materialized-view",
2631
hydratedReplicas: 2,
2732
totalReplicas: 2,
@@ -64,15 +69,15 @@ const rows: FreshnessRow[] = [
6469

6570
describe("FreshnessTable", () => {
6671
it("lists every object, over threshold or not", async () => {
67-
await renderComponent(<FreshnessTable rows={rows} />);
72+
await renderComponent(<FreshnessTable rows={rows} scope="cluster" />);
6873

6974
expect(await screen.findByText("orders_mv")).toBeVisible();
7075
expect(screen.getByText("users_idx")).toBeVisible();
7176
expect(screen.getByText("legacy_sink")).toBeVisible();
7277
});
7378

7479
it("marks only the rows drawn on the graph", async () => {
75-
await renderComponent(<FreshnessTable rows={rows} />);
80+
await renderComponent(<FreshnessTable rows={rows} scope="cluster" />);
7681

7782
// The swatch is the only link between a row and its line, so an extra or a
7883
// missing one misattributes.
@@ -84,15 +89,15 @@ describe("FreshnessTable", () => {
8489
});
8590

8691
it("renders a missing reading as a dash rather than a zero", async () => {
87-
await renderComponent(<FreshnessTable rows={rows} />);
92+
await renderComponent(<FreshnessTable rows={rows} scope="cluster" />);
8893

8994
const nullRow = (await screen.findByText("legacy_sink")).closest("tr");
9095
// An object with no reading has not been measured at zero lag.
9196
expect(within(nullRow!).getAllByText("—")).toHaveLength(3);
9297
});
9398

9499
it("labels hydration with the same buckets as the other tables", async () => {
95-
await renderComponent(<FreshnessTable rows={rows} />);
100+
await renderComponent(<FreshnessTable rows={rows} scope="cluster" />);
96101

97102
// Three buckets, not a boolean: "hydrating" is a real state, and collapsing
98103
// it into "not hydrated" would misreport an object that is catching up.
@@ -101,7 +106,7 @@ describe("FreshnessTable", () => {
101106
});
102107

103108
it("sorts on a column when its header is clicked", async () => {
104-
await renderComponent(<FreshnessTable rows={rows} />);
109+
await renderComponent(<FreshnessTable rows={rows} scope="cluster" />);
105110

106111
await userEvent.click(await screen.findByText(/^Object/));
107112
const names = screen
@@ -116,6 +121,7 @@ describe("FreshnessTable", () => {
116121
// the screen.
117122
await renderComponent(
118123
<FreshnessTable
124+
scope="cluster"
119125
rows={[
120126
buildRow({
121127
key: "u9",
@@ -135,19 +141,37 @@ describe("FreshnessTable", () => {
135141
expect(screen.queryByText(/∞|Infinity/)).not.toBeInTheDocument();
136142
});
137143

138-
it("links each object to its detail drawer", async () => {
139-
await renderComponent(<FreshnessTable rows={rows} />);
144+
it("links every type the page shows to its workflow graph", async () => {
145+
// Tables included: they appear by schema, and the Maintained Objects
146+
// drawer has nothing to show for one.
147+
const typed = [
148+
buildRow({ key: "u1", objectName: "t", objectType: "table" }),
149+
buildRow({ key: "u2", objectName: "s", objectType: "source" }),
150+
buildRow({ key: "u3", objectName: "m", objectType: "materialized-view" }),
151+
buildRow({ key: "u4", objectName: "i", objectType: "index" }),
152+
buildRow({ key: "u5", objectName: "k", objectType: "sink" }),
153+
];
154+
await renderComponent(<FreshnessTable rows={typed} scope="cluster" />);
140155

141-
const link = await screen.findByRole("link", { name: "orders_mv" });
142-
// A link rather than a row handler, so it is reachable without a mouse.
143-
expect(link).toHaveAttribute(
144-
"href",
145-
expect.stringContaining("/maintained-objects/u1"),
156+
const hrefs = await Promise.all(
157+
typed.map(async (row) =>
158+
(await screen.findByRole("link", { name: row.objectName }))
159+
.getAttribute("href")
160+
?.replace(/^.*\/objects\//, ""),
161+
),
146162
);
163+
// A link rather than a row handler, so it is reachable without a mouse.
164+
expect(hrefs).toEqual([
165+
"materialize/schemas/public/tables/t/u1/workflow",
166+
"materialize/schemas/public/sources/s/u2/workflow",
167+
"materialize/schemas/public/materialized-views/m/u3/workflow",
168+
"materialize/schemas/public/indexes/i/u4/workflow",
169+
"materialize/schemas/public/sinks/k/u5/workflow",
170+
]);
147171
});
148172

149173
it("opens sorted worst first", async () => {
150-
await renderComponent(<FreshnessTable rows={rows} />);
174+
await renderComponent(<FreshnessTable rows={rows} scope="cluster" />);
151175

152176
await screen.findByText("orders_mv");
153177
const names = screen
@@ -168,11 +192,77 @@ describe("FreshnessTable", () => {
168192
peak: 1_000 + i,
169193
}),
170194
);
171-
await renderComponent(<FreshnessTable rows={many} />);
195+
await renderComponent(<FreshnessTable rows={many} scope="cluster" />);
172196

173197
await screen.findByText("object_00");
174198
// 25 rows plus the header.
175199
expect(screen.getAllByRole("row")).toHaveLength(26);
176200
expect(screen.queryByText("object_59")).not.toBeInTheDocument();
177201
});
178202
});
203+
204+
describe("FreshnessTable placement column", () => {
205+
const renderAt = (
206+
scope: FreshnessScope,
207+
search: string,
208+
tableRows: FreshnessRow[],
209+
) =>
210+
renderComponent(<FreshnessTable rows={tableRows} scope={scope} />, {
211+
initialRouterEntries: [search],
212+
});
213+
const searchOf = (link: HTMLElement) =>
214+
new URLSearchParams(link.getAttribute("href")?.split("?")[1]);
215+
216+
it("by cluster, shows each object's schema, linking to that schema", async () => {
217+
await renderAt("cluster", "/?cluster=u1&threshold=5000&type=index,sink", [
218+
buildRow({}),
219+
]);
220+
221+
expect(
222+
await screen.findByRole("columnheader", { name: "Schema" }),
223+
).toBeVisible();
224+
// Once, in its column: the line that used to repeat it under the name is
225+
// gone.
226+
expect(screen.getAllByText("materialize.public")).toHaveLength(1);
227+
const search = searchOf(
228+
screen.getByRole("link", { name: "materialize.public" }),
229+
);
230+
expect(search.get("scope")).toBe("schema");
231+
expect(search.get("schema")).toBe("u3");
232+
expect(search.get("cluster")).toBeNull();
233+
// The reader's other controls survive the jump.
234+
expect(search.get("threshold")).toBe("5000");
235+
expect(search.get("type")).toBe("index,sink");
236+
});
237+
238+
it("by schema, shows each object's cluster, linking to that cluster", async () => {
239+
await renderAt("schema", "/?scope=schema&schema=u3&type=table,index", [
240+
buildRow({}),
241+
]);
242+
243+
expect(
244+
await screen.findByRole("columnheader", { name: "Cluster" }),
245+
).toBeVisible();
246+
const search = searchOf(screen.getByRole("link", { name: "quickstart" }));
247+
expect(search.get("scope")).toBe("cluster");
248+
expect(search.get("cluster")).toBe("u1");
249+
expect(search.get("schema")).toBeNull();
250+
// A cluster never holds a table, so that filter cannot follow.
251+
expect(search.get("type")).toBe("index");
252+
});
253+
254+
it("by schema, shows no cluster for a table", async () => {
255+
await renderAt("schema", "/?scope=schema&schema=u3", [
256+
buildRow({
257+
objectName: "orders",
258+
objectType: "table",
259+
clusterId: null,
260+
clusterName: null,
261+
}),
262+
]);
263+
264+
const row = (await screen.findByText("orders")).closest("tr");
265+
expect(within(row!).getAllByRole("link")).toHaveLength(1);
266+
expect(within(row!).getAllByText("—").length).toBeGreaterThan(0);
267+
});
268+
});

0 commit comments

Comments
 (0)