Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: show full node in search result (#20667)
ecmadaob8f61d7f6ff9
diff --git a/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsx b/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsxindex e2bc5fab00..af83832ae0 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsx+++ b/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsx@@ -286,7 +286,13 @@ function SchemaPaneInner() {return tree.reduce((sum, root) =>sum +- countVisibleRows(root, expandedKeySet, searchKeyword, schemaNodeMatch),+ countVisibleRows(+ root,+ expandedKeySet,+ searchKeyword,+ schemaNodeMatch,+ true+ ),0);}, [tree, expandedKeySet, searchKeyword]);@@ -461,6 +467,7 @@ function SchemaPaneInner() {expandedIds={expandedKeys}searchTerm={searchKeyword || undefined}searchMatch={searchMatch}+ includeChildrenOnSearchMatchonToggle={(id) => {const next = new Set(expandedKeys);if (next.has(id)) next.delete(id);diff --git a/frontend/src/react/components/ui/tree-utils.test.ts b/frontend/src/react/components/ui/tree-utils.test.tsnew file mode 100644index 0000000000..528538ecfc--- /dev/null+++ b/frontend/src/react/components/ui/tree-utils.test.ts@@ -0,0 +1,35 @@+import { describe, expect, test } from "vitest";+import { countVisibleRows } from "./tree-utils";++type TestNode = {+ key: string;+ label: string;+ children?: TestNode[];+};++describe("countVisibleRows", () => {+ test("counts direct children of matching nodes when requested", () => {+ const tree: TestNode = {+ key: "schema",+ label: "billing",+ children: [+ {+ key: "table",+ label: "invoice",+ children: [{ key: "column", label: "amount" }],+ },+ { key: "view", label: "payment_view" },+ ],+ };++ expect(+ countVisibleRows(+ tree,+ new Set(),+ "billing",+ (node, term) => node.label.includes(term),+ true+ )+ ).toBe(3);+ });+});diff --git a/frontend/src/react/components/ui/tree-utils.ts b/frontend/src/react/components/ui/tree-utils.tsindex ecf3c3a8d1..b31e7b607f 100644--- a/frontend/src/react/components/ui/tree-utils.ts+++ b/frontend/src/react/components/ui/tree-utils.ts@@ -35,7 +35,9 @@ export function countVisibleRows<node: T,expandedKeys: ReadonlySet<string>,keyword: string,- searchMatch: (node: T, term: string) => boolean+ searchMatch: (node: T, term: string) => boolean,+ includeChildrenOnSearchMatch = false,+ parentMatches = false): number {if (!keyword) {let count = 1;@@ -47,12 +49,20 @@ export function countVisibleRows<return count;}+ const selfMatches = searchMatch(node, keyword);+ const includedByParent = includeChildrenOnSearchMatch && parentMatches;let childCount = 0;for (const child of node.children ?? []) {- childCount += countVisibleRows(child, expandedKeys, keyword, searchMatch);+ childCount += countVisibleRows(+ child,+ expandedKeys,+ keyword,+ searchMatch,+ includeChildrenOnSearchMatch,+ selfMatches+ );}- const selfMatches = searchMatch(node, keyword);- if (selfMatches || childCount > 0) {+ if (includedByParent || selfMatches || childCount > 0) {return 1 + childCount;}return 0;diff --git a/frontend/src/react/components/ui/tree.test.tsx b/frontend/src/react/components/ui/tree.test.tsxindex 554436d53c..c49e0e3e5b 100644--- a/frontend/src/react/components/ui/tree.test.tsx+++ b/frontend/src/react/components/ui/tree.test.tsx@@ -278,4 +278,40 @@ describe("Tree", () => {expect(container.textContent).toContain("Foo Also");expect(container.textContent).not.toContain("Bazqux");});++ test("searchTerm can show direct children of matching nodes without recursively expanding them", async () => {+ const nodes = [+ makeNode("schema", "billing", [+ makeNode("table", "invoice", [makeNode("column", "amount")]),+ makeNode("view", "payment_view"),+ ]),+ makeNode("audit", "audit", [makeNode("log", "log_entry")]),+ ];++ await act(async () => {+ root.render(+ <Tree+ data={nodes}+ searchTerm="billing"+ includeChildrenOnSearchMatch+ searchMatch={(node, term) =>+ node.data.label.toLowerCase().includes(term.toLowerCase())+ }+ renderNode={({ node, style }) => (+ <div style={style} data-testid={`node-${node.id}`}>+ {node.data.data.label}+ </div>+ )}+ height={200}+ />+ );+ });++ expect(container.textContent).toContain("billing");+ expect(container.textContent).toContain("invoice");+ expect(container.textContent).toContain("payment_view");+ expect(container.textContent).not.toContain("amount");+ expect(container.textContent).not.toContain("audit");+ expect(container.textContent).not.toContain("log_entry");+ });});diff --git a/frontend/src/react/components/ui/tree.tsx b/frontend/src/react/components/ui/tree.tsxindex b3cf15ca51..469c139de5 100644--- a/frontend/src/react/components/ui/tree.tsx+++ b/frontend/src/react/components/ui/tree.tsx@@ -27,6 +27,7 @@ export interface TreeProps<T> {readonly searchTerm?: string;readonly searchMatch?: (node: TreeDataNode<T>, term: string) => boolean;+ readonly includeChildrenOnSearchMatch?: boolean;readonly height?: number;readonly rowHeight?: number;@@ -56,6 +57,7 @@ export function Tree<T>({onToggle,searchTerm,searchMatch,+ includeChildrenOnSearchMatch = false,height = 300,rowHeight = 28,indent = 16,@@ -153,10 +155,18 @@ export function Tree<T>({return label.toLowerCase().includes(term.toLowerCase());};- const resolvedSearchMatch = searchMatch+ const baseSearchMatch = searchMatch? (node: NodeApi<TreeDataNode<T>>, term: string) =>searchMatch(node.data, term): defaultSearchMatch;+ const resolvedSearchMatch = includeChildrenOnSearchMatch+ ? (node: NodeApi<TreeDataNode<T>>, term: string) => {+ return (+ baseSearchMatch(node, term) ||+ (!!node.parent?.data?.data && baseSearchMatch(node.parent, term))+ );+ }+ : baseSearchMatch;return (<div