feat(sidebar): extend filters to views and routines

This commit is contained in:
jearhe authored and GitHub committed 2026-08-23 01:38:19 +08:00
1 parent 3dbcc2d0dc
commit b74d49e982
20 files changed
+268 -46

No files matched your search

@@ -0,0 +1,13 @@
import { describe, expect, it } from "vitest";
import { supportsSidebarObjectNameFilter } from "../../sidebar/sidebarObjectNameFilter";
describe("supportsSidebarObjectNameFilter", () => {
it("allows only supported object groups", () => {
const supportedTypes = ["group-tables", "group-views", "group-materialized-views", "group-procedures", "group-functions"] as const;
expect(supportedTypes.every((type) => supportsSidebarObjectNameFilter({ type, parentType: undefined }))).toBe(true);
expect(supportsSidebarObjectNameFilter({ type: "group-indexes", parentType: undefined })).toBe(false);
expect(supportsSidebarObjectNameFilter({ type: "group-triggers", parentType: undefined })).toBe(false);
expect(supportsSidebarObjectNameFilter({ type: "group-events", parentType: undefined })).toBe(false);
expect(supportsSidebarObjectNameFilter({ type: "group-functions", parentType: "package" })).toBe(false);
});
});
+2 -1
View File
@@ -829,7 +829,7 @@ export async function getTableComment(_connectionId: string, _database: string,
throw new Error("Table comment lookup is not available in the web backend");
}
export async function listObjects(connectionId: string, database: string, schema: string, objectTypes?: (SidebarObjectKind | "EVENT")[], filter?: string, limit?: number, offset?: number, catalog?: string): Promise<ObjectInfo[]> {
export async function listObjects(connectionId: string, database: string, schema: string, objectTypes?: (SidebarObjectKind | "EVENT")[], filter?: string, limit?: number, offset?: number, catalog?: string, tableNameFilter?: TableNameFilter): Promise<ObjectInfo[]> {
return get(
`/api/schema/objects?${qs({
connection_id: connectionId,
@@ -840,6 +840,7 @@ export async function listObjects(connectionId: string, database: string, schema
limit,
offset,
catalog,
table_name_filter: tableNameFilter ? JSON.stringify(tableNameFilter) : undefined,
})}`,
);
}
+2 -1
View File
@@ -1093,7 +1093,7 @@ export async function getTableComment(connectionId: string, database: string, sc
});
}
export async function listObjects(connectionId: string, database: string, schema: string, objectTypes?: (SidebarObjectKind | "EVENT")[], filter?: string, limit?: number, offset?: number, catalog?: string): Promise<ObjectInfo[]> {
export async function listObjects(connectionId: string, database: string, schema: string, objectTypes?: (SidebarObjectKind | "EVENT")[], filter?: string, limit?: number, offset?: number, catalog?: string, tableNameFilter?: import("@/types/database").TableNameFilter): Promise<ObjectInfo[]> {
return invoke("list_objects", {
connectionId,
database,
@@ -1103,6 +1103,7 @@ export async function listObjects(connectionId: string, database: string, schema
limit,
offset,
catalog,
tableNameFilter,
});
}
@@ -0,0 +1,12 @@
import type { TreeNode, TreeNodeType } from "@/types/database";
const sidebarObjectNameFilterGroupTypes: ReadonlySet<TreeNodeType> = new Set(["group-tables", "group-views", "group-materialized-views", "group-procedures", "group-functions"]);
type SidebarObjectNameFilterTarget = {
type: TreeNodeType;
parentType?: TreeNode["parentType"];
};
export function supportsSidebarObjectNameFilter(node: SidebarObjectNameFilterTarget): boolean {
return node.parentType !== "package" && sidebarObjectNameFilterGroupTypes.has(node.type);
}