diff --git a/src/components/sidebar/ConnectionTree.vue b/src/components/sidebar/ConnectionTree.vue index 350f1d5399..9459a4c459 100644 --- a/src/components/sidebar/ConnectionTree.vue +++ b/src/components/sidebar/ConnectionTree.vue @@ -96,6 +96,12 @@ function filterTree(nodes: TreeNode[], q: string): TreeNode[] { const filteredNodes: TreeNode[] = []; for (const node of nodes) { + if (node.type === "object-browser" && node.hiddenChildren) { + const matches = node.hiddenChildren.filter((child) => matchSidebarLabel(normalizedLabel(child), q)); + if (matches.length > 0) filteredNodes.push(...matches); + continue; + } + const label = normalizedLabel(node); const selfMatches = !!matchSidebarLabel(label, q); const filteredChildren = node.children ? filterTree(node.children, q) : undefined; diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts index 54aa804e95..1256a33a16 100644 --- a/src/stores/connectionStore.ts +++ b/src/stores/connectionStore.ts @@ -689,17 +689,25 @@ export const useConnectionStore = defineStore("connection", () => { [], defaultSchemaTables.slice(0, SIDEBAR_TABLE_NODE_LIMIT), ); - children = [ - ...previewTables, - buildObjectBrowserNode( - `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`, - connectionId, - database, - SQLSERVER_DEFAULT_SCHEMA, - defaultSchemaTables.length, - ), - ...children.filter((child) => child.type === "schema"), - ]; + const browserNode = buildObjectBrowserNode( + `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`, + connectionId, + database, + SQLSERVER_DEFAULT_SCHEMA, + defaultSchemaTables.length, + ); + const hiddenTables = defaultSchemaTables.slice(SIDEBAR_TABLE_NODE_LIMIT); + browserNode.hiddenChildren = hiddenTables.map((t) => ({ + id: `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}:${t.name}`, + label: t.name, + type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table", + connectionId, + database, + schema: SQLSERVER_DEFAULT_SCHEMA, + isExpanded: false, + children: [], + })); + children = [...previewTables, browserNode, ...children.filter((child) => child.type === "schema")]; } setChildren(node, children); await savePersistedTreeChildren(cacheKey, children); @@ -736,7 +744,19 @@ export const useConnectionStore = defineStore("connection", () => { children: [], })); if (tables.length > SIDEBAR_TABLE_NODE_LIMIT) { - children.push(buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length)); + const hiddenTables = tables.slice(SIDEBAR_TABLE_NODE_LIMIT); + const browserNode = buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length); + browserNode.hiddenChildren = hiddenTables.map((t) => ({ + id: `${nodeId}:${t.name}`, + label: t.name, + type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table", + connectionId, + database, + schema: effectiveSchema, + isExpanded: false, + children: [], + })); + children.push(browserNode); } setChildren(node, children); await savePersistedTreeChildren(cacheKey, children); diff --git a/src/types/database.ts b/src/types/database.ts index dca1fd7bc1..70de4478b7 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -205,6 +205,7 @@ export interface TreeNode { schema?: string; tableName?: string; objectCount?: number; + hiddenChildren?: TreeNode[]; savedSqlId?: string; savedSqlFolderId?: string; meta?: ColumnInfo | IndexInfo | ForeignKeyInfo | TriggerInfo;