From 50ba9a98a5fc07821e8faa7a1b141215c2171d41 Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Sun, 15 Nov 2026 07:14:50 +0300 Subject: [PATCH] feat(ui): Querya workspace chrome core with mock demo path Park SQL as a secondary home tab. Sidebar matches Flutter (expand tree, context Create, no permanent CTA stack). Clicking a table opens Data | Relations with an immediate grid from the offline demo catalog. --- apps/tauri/README.md | 2 +- apps/tauri/src/App.vue | 57 +--- apps/tauri/src/mock/demoCatalog.ts | 101 ++++++ apps/tauri/src/stores/connections.ts | 89 ++++- apps/tauri/src/stores/objectTree.ts | 46 ++- apps/tauri/src/stores/queryResult.ts | 68 +++- apps/tauri/src/stores/shellNav.ts | 83 +++++ apps/tauri/src/ui/ConnectionHome.vue | 277 +++++++++++++++ apps/tauri/src/ui/ConnectionsPanel.vue | 407 ++++++++++++++++++----- apps/tauri/src/ui/SqlWorkspace.vue | 17 +- apps/tauri/src/ui/SqliteObjectTree.vue | 255 -------------- apps/tauri/src/ui/TableObjectView.vue | 266 +++++++++++++++ apps/tauri/src/ui/WorkspaceEmptyHero.vue | 34 +- 13 files changed, 1250 insertions(+), 452 deletions(-) create mode 100644 apps/tauri/src/mock/demoCatalog.ts create mode 100644 apps/tauri/src/stores/shellNav.ts create mode 100644 apps/tauri/src/ui/ConnectionHome.vue delete mode 100644 apps/tauri/src/ui/SqliteObjectTree.vue create mode 100644 apps/tauri/src/ui/TableObjectView.vue diff --git a/apps/tauri/README.md b/apps/tauri/README.md index 1537b511..2abc8da5 100644 --- a/apps/tauri/README.md +++ b/apps/tauri/README.md @@ -54,7 +54,7 @@ pnpm install pnpm tauri dev ``` -You should get the shell chrome and an `app_info` status line. **Open SQLite…** uses the native file dialog and `db_connect_sqlite` IPC (live connection list in the sidebar). +UI-core first: empty hero → **Demo** (offline catalog) or Open SQLite → connection **Overview** → click a table for **Data** grid. SQL is parked on the connection home SQL tab. Live DB commands remain for later slices. ### Scripts diff --git a/apps/tauri/src/App.vue b/apps/tauri/src/App.vue index e907f954..c172a445 100644 --- a/apps/tauri/src/App.vue +++ b/apps/tauri/src/App.vue @@ -5,30 +5,28 @@ import { open } from "@tauri-apps/plugin-dialog"; import { storeToRefs } from "pinia"; import { useShellStore } from "./stores/shell"; import { useShellStatusStore } from "./stores/shellStatus"; -import { useWorkspaceStore } from "./stores/workspace"; import { useConnectionsStore } from "./stores/connections"; +import { useShellNavStore } from "./stores/shellNav"; import { initTheme } from "./theme/queryaTheme"; import { provideQueryaMotion } from "./motion"; import TitleBar from "./ui/TitleBar.vue"; import ConnectionsPanel from "./ui/ConnectionsPanel.vue"; -import TabStrip from "./ui/TabStrip.vue"; import StatusBar from "./ui/StatusBar.vue"; import WorkspaceEmptyHero from "./ui/WorkspaceEmptyHero.vue"; import QueryaDivider from "./ui/QueryaDivider.vue"; -import SqlWorkspace from "./ui/SqlWorkspace.vue"; +import ConnectionHome from "./ui/ConnectionHome.vue"; +import TableObjectView from "./ui/TableObjectView.vue"; const shell = useShellStore(); const status = useShellStatusStore(); -const workspace = useWorkspaceStore(); const connections = useConnectionsStore(); -const { activeTab } = storeToRefs(workspace); +const nav = useShellNavStore(); +const { surface } = storeToRefs(nav); provideQueryaMotion(); -const showEmpty = computed( - () => !connections.active && activeTab.value?.kind === "welcome", -); - -const showSql = computed(() => activeTab.value?.kind === "sql"); +const showEmpty = computed(() => surface.value === "empty"); +const showHome = computed(() => surface.value === "connectionHome"); +const showTable = computed(() => surface.value === "tableObject"); async function onOpenSqlite() { try { @@ -42,8 +40,7 @@ async function onOpenSqlite() { ], }); if (!selected || Array.isArray(selected)) return; - const conn = await connections.connectSqlite(selected); - workspace.addTab({ title: conn.name, kind: "sql" }); + await connections.connectSqlite(selected); } catch (err) { if (String(err).includes("cancel")) return; } @@ -51,11 +48,15 @@ async function onOpenSqlite() { function onNewConnection() { status.setQueryMetrics({ - message: "Connection form will land with keyring/profiles", + message: "Connection form UI next — use Demo or Open SQLite for now", busy: false, }); } +function onLaunchDemo() { + connections.launchDemo(); +} + function onOpenTour() { status.setQueryMetrics({ message: "Tour stub", busy: false }); } @@ -80,7 +81,7 @@ onMounted(async () => { os?: string; }>("app_info"); status.setQueryMetrics({ - message: `${info.name} ${info.version} · ${info.stack}${info.os ? ` · ${info.os}` : ""}`, + message: `${info.name} ${info.version} · UI core · ${info.stack}${info.os ? ` · ${info.os}` : ""}`, }); } catch { status.setQueryMetrics({ message: "IPC unavailable" }); @@ -104,21 +105,16 @@ onUnmounted(() => { @new-connection="onNewConnection" />
-
- -
-

{{ activeTab?.title }}

-

- Connected: {{ connections.active.path }} -

-
+ +
@@ -160,21 +156,4 @@ onUnmounted(() => { display: flex; flex-direction: column; } - -.tab-placeholder { - height: 100%; - display: grid; - place-content: center; - justify-items: center; - gap: var(--q-space-2); - padding: var(--q-space-8); - text-align: center; - color: var(--q-muted-foreground); -} - -.tab-placeholder h2 { - margin: 0; - color: var(--q-foreground); - font-size: var(--q-text-lg); -} diff --git a/apps/tauri/src/mock/demoCatalog.ts b/apps/tauri/src/mock/demoCatalog.ts new file mode 100644 index 00000000..a2508032 --- /dev/null +++ b/apps/tauri/src/mock/demoCatalog.ts @@ -0,0 +1,101 @@ +/** Offline demo catalog for UI-core review (no live DB). */ + +export type DemoColumn = { + name: string; + data_type: string; + is_primary_key: boolean; + is_nullable: boolean; +}; + +export type DemoObject = { + name: string; + kind: "table" | "view"; + columns: DemoColumn[]; + rows: unknown[][]; +}; + +export type DemoConnection = { + id: string; + name: string; + driver: "sqlite"; + path: string; + objects: DemoObject[]; +}; + +const users: DemoObject = { + name: "users", + kind: "table", + columns: [ + { name: "id", data_type: "INTEGER", is_primary_key: true, is_nullable: false }, + { name: "username", data_type: "TEXT", is_primary_key: false, is_nullable: false }, + { name: "email", data_type: "TEXT", is_primary_key: false, is_nullable: false }, + { name: "full_name", data_type: "TEXT", is_primary_key: false, is_nullable: true }, + { name: "city", data_type: "TEXT", is_primary_key: false, is_nullable: true }, + { name: "is_active", data_type: "INTEGER", is_primary_key: false, is_nullable: false }, + { name: "created_at", data_type: "DATETIME", is_primary_key: false, is_nullable: false }, + ], + rows: [ + [1, "ada", "ada@ex.com", "Ada Lovelace", "London", 1, "2024-01-02 10:00:00"], + [2, "bob", "bob@ex.com", "Bob Builder", "Berlin", 1, "2024-02-11 12:30:00"], + [3, "cara", "cara@ex.com", null, "Oslo", 0, "2024-03-05 09:15:00"], + [4, "dan", "dan@ex.com", "Dan Park", "Tokyo", 1, "2024-04-18 18:45:00"], + [5, "eve", "eve@ex.com", "Eve North", "Seoul", 1, "2024-05-01 08:00:00"], + ], +}; + +const products: DemoObject = { + name: "products", + kind: "table", + columns: [ + { name: "id", data_type: "INTEGER", is_primary_key: true, is_nullable: false }, + { name: "sku", data_type: "TEXT", is_primary_key: false, is_nullable: false }, + { name: "title", data_type: "TEXT", is_primary_key: false, is_nullable: false }, + { name: "price", data_type: "REAL", is_primary_key: false, is_nullable: false }, + ], + rows: [ + [10, "SKU-1", "Notebook", 12.5], + [11, "SKU-2", "Pen set", 4.2], + [12, "SKU-3", "Desk lamp", 39.0], + ], +}; + +const orders: DemoObject = { + name: "orders", + kind: "table", + columns: [ + { name: "id", data_type: "INTEGER", is_primary_key: true, is_nullable: false }, + { name: "user_id", data_type: "INTEGER", is_primary_key: false, is_nullable: false }, + { name: "total", data_type: "REAL", is_primary_key: false, is_nullable: false }, + { name: "status", data_type: "TEXT", is_primary_key: false, is_nullable: false }, + ], + rows: [ + [100, 1, 44.5, "paid"], + [101, 2, 12.5, "pending"], + [102, 1, 39.0, "paid"], + ], +}; + +const customerSpending: DemoObject = { + name: "customer_spending", + kind: "view", + columns: [ + { name: "username", data_type: "TEXT", is_primary_key: false, is_nullable: false }, + { name: "spent", data_type: "REAL", is_primary_key: false, is_nullable: false }, + ], + rows: [ + ["ada", 83.5], + ["bob", 12.5], + ], +}; + +export const DEMO_CONNECTION: DemoConnection = { + id: "demo-sqlite", + name: "Demo SQLite", + driver: "sqlite", + path: "mock://demo", + objects: [users, products, orders, customerSpending], +}; + +export function findDemoObject(name: string): DemoObject | undefined { + return DEMO_CONNECTION.objects.find((o) => o.name === name); +} diff --git a/apps/tauri/src/stores/connections.ts b/apps/tauri/src/stores/connections.ts index 1354db36..aca66b54 100644 --- a/apps/tauri/src/stores/connections.ts +++ b/apps/tauri/src/stores/connections.ts @@ -5,6 +5,8 @@ import { dbDisconnect, formatConnectionError, } from "../api/connection"; +import { DEMO_CONNECTION } from "../mock/demoCatalog"; +import { useShellNavStore } from "./shellNav"; import { useShellStatusStore } from "./shellStatus"; export type LiveConnection = { @@ -12,6 +14,8 @@ export type LiveConnection = { driver: "sqlite"; name: string; path: string; + /** Offline UI demo — no Rust session. */ + mock?: boolean; }; function fileName(path: string): string { @@ -19,18 +23,50 @@ function fileName(path: string): string { return parts[parts.length - 1] || path; } -/** Live DB sessions opened in this app process. */ +/** Saved / live sessions shown in SERVERS (Flutter connections list). */ export const useConnectionsStore = defineStore("connections", () => { const items = ref([]); - const activeId = ref(null); - const active = computed( - () => items.value.find((c) => c.id === activeId.value) ?? null, - ); + const byId = computed(() => { + const map = new Map(); + for (const c of items.value) map.set(c.id, c); + return map; + }); + + function upsert(conn: LiveConnection) { + const rest = items.value.filter((c) => c.id !== conn.id); + items.value = [...rest, conn]; + } + + /** Flutter-style Demo — full UI without opening a real file. */ + function launchDemo() { + const nav = useShellNavStore(); + const status = useShellStatusStore(); + const conn: LiveConnection = { + id: DEMO_CONNECTION.id, + driver: "sqlite", + name: DEMO_CONNECTION.name, + path: DEMO_CONNECTION.path, + mock: true, + }; + upsert(conn); + nav.setExpanded(conn.id, true); + nav.selectConnection(conn.id); + status.setConnection(conn.name, "Demo (offline)"); + status.setQueryMetrics({ + message: "Demo catalog · UI core (no live DB)", + busy: false, + }); + return conn; + } async function connectSqlite(path: string) { const status = useShellStatusStore(); - status.setQueryMetrics({ busy: true, message: `Opening ${fileName(path)}…` }); + const nav = useShellNavStore(); + status.setQueryMetrics({ + busy: true, + message: `Opening ${fileName(path)}…`, + }); try { const id = await dbConnectSqlite(path); const conn: LiveConnection = { @@ -39,8 +75,9 @@ export const useConnectionsStore = defineStore("connections", () => { name: fileName(path), path, }; - items.value = [...items.value, conn]; - activeId.value = id; + upsert(conn); + nav.setExpanded(id, true); + nav.selectConnection(id); status.setConnection(conn.name, path); status.setQueryMetrics({ busy: false, @@ -56,16 +93,19 @@ export const useConnectionsStore = defineStore("connections", () => { async function disconnect(id: string) { const status = useShellStatusStore(); + const nav = useShellNavStore(); + const conn = byId.value.get(id); try { - await dbDisconnect(id); + if (conn && !conn.mock) await dbDisconnect(id); } finally { items.value = items.value.filter((c) => c.id !== id); - if (activeId.value === id) { - activeId.value = items.value[0]?.id ?? null; - const next = active.value; + if (nav.selectedConnectionId === id) { + const next = items.value[0] ?? null; + if (next) nav.selectConnection(next.id); + else nav.reset(); status.setConnection(next?.name ?? null, next?.path ?? null); status.setQueryMetrics({ - message: next ? `Connected · ${next.name}` : "Disconnected", + message: next ? `Connected · ${next.name}` : "No connection", busy: false, }); } @@ -73,13 +113,26 @@ export const useConnectionsStore = defineStore("connections", () => { } function select(id: string) { - const conn = items.value.find((c) => c.id === id); + const conn = byId.value.get(id); if (!conn) return; - activeId.value = id; + const nav = useShellNavStore(); const status = useShellStatusStore(); - status.setConnection(conn.name, conn.path); - status.setQueryMetrics({ message: `Connected · ${conn.name}`, busy: false }); + nav.selectConnection(id); + status.setConnection(conn.name, conn.mock ? "Demo (offline)" : conn.path); + status.setQueryMetrics({ + message: conn.mock + ? "Demo catalog · UI core (no live DB)" + : `Connected · ${conn.name}`, + busy: false, + }); } - return { items, activeId, active, connectSqlite, disconnect, select }; + return { + items, + byId, + launchDemo, + connectSqlite, + disconnect, + select, + }; }); diff --git a/apps/tauri/src/stores/objectTree.ts b/apps/tauri/src/stores/objectTree.ts index 2948e6ae..fb4f4a77 100644 --- a/apps/tauri/src/stores/objectTree.ts +++ b/apps/tauri/src/stores/objectTree.ts @@ -7,8 +7,9 @@ import { type ColumnMeta, type SchemaObject, } from "../api/connection"; +import { DEMO_CONNECTION } from "../mock/demoCatalog"; import { useConnectionsStore } from "./connections"; -import { useShellStatusStore } from "./shellStatus"; +import { useShellNavStore } from "./shellNav"; export type TreeTableNode = SchemaObject & { expanded: boolean; @@ -17,7 +18,6 @@ export type TreeTableNode = SchemaObject & { error: string | null; }; -/** SQLite object tree for the active connection. */ export const useObjectTreeStore = defineStore("objectTree", () => { const connectionId = ref(null); const objects = ref([]); @@ -25,6 +25,23 @@ export const useObjectTreeStore = defineStore("objectTree", () => { const error = ref(null); const filter = ref(""); + function fromDemo(): TreeTableNode[] { + return DEMO_CONNECTION.objects.map((o) => ({ + name: o.name, + kind: o.kind, + schema: "main", + expanded: false, + loadingColumns: false, + columns: o.columns.map((c) => ({ + name: c.name, + data_type: c.data_type, + is_nullable: c.is_nullable, + is_primary_key: c.is_primary_key, + })), + error: null, + })); + } + async function loadFor(id: string | null) { connectionId.value = id; objects.value = []; @@ -32,6 +49,13 @@ export const useObjectTreeStore = defineStore("objectTree", () => { filter.value = ""; if (!id) return; + const connections = useConnectionsStore(); + const conn = connections.byId.get(id); + if (conn?.mock) { + objects.value = fromDemo(); + return; + } + loading.value = true; try { const list = await dbListTables(id); @@ -49,7 +73,7 @@ export const useObjectTreeStore = defineStore("objectTree", () => { } } - async function toggleTable(name: string) { + async function toggleColumns(name: string) { const id = connectionId.value; const node = objects.value.find((o) => o.name === name); if (!id || !node) return; @@ -58,10 +82,12 @@ export const useObjectTreeStore = defineStore("objectTree", () => { node.expanded = false; return; } - node.expanded = true; if (node.columns) return; + const connections = useConnectionsStore(); + if (connections.byId.get(id)?.mock) return; + node.loadingColumns = true; node.error = null; try { @@ -69,11 +95,6 @@ export const useObjectTreeStore = defineStore("objectTree", () => { node.columns = schema.columns; } catch (err) { node.error = formatConnectionError(err); - const status = useShellStatusStore(); - status.setQueryMetrics({ - message: node.error, - busy: false, - }); } finally { node.loadingColumns = false; } @@ -83,10 +104,9 @@ export const useObjectTreeStore = defineStore("objectTree", () => { return loadFor(connectionId.value); } - // Keep tree in sync with active connection. - const connections = useConnectionsStore(); + const nav = useShellNavStore(); watch( - () => connections.activeId, + () => nav.selectedConnectionId, (id) => { void loadFor(id); }, @@ -100,7 +120,7 @@ export const useObjectTreeStore = defineStore("objectTree", () => { error, filter, loadFor, - toggleTable, + toggleColumns, refresh, }; }); diff --git a/apps/tauri/src/stores/queryResult.ts b/apps/tauri/src/stores/queryResult.ts index 06193879..d754a014 100644 --- a/apps/tauri/src/stores/queryResult.ts +++ b/apps/tauri/src/stores/queryResult.ts @@ -8,9 +8,10 @@ import { } from "../api/queryAccumulate"; import { formatConnectionError } from "../api/connection"; import { useConnectionsStore } from "./connections"; +import { useShellNavStore } from "./shellNav"; import { useShellStatusStore } from "./shellStatus"; -/** Last streamed query result — Glide grid binds here. */ +/** Last streamed / browsed result — Glide grid binds here. */ export const useQueryResultStore = defineStore("queryResult", () => { const columns = ref([]); const rows = ref([]); @@ -21,36 +22,68 @@ export const useQueryResultStore = defineStore("queryResult", () => { const affectedRows = ref(null); const error = ref(null); - function syncFrom(acc: AccumulatedQuery) { - columns.value = acc.columns; - rows.value = acc.rows; - truncated.value = acc.truncated; - rowCount.value = acc.rowCount; - elapsedMs.value = acc.elapsedMs; - affectedRows.value = acc.affectedRows; - error.value = acc.error; + let acc = emptyAccumulatedQuery(); + + function syncFrom(next: AccumulatedQuery) { + columns.value = next.columns; + rows.value = next.rows; + truncated.value = next.truncated; + rowCount.value = next.rowCount; + elapsedMs.value = next.elapsedMs; + affectedRows.value = next.affectedRows; + error.value = next.error; } function reset() { - syncFrom(emptyAccumulatedQuery()); + acc = emptyAccumulatedQuery(); + syncFrom(acc); } - let acc = emptyAccumulatedQuery(); - - function onEvent(ev: QueryEvent) { + function feedEvent(ev: QueryEvent) { acc = applyQueryEvent(acc, ev); syncFrom(acc); } + function setSnapshot(opts: { + columns: string[]; + rows: unknown[][]; + message?: string; + }) { + acc = { + ...emptyAccumulatedQuery(), + columns: opts.columns, + rows: opts.rows, + rowCount: opts.rows.length, + elapsedMs: 0, + }; + syncFrom(acc); + if (opts.message) { + useShellStatusStore().setQueryMetrics({ + message: opts.message, + busy: false, + rows: opts.rows.length, + cols: opts.columns.length, + durationMs: 0, + }); + } + } + async function run(sql: string) { const connections = useConnectionsStore(); + const nav = useShellNavStore(); const status = useShellStatusStore(); - const id = connections.activeId; - if (!id) { + const id = nav.selectedConnectionId; + const conn = id ? connections.byId.get(id) : null; + if (!id || !conn) { error.value = "No active connection"; status.setQueryMetrics({ message: error.value, busy: false }); return; } + if (conn.mock) { + error.value = "Demo connection — open a table from the sidebar for Data"; + status.setQueryMetrics({ message: error.value, busy: false }); + return; + } const trimmed = sql.trim(); if (!trimmed) { error.value = "SQL is empty"; @@ -59,11 +92,10 @@ export const useQueryResultStore = defineStore("queryResult", () => { } reset(); - acc = emptyAccumulatedQuery(); running.value = true; status.setQueryMetrics({ message: "Running…", busy: true }); try { - await dbExecuteQuery(id, trimmed, onEvent); + await dbExecuteQuery(id, trimmed, feedEvent); if (error.value) { status.setQueryMetrics({ message: error.value, busy: false }); } else if (affectedRows.value != null && columns.value.length === 0) { @@ -103,6 +135,8 @@ export const useQueryResultStore = defineStore("queryResult", () => { affectedRows, error, reset, + feedEvent, + setSnapshot, run, }; }); diff --git a/apps/tauri/src/stores/shellNav.ts b/apps/tauri/src/stores/shellNav.ts new file mode 100644 index 00000000..86b43294 --- /dev/null +++ b/apps/tauri/src/stores/shellNav.ts @@ -0,0 +1,83 @@ +import { defineStore } from "pinia"; +import { computed, ref } from "vue"; + +/** Flutter MainScreen workspace selection — chrome routing, not DB. */ +export type WorkspaceSurface = "empty" | "connectionHome" | "tableObject"; + +export type HomeStripTab = "overview" | "sql"; +export type ObjectStripTab = "data" | "relations"; + +export type SelectedObject = { + connectionId: string; + name: string; + kind: "table" | "view"; +}; + +export const useShellNavStore = defineStore("shellNav", () => { + const selectedConnectionId = ref(null); + const selectedObject = ref(null); + const homeTab = ref("overview"); + const objectTab = ref("data"); + /** Expanded connection ids in the SERVERS tree (Flutter expand = show objects). */ + const expandedConnectionIds = ref([]); + + const surface = computed(() => { + if (selectedObject.value) return "tableObject"; + if (selectedConnectionId.value) return "connectionHome"; + return "empty"; + }); + + function selectConnection(id: string | null) { + selectedConnectionId.value = id; + selectedObject.value = null; + homeTab.value = "overview"; + } + + function selectObject(obj: SelectedObject) { + selectedConnectionId.value = obj.connectionId; + selectedObject.value = obj; + objectTab.value = "data"; + } + + function clearObject() { + selectedObject.value = null; + homeTab.value = "overview"; + } + + function toggleExpanded(id: string) { + const set = new Set(expandedConnectionIds.value); + if (set.has(id)) set.delete(id); + else set.add(id); + expandedConnectionIds.value = [...set]; + } + + function setExpanded(id: string, expanded: boolean) { + const set = new Set(expandedConnectionIds.value); + if (expanded) set.add(id); + else set.delete(id); + expandedConnectionIds.value = [...set]; + } + + function reset() { + selectedConnectionId.value = null; + selectedObject.value = null; + homeTab.value = "overview"; + objectTab.value = "data"; + expandedConnectionIds.value = []; + } + + return { + selectedConnectionId, + selectedObject, + homeTab, + objectTab, + expandedConnectionIds, + surface, + selectConnection, + selectObject, + clearObject, + toggleExpanded, + setExpanded, + reset, + }; +}); diff --git a/apps/tauri/src/ui/ConnectionHome.vue b/apps/tauri/src/ui/ConnectionHome.vue new file mode 100644 index 00000000..3b51618b --- /dev/null +++ b/apps/tauri/src/ui/ConnectionHome.vue @@ -0,0 +1,277 @@ + + + + + diff --git a/apps/tauri/src/ui/ConnectionsPanel.vue b/apps/tauri/src/ui/ConnectionsPanel.vue index 1542f07a..1b4db5d2 100644 --- a/apps/tauri/src/ui/ConnectionsPanel.vue +++ b/apps/tauri/src/ui/ConnectionsPanel.vue @@ -3,9 +3,10 @@ import { computed, onUnmounted, ref } from "vue"; import { storeToRefs } from "pinia"; import { useShellStore } from "../stores/shell"; import { useConnectionsStore } from "../stores/connections"; +import { useShellNavStore } from "../stores/shellNav"; +import { useObjectTreeStore } from "../stores/objectTree"; import { useQueryaMotion } from "../motion"; import SplitHandle from "./SplitHandle.vue"; -import SqliteObjectTree from "./SqliteObjectTree.vue"; const emit = defineEmits<{ openSqlite: []; @@ -14,12 +15,18 @@ const emit = defineEmits<{ const shell = useShellStore(); const connections = useConnectionsStore(); -const { items, activeId } = storeToRefs(connections); +const nav = useShellNavStore(); +const tree = useObjectTreeStore(); +const { items } = storeToRefs(connections); +const { selectedConnectionId, expandedConnectionIds, selectedObject } = + storeToRefs(nav); +const { objects, filter: objectFilter, loading, error } = storeToRefs(tree); const motion = useQueryaMotion(); const filter = ref(""); const dragging = ref(false); +const menuOpen = ref(false); -const filtered = computed(() => { +const filteredConnections = computed(() => { const q = filter.value.trim().toLowerCase(); if (!q) return items.value; return items.value.filter( @@ -28,6 +35,12 @@ const filtered = computed(() => { ); }); +const filteredObjects = computed(() => { + const q = objectFilter.value.trim().toLowerCase(); + if (!q) return objects.value; + return objects.value.filter((o) => o.name.toLowerCase().includes(q)); +}); + const panelStyle = computed(() => ({ width: shell.sidebarOpen ? `${shell.sidebarWidth}px` : "0px", transitionProperty: dragging.value ? "none" : "width", @@ -41,13 +54,11 @@ function onResizeStart(e: PointerEvent) { dragging.value = true; const startX = e.clientX; const startW = shell.sidebarWidth; - const onMove = (ev: PointerEvent) => { shell.setSidebarWidth(startW + (ev.clientX - startX)); }; const onUp = () => { dragging.value = false; - // Flutter collapse threshold: flick under ~100px closes. if (shell.sidebarWidth < 100) shell.setSidebarOpen(false); window.removeEventListener("pointermove", onMove); window.removeEventListener("pointerup", onUp); @@ -56,6 +67,33 @@ function onResizeStart(e: PointerEvent) { window.addEventListener("pointerup", onUp); } +function onConnClick(id: string) { + connections.select(id); +} + +function onConnExpand(id: string, e: MouseEvent) { + e.stopPropagation(); + nav.toggleExpanded(id); + connections.select(id); +} + +function onObjectClick(name: string, kind: "table" | "view") { + const id = selectedConnectionId.value; + if (!id) return; + nav.selectObject({ connectionId: id, name, kind }); +} + +function onObjectChevron(name: string, e: MouseEvent) { + e.stopPropagation(); + void tree.toggleColumns(name); +} + +function onContextCreate(action: "connection" | "sqlite" | "folder") { + menuOpen.value = false; + if (action === "sqlite") emit("openSqlite"); + else if (action === "connection") emit("newConnection"); +} + onUnmounted(() => { dragging.value = false; }); @@ -69,7 +107,7 @@ onUnmounted(() => { :style="panelStyle" :aria-hidden="!shell.sidebarOpen" > -
+
SERVERS {{ items.length }} @@ -84,57 +122,144 @@ onUnmounted(() => { data-testid="connections-filter" />
+
-
    +

    + {{ filter ? "No connections match" : "No connections yet" }} +

    +

    + Right-click → Create, or use the empty workspace actions. +

    + +
    • - - + + +
+ +
- × - +
+ OBJECTS + +
+ +

Loading…

+

{{ error }}

+
    +
  • +
    + + +
    +
      +
    • Loading…
    • +
    • {{ obj.error }}
    • +
    • + + {{ col.name }} + PK + + {{ col.data_type || "—" }} +
    • +
    +
  • +
+
- - -
- - -
+
+ +
+

Create

+ + + +
@@ -153,6 +278,7 @@ onUnmounted(() => { } .inner { + position: relative; flex: 1; min-width: var(--q-sidebar-min); height: 100%; @@ -174,7 +300,8 @@ onUnmounted(() => { padding: 10px 12px 6px; } -.servers-label { +.servers-label, +.tree-label { font-family: var(--q-font-mono); font-size: 11px; font-weight: 600; @@ -214,38 +341,71 @@ onUnmounted(() => { .body { flex: 1; - padding: 16px 12px; + padding: 4px 8px 16px; overflow: auto; } +.empty-title { + margin: 12px 4px 0; + font-size: 13px; + font-weight: 600; +} + +.empty-hint, +.hint { + margin: 6px 4px 0; + font-size: 12px; + color: var(--q-muted-foreground); + line-height: 1.4; +} + +.hint.err, +.col.err { + color: var(--q-danger, #c44); +} + .list { list-style: none; - margin: 0 0 12px; + margin: 0; padding: 0; - display: flex; - flex-direction: column; - gap: 2px; } -.row { +.conn-row { display: flex; align-items: center; gap: 2px; border-radius: var(--q-radius-control); } -.row.active { +.conn.active > .conn-row { background: color-mix(in srgb, var(--q-primary) 16%, transparent); } -.row-main { +.chev { + appearance: none; + border: 0; + background: transparent; + width: 1.25rem; + height: 1.5rem; + color: var(--q-muted-foreground); + cursor: pointer; + font-size: 10px; + flex-shrink: 0; +} + +.chev.sm { + width: 1rem; +} + +.conn-main, +.node-main { appearance: none; border: 0; background: transparent; flex: 1; min-width: 0; text-align: left; - padding: 6px 8px; + padding: 6px 6px; cursor: pointer; color: var(--q-foreground); font: inherit; @@ -253,11 +413,13 @@ onUnmounted(() => { border-radius: var(--q-radius-control); } -.row-main:hover { +.conn-main:hover, +.node-main:hover { background: var(--q-accent); } -.row-name { +.conn-name, +.name { display: block; overflow: hidden; text-overflow: ellipsis; @@ -265,14 +427,17 @@ onUnmounted(() => { font-weight: 500; } -.row-meta { +.conn-meta, +.kind, +.type { display: block; font-size: 10px; color: var(--q-muted-foreground); font-family: var(--q-font-mono); } -.row-x { +.conn-x, +.refresh { appearance: none; border: 0; background: transparent; @@ -283,56 +448,118 @@ onUnmounted(() => { cursor: pointer; } -.row-x:hover { +.conn-x:hover, +.refresh:hover { background: var(--q-accent); color: var(--q-foreground); } -.empty-title { - margin: 0; - font-size: 13px; - font-weight: 600; - color: var(--q-foreground); +.tree { + margin: 2px 0 8px 6px; + padding: 6px 0 4px 6px; + border-left: 1px solid + color-mix(in srgb, var(--q-border) 55%, transparent); } -.empty-hint { +.tree-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 4px; +} + +.nodes, +.cols { + list-style: none; margin: 6px 0 0; - font-size: 12px; + padding: 0; +} + +.node-row { + display: flex; + align-items: center; + border-radius: var(--q-radius-control); +} + +.node-row.selected { + background: color-mix(in srgb, var(--q-primary) 14%, transparent); +} + +.cols { + padding: 0 0 4px 1rem; +} + +.col { + display: flex; + justify-content: space-between; + gap: 8px; + padding: 2px 6px; + font-size: 11px; +} + +.col.muted { color: var(--q-muted-foreground); - line-height: 1.4; } -.actions { +.pk { + margin-left: 4px; + font-size: 9px; + font-weight: 700; + color: var(--q-primary); + font-family: var(--q-font-mono); +} + +.ctx { + position: absolute; + left: 12px; + bottom: 12px; + z-index: 5; + min-width: 160px; + padding: 6px; + border-radius: var(--q-radius-control); + background: var(--q-surface); + border: 1px solid var(--q-border); + box-shadow: 0 8px 24px color-mix(in srgb, #000 35%, transparent); display: flex; flex-direction: column; - gap: 6px; - margin-top: 14px; + gap: 2px; } -.btn { +.ctx-label { + margin: 0; + padding: 4px 8px; + font-size: 10px; + font-weight: 700; + letter-spacing: 0.06em; + color: var(--q-muted-foreground); + text-transform: uppercase; +} + +.ctx button { appearance: none; - height: var(--q-control-h-sm); - border: 1px solid var(--q-border); - border-radius: var(--q-radius-control); - background: var(--q-surface); - color: var(--q-foreground); + border: 0; + background: transparent; + text-align: left; + padding: 6px 8px; + border-radius: var(--q-radius-sm); font: inherit; font-size: 12px; + color: var(--q-foreground); cursor: pointer; - padding: 0 8px; } -.btn:hover { +.ctx button:hover:not(:disabled) { background: var(--q-accent); } -.btn.primary { - background: var(--q-primary); - border-color: transparent; - color: var(--q-primary-foreground); +.ctx button:disabled, +.ctx .muted { + opacity: 0.45; + cursor: not-allowed; } -.btn.primary:hover { - filter: brightness(1.05); +.ctx .dismiss { + margin-top: 4px; + color: var(--q-muted-foreground); } diff --git a/apps/tauri/src/ui/SqlWorkspace.vue b/apps/tauri/src/ui/SqlWorkspace.vue index 5c2881f6..8140110b 100644 --- a/apps/tauri/src/ui/SqlWorkspace.vue +++ b/apps/tauri/src/ui/SqlWorkspace.vue @@ -3,6 +3,7 @@ import { computed, ref, watch } from "vue"; import { storeToRefs } from "pinia"; import { useWorkspaceStore } from "../stores/workspace"; import { useQueryResultStore } from "../stores/queryResult"; +import { useShellNavStore } from "../stores/shellNav"; import { useConnectionsStore } from "../stores/connections"; import SqlEditor from "./SqlEditor.vue"; import ResultGrid from "./ResultGrid.vue"; @@ -10,10 +11,18 @@ import ResultGrid from "./ResultGrid.vue"; const workspace = useWorkspaceStore(); const query = useQueryResultStore(); const connections = useConnectionsStore(); +const nav = useShellNavStore(); const { activeTab } = storeToRefs(workspace); const { columns, running, error, rowCount, elapsedMs, truncated, affectedRows } = storeToRefs(query); +const hasLiveConnection = computed(() => { + const id = nav.selectedConnectionId; + if (!id) return false; + const c = connections.byId.get(id); + return !!c && !c.mock; +}); + const editorRef = ref | null>(null); const sql = computed({ @@ -52,13 +61,15 @@ const hasGrid = computed(() => columns.value.length > 0); type="button" class="run" data-testid="sql-run" - :disabled="running || !connections.active" + :disabled="running || !hasLiveConnection" @click="onRun" > {{ running ? "Running…" : "Run" }} - Ctrl/Cmd+Enter · selection or whole buffer - Connect a database first + Parked under Overview · Ctrl/Cmd+Enter + + Live SQLite required for Run (Demo uses table Data view) +
-import { computed } from "vue"; -import { storeToRefs } from "pinia"; -import { useObjectTreeStore } from "../stores/objectTree"; - -const tree = useObjectTreeStore(); -const { objects, loading, error, filter, connectionId } = storeToRefs(tree); - -const filtered = computed(() => { - const q = filter.value.trim().toLowerCase(); - if (!q) return objects.value; - return objects.value.filter((o) => o.name.toLowerCase().includes(q)); -}); - - - - - diff --git a/apps/tauri/src/ui/TableObjectView.vue b/apps/tauri/src/ui/TableObjectView.vue new file mode 100644 index 00000000..d9acf0a4 --- /dev/null +++ b/apps/tauri/src/ui/TableObjectView.vue @@ -0,0 +1,266 @@ + + + + + diff --git a/apps/tauri/src/ui/WorkspaceEmptyHero.vue b/apps/tauri/src/ui/WorkspaceEmptyHero.vue index df762059..d83c751a 100644 --- a/apps/tauri/src/ui/WorkspaceEmptyHero.vue +++ b/apps/tauri/src/ui/WorkspaceEmptyHero.vue @@ -2,6 +2,7 @@ const emit = defineEmits<{ newConnection: []; openSqlite: []; + launchDemo: []; openTour: []; }>(); @@ -9,7 +10,7 @@ const emit = defineEmits<{ @@ -80,10 +89,10 @@ const emit = defineEmits<{ .btn { appearance: none; - height: var(--q-control-h-md); - padding: 0 12px; - border-radius: var(--q-radius-control); + height: var(--q-control-h); + padding: 0 14px; border: 1px solid var(--q-border); + border-radius: var(--q-radius-control); background: var(--q-surface); color: var(--q-foreground); font: inherit; @@ -110,17 +119,10 @@ const emit = defineEmits<{ } .hint { - margin: var(--q-space-6) 0 0; + margin: var(--q-space-4) 0 0; + max-width: 32rem; font-size: 12px; color: var(--q-muted-foreground); -} - -kbd { - font-family: var(--q-font-mono); - font-size: 11px; - padding: 1px 4px; - border-radius: 3px; - border: 1px solid var(--q-border); - background: var(--q-surface); + line-height: 1.45; }