Skip to content

Commit 1e78ff7

Browse files
committed
Fix schema search
1 parent ac79007 commit 1e78ff7

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

exec/java-exec/src/main/resources/webapp/src/components/schema-explorer/SchemaExplorer.tsx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,7 @@ export default function SchemaExplorer({ onInsertText, onTableSelect, datasetFil
388388
return [];
389389
}
390390

391-
const filteredPlugins = searchText
392-
? plugins.filter((p) =>
393-
p.name.toLowerCase().includes(searchText.toLowerCase()) ||
394-
Object.keys(schemasCache[p.name] || []).some((s) =>
395-
s.toLowerCase().includes(searchText.toLowerCase())
396-
)
397-
)
398-
: plugins;
399-
400-
let nodes = filteredPlugins.map((plugin) =>
391+
let nodes = plugins.map((plugin) =>
401392
buildPluginNode(
402393
plugin, schemasCache, tablesCache, columnsCache, filesCache, nestedCache, subTablesCache,
403394
columnFilter,
@@ -410,6 +401,34 @@ export default function SchemaExplorer({ onInsertText, onTableSelect, datasetFil
410401
nodes = filterTreeNodes(nodes, datasetAllowList);
411402
}
412403

404+
// Apply search filter across all levels (plugin, schema, table, column)
405+
if (searchText) {
406+
const lower = searchText.toLowerCase();
407+
const matchesSearch = (node: DataNode): boolean => {
408+
const title = typeof node.title === 'string'
409+
? node.title
410+
: String(node.key).split(':').pop() || '';
411+
if (title.toLowerCase().includes(lower)) {
412+
return true;
413+
}
414+
if (node.children) {
415+
return node.children.some(matchesSearch);
416+
}
417+
return false;
418+
};
419+
const pruneTree = (nodeList: DataNode[]): DataNode[] => {
420+
return nodeList
421+
.filter(matchesSearch)
422+
.map((node) => {
423+
if (!node.children) {
424+
return node;
425+
}
426+
return { ...node, children: pruneTree(node.children) };
427+
});
428+
};
429+
nodes = pruneTree(nodes);
430+
}
431+
413432
return nodes;
414433
}, [plugins, schemasCache, tablesCache, columnsCache, filesCache, nestedCache, subTablesCache, searchText, datasetAllowList, columnFilter]);
415434

@@ -1012,7 +1031,7 @@ export default function SchemaExplorer({ onInsertText, onTableSelect, datasetFil
10121031
<div style={{ padding: '8px 8px 0', display: 'flex', gap: 8 }}>
10131032
<Search
10141033
id="schema-search-input"
1015-
placeholder="Search schemas... (Ctrl+Shift+F)"
1034+
placeholder="Search schemas, tables, columns... (Ctrl+Shift+F)"
10161035
allowClear
10171036
size="small"
10181037
prefix={<SearchOutlined />}

0 commit comments

Comments
 (0)