Skip to content
Merged
Changes from 1 commit
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
55 changes: 37 additions & 18 deletions ui/src/routes/tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,46 @@ function Tables() {
</Card>
);

const tab = table
? data.tables.findIndex(({ name }) => name === table).toString()
: "0";
const requestedTableMissing =
!!table && !data.tables.some(({ name }) => name === table);

const tab = (() => {
if (!table) return "0";
const index = data.tables.findIndex(({ name }) => name === table);
return (index >= 0 ? index : 0).toString();
})();

Comment thread
Esubaalew marked this conversation as resolved.
Outdated
return (
<Tabs defaultValue={tab}>
<TabsList>
{data.tables.map((n, i) => (
<TabsTrigger key={i} value={i.toString()}>
<Link to="/tables" search={{ table: n.name }}>
{n.name} [{n.count.toLocaleString()}]
</Link>
</TabsTrigger>
<>
{requestedTableMissing && (
<Card className="mb-3">
<CardHeader>
<CardTitle>Table not found</CardTitle>
<CardDescription>
Could not find "{table}". Showing the first available table
instead.
</CardDescription>
</CardHeader>
</Card>
)}
Comment thread
Esubaalew marked this conversation as resolved.

<Tabs defaultValue={tab}>
Comment thread
Esubaalew marked this conversation as resolved.
Outdated
<TabsList>
{data.tables.map((n, i) => (
<TabsTrigger key={i} value={i.toString()}>
<Link to="/tables" search={{ table: n.name }}>
{n.name} [{n.count.toLocaleString()}]
</Link>
</TabsTrigger>
))}
</TabsList>
{data.tables.map(({ name }, i) => (
<TabsContent key={i} value={i.toString()} className="py-4">
<Table name={name} />
</TabsContent>
))}
</TabsList>
{data.tables.map(({ name }, i) => (
<TabsContent key={i} value={i.toString()} className="py-4">
<Table name={name} />
</TabsContent>
))}
</Tabs>
</Tabs>
</>
);
}

Expand Down
Loading