Skip to content

Commit c24c4f6

Browse files
NicolappsConvex, Inc.
authored andcommitted
Split “Schema and Indexes” into two panels (#39350)
GitOrigin-RevId: 9c11c8104f45e3301bb59653a122ea6dce3ed5db
1 parent 9ebe8ef commit c24c4f6

File tree

14 files changed

+190
-116
lines changed

14 files changed

+190
-116
lines changed

npm-packages/convex/src/cli/lib/indexes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function setSchemaProgressSpinner(
208208
if (index.backfill.state === "in_progress") {
209209
const dashboardUrl = deploymentDashboardUrlPage(
210210
deploymentName,
211-
`/data?table=${index.table}&showSchemaAndIndexes=true`,
211+
`/data?table=${index.table}&showIndexes=true`,
212212
);
213213
msg = `Backfilling index ${index.name} (${indexesCompleted}/${numIndexes} ready), \
214214
see progress on the dashboard here: ${dashboardUrl}`;

npm-packages/dashboard-common/src/features/data/components/DataContent.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,20 @@ export function DataContent({
179179
});
180180
const { popupEl } = popupState;
181181

182-
// Handle query parameter to open schema popup
182+
// Handle query parameter to open the indexes panel
183183
useEffect(() => {
184-
if (!!router.query.showSchemaAndIndexes && !popupState.popup) {
185-
popupState.setPopup({ type: "viewSchema", tableName });
184+
if (!!router.query.showIndexes && !popupState.popup) {
185+
popupState.setPopup({ type: "viewIndexes", tableName });
186186
void router.push(
187187
{
188188
pathname: router.pathname,
189-
query: omit(router.query, "showSchemaAndIndexes"),
189+
query: omit(router.query, "showIndexes"),
190190
},
191191
undefined,
192192
{ shallow: true },
193193
);
194194
}
195-
}, [router.query.showSchemaAndIndexes, router, popupState, tableName]);
195+
}, [router.query.showIndexes, router, popupState, tableName]);
196196

197197
const selectedDocumentId = rowsThatAreSelected.values().next().value;
198198
const selectedDocument = data.find((row) => row._id === selectedDocumentId);

npm-packages/dashboard-common/src/features/data/components/DataOverflowMenu/DataOverflowMenu.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { BackspaceIcon } from "@heroicons/react/24/outline";
1+
import { BackspaceIcon, FingerPrintIcon } from "@heroicons/react/24/outline";
22
import {
33
BarChartIcon,
44
TrashIcon,
55
DotsVerticalIcon,
66
CodeIcon,
7-
CardStackIcon,
7+
CubeIcon,
88
} from "@radix-ui/react-icons";
99
import { useContext } from "react";
1010
import { DeploymentInfoContext } from "@common/lib/deploymentContext";
@@ -17,15 +17,17 @@ export function DataOverflowMenu({
1717
numRows,
1818
onClickCustomQuery,
1919
onClickClearTable,
20-
onClickSchemaIndexes,
20+
onClickSchema,
21+
onClickIndexes,
2122
onClickMetrics,
2223
onClickDeleteTable,
2324
}: {
2425
tableSchemaStatus: TableSchemaStatus | undefined;
2526
numRows: number;
2627
onClickCustomQuery: () => void;
2728
onClickClearTable: () => void;
28-
onClickSchemaIndexes: () => void;
29+
onClickSchema: () => void;
30+
onClickIndexes: () => void;
2931
onClickMetrics: () => void;
3032
onClickDeleteTable: () => void;
3133
}) {
@@ -62,9 +64,13 @@ export function DataOverflowMenu({
6264
<CodeIcon />
6365
Custom query
6466
</MenuItem>
65-
<MenuItem action={onClickSchemaIndexes}>
66-
<CardStackIcon />
67-
Schema and Indexes
67+
<MenuItem action={onClickSchema}>
68+
<CubeIcon />
69+
Schema
70+
</MenuItem>
71+
<MenuItem action={onClickIndexes}>
72+
<FingerPrintIcon className="size-4" />
73+
Indexes
6874
</MenuItem>
6975
<MenuItem action={onClickMetrics}>
7076
<BarChartIcon />

npm-packages/dashboard-common/src/features/data/components/DataPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function DataPanel({
3434
<ClosePanelButton onClose={onClose} className="ml-auto" />
3535
</div>
3636
</div>
37-
{children}
37+
<div className="flex grow flex-col overflow-y-auto">{children}</div>
3838
</div>
3939
</div>
4040
</Panel>

npm-packages/dashboard-common/src/features/data/components/DataSidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CodeIcon, MagnifyingGlassIcon, PlusIcon } from "@radix-ui/react-icons";
1+
import { CubeIcon, MagnifyingGlassIcon, PlusIcon } from "@radix-ui/react-icons";
22
import { useMutation } from "convex/react";
33
import classNames from "classnames";
44
import { useContext, useState } from "react";
@@ -92,7 +92,7 @@ export function DataSidebar({
9292
<Button
9393
variant="neutral"
9494
onClick={showSchema.showSchema}
95-
icon={<CodeIcon />}
95+
icon={<CubeIcon />}
9696
className="animate-fadeInFromLoading overflow-hidden"
9797
>
9898
<span className="truncate">Schema</span>

npm-packages/dashboard-common/src/features/data/components/DataToolbar/DataToolbar.test.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,34 @@ describe("DataToolbar", () => {
195195
expect(saveButton).toBeDefined();
196196
});
197197

198-
it("should open the indexes panel", async () => {
198+
it("should open the schema panel", async () => {
199199
setup();
200200
const menuButton = await screen.findByLabelText("Open table settings");
201201
const user = userEvent.setup();
202202
await user.click(menuButton);
203203

204-
const indexes = await screen.findByText(`Schema and Indexes`);
204+
const indexes = await screen.findByText("Schema");
205205
expect(indexes).toBeEnabled();
206206

207207
await user.click(indexes);
208208

209209
await screen.findByText("Schema for table");
210210
});
211211

212+
it("should open the indexes panel", async () => {
213+
setup();
214+
const menuButton = await screen.findByLabelText("Open table settings");
215+
const user = userEvent.setup();
216+
await user.click(menuButton);
217+
218+
const indexes = await screen.findByText("Indexes");
219+
expect(indexes).toBeEnabled();
220+
221+
await user.click(indexes);
222+
223+
await screen.findByText("Indexes for table");
224+
});
225+
212226
it("should open the metrics chart", async () => {
213227
setup();
214228
const menuButton = await screen.findByLabelText("Open table settings");

npm-packages/dashboard-common/src/features/data/components/DataToolbar/DataToolbar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,18 @@ export function DataToolbar({
173173
});
174174
setPopup({ type: "clearTable", tableName });
175175
}}
176-
onClickSchemaIndexes={() => {
176+
onClickSchema={() => {
177177
log("view table schema", {
178178
how: "toolbar",
179179
});
180180
setPopup({ type: "viewSchema", tableName });
181181
}}
182+
onClickIndexes={() => {
183+
log("view table indexes", {
184+
how: "toolbar",
185+
});
186+
setPopup({ type: "viewIndexes", tableName });
187+
}}
182188
onClickMetrics={() => {
183189
log("view table metrics", {
184190
how: "toolbar",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Link from "next/link";
2+
import { ExternalLinkIcon } from "@radix-ui/react-icons";
3+
4+
export function LearnMoreLink({ name, link }: { name: string; link: string }) {
5+
return (
6+
<div className="mb-2 px-4 text-xs text-content-primary sm:px-6">
7+
Learn more about{" "}
8+
<Link
9+
passHref
10+
href={link}
11+
className="inline-flex items-center text-content-link"
12+
target="_blank"
13+
>
14+
{name}
15+
<ExternalLinkIcon className="ml-0.5 h-3 w-3" />
16+
</Link>
17+
</div>
18+
);
19+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { DataPanel } from "@common/features/data/components/DataPanel";
2+
import { ConvexSchemaFilePath } from "@common/features/data/components/ConvexSchemaFilePath";
3+
import { Loading } from "@ui/Loading";
4+
import { useSingleTableSchemaStatus } from "./TableSchema";
5+
import { IndexList } from "./IndexList";
6+
import { LearnMoreLink } from "./LearnMoreLink";
7+
8+
export function TableIndexesPanel({
9+
tableName,
10+
onClose,
11+
}: {
12+
tableName: string;
13+
onClose: () => void;
14+
}) {
15+
return (
16+
<DataPanel
17+
title={
18+
<>
19+
Indexes for table{" "}
20+
<span className="font-mono text-[1.0625rem]">{tableName}</span>
21+
</>
22+
}
23+
onClose={onClose}
24+
>
25+
<IndexBody tableName={tableName} />
26+
</DataPanel>
27+
);
28+
}
29+
30+
function IndexBody({ tableName }: { tableName: string }) {
31+
const tableSchemaStatus = useSingleTableSchemaStatus(tableName);
32+
if (tableSchemaStatus === undefined) {
33+
return <Loading />;
34+
}
35+
36+
return (
37+
<>
38+
<LearnMoreLink
39+
name="indexes"
40+
link="https://docs.convex.dev/database/indexes"
41+
/>
42+
<div className="px-4 sm:px-6">
43+
{tableSchemaStatus.isDefined ? (
44+
<IndexList tableName={tableName} />
45+
) : (
46+
<>
47+
Once you add your table to your <ConvexSchemaFilePath /> file,
48+
you’ll be able to see any indexes you’ve defined here.
49+
</>
50+
)}
51+
</div>
52+
</>
53+
);
54+
}

npm-packages/dashboard-common/src/features/data/components/TableSchemaAndIndexes.tsx

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)