From c004be3b128878b85b87288d98f4446375304c11 Mon Sep 17 00:00:00 2001 From: mawkone Date: Sun, 14 Jun 2026 14:11:14 -0700 Subject: [PATCH] fix(databases): align database tree styles with codebase tree --- .../project/database-table-tree.tsx | 185 +++++++++++++----- 1 file changed, 137 insertions(+), 48 deletions(-) diff --git a/vibn-frontend/components/project/database-table-tree.tsx b/vibn-frontend/components/project/database-table-tree.tsx index 9e7f2baf..36d21bce 100644 --- a/vibn-frontend/components/project/database-table-tree.tsx +++ b/vibn-frontend/components/project/database-table-tree.tsx @@ -11,7 +11,16 @@ */ import { useEffect, useState } from "react"; -import { Table, ChevronDown, ChevronRight, Loader2, AlertCircle, Info } from "lucide-react"; +import { + Table, + ChevronDown, + ChevronRight, + Loader2, + AlertCircle, + Info, + Database, +} from "lucide-react"; +import { THEME } from "@/components/project/dashboard-ui"; interface IntrospectedTable { schema: string; @@ -34,7 +43,10 @@ interface Props { } export function DatabaseTableTree({ - projectId, dbUuid, selectedTable, onSelectTable, + projectId, + dbUuid, + selectedTable, + onSelectTable, }: Props) { const [data, setData] = useState(null); const [error, setError] = useState(null); @@ -48,38 +60,54 @@ export function DatabaseTableTree({ setError(null); fetch(`/api/projects/${projectId}/databases/${dbUuid}/tables`, { - credentials: "include", signal: ctrl.signal, + credentials: "include", + signal: ctrl.signal, }) - .then(async r => { + .then(async (r) => { let body: unknown = {}; - try { body = await r.json(); } catch {/* keep {} */} + try { + body = await r.json(); + } catch { + /* keep {} */ + } if (!r.ok) { - throw new Error((body as { error?: string }).error || `HTTP ${r.status}`); + throw new Error( + (body as { error?: string }).error || `HTTP ${r.status}`, + ); } return body as ApiResp; }) - .then(d => { if (!cancelled) setData(d); }) - .catch(err => { + .then((d) => { + if (!cancelled) setData(d); + }) + .catch((err) => { if (cancelled) return; if (err?.name === "AbortError") setError("Timed out after 12s."); else setError(err?.message || "Failed to list tables"); }) - .finally(() => { clearTimeout(t); if (!cancelled) setLoading(false); }); + .finally(() => { + clearTimeout(t); + if (!cancelled) setLoading(false); + }); - return () => { cancelled = true; ctrl.abort(); clearTimeout(t); }; + return () => { + cancelled = true; + ctrl.abort(); + clearTimeout(t); + }; }, [projectId, dbUuid]); if (loading) { return (
- Inspecting database… + Inspecting database…
); } if (error) { return (
- {error} + {error}
); } @@ -88,9 +116,9 @@ export function DatabaseTableTree({ if (data.unsupported) { return (
- - Table inspection isn't wired up for {data.engine} yet — Postgres - is the only engine supported today. + + Table inspection isn't wired up for {data.engine} yet — Postgres is the + only engine supported today.
); } @@ -98,7 +126,7 @@ export function DatabaseTableTree({ if (data.tables.length === 0) { return (
- + No user-tables found. (Pre-deploy databases often start empty.)
); @@ -114,7 +142,7 @@ export function DatabaseTableTree({ return (
- {schemas.map(schema => ( + {schemas.map((schema) => ( - {tables.map(t => { - const active = selectedTable?.schema === t.schema && selectedTable?.name === t.name; + {tables.map((t) => { + const active = + selectedTable?.schema === t.schema && selectedTable?.name === t.name; return (