fix(postgresql): show trigger source details

This commit is contained in:
zipg authored and GitHub committed 2026-07-23 21:16:43 +08:00
1 parent 6115771b34
commit 6b2f55e4de
13 files changed
+137 -19

No files matched your search

@@ -1,7 +1,7 @@
import { createPinia, setActivePinia } from "pinia";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { loadSidebarObjectGroup } from "@/lib/sidebar/sidebarObjectGroupRouting";
import type { ConnectionConfig, ObjectInfo, TreeNode } from "@/types/database";
import type { ConnectionConfig, ObjectInfo, TreeNode, TriggerInfo } from "@/types/database";
function installLocalStorage() {
const data = new Map<string, string>();
@@ -92,7 +92,13 @@ describe("sidebar object-group routing", () => {
it("keeps table-level trigger groups on listTriggers", async () => {
const listObjects = vi.fn<() => Promise<ObjectInfo[]>>().mockResolvedValue([]);
const listTriggers = vi.fn<() => Promise<never[]>>().mockResolvedValue([]);
const listTriggers = vi.fn<() => Promise<TriggerInfo[]>>().mockResolvedValue([
{
name: "trg_orders_audit",
timing: "AFTER",
event: "UPDATE",
},
]);
const { connection, store } = await createStore({ listObjects, listTriggers });
const tableTriggerGroup: TreeNode = {
...objectGroup("group-triggers", `${connection.id}:app:app:orders:__triggers`),
@@ -105,7 +111,18 @@ describe("sidebar object-group routing", () => {
expect(listTriggers).toHaveBeenCalledWith(connection.id, "app", "app", "orders", undefined);
expect(listObjects).not.toHaveBeenCalled();
expect(storedTriggerGroup).toMatchObject({ isExpanded: true, isLoading: false, children: [] });
expect(storedTriggerGroup).toMatchObject({
isExpanded: true,
isLoading: false,
children: [
{
label: "trg_orders_audit (AFTER UPDATE)",
objectName: "trg_orders_audit",
tableName: "orders",
type: "trigger",
},
],
});
});
it("propagates rejected schema-level metadata while clearing the loading state", async () => {
+2 -2
View File
@@ -656,8 +656,8 @@ export async function completionAssistantSearch(request: CompletionAssistantRequ
return post("/api/schema/completion-assistant", request);
}
export async function getObjectSource(connectionId: string, database: string, schema: string, name: string, objectType: ObjectSourceKind, signature?: string): Promise<ObjectSource> {
return get(`/api/schema/object-source?${qs({ connection_id: connectionId, database, schema, table: name, object_type: objectType, signature })}`);
export async function getObjectSource(connectionId: string, database: string, schema: string, name: string, objectType: ObjectSourceKind, signature?: string, relationName?: string): Promise<ObjectSource> {
return get(`/api/schema/object-source?${qs({ connection_id: connectionId, database, schema, table: name, object_type: objectType, signature, relation_name: relationName })}`);
}
export async function getColumns(connectionId: string, database: string, schema: string, table: string, catalog?: string, clientSessionId?: string): Promise<ColumnInfo[]> {
+2 -2
View File
@@ -832,8 +832,8 @@ export async function completionAssistantSearch(request: CompletionAssistantRequ
return invoke("completion_assistant_search", { request });
}
export async function getObjectSource(connectionId: string, database: string, schema: string, name: string, objectType: ObjectSourceKind, signature?: string): Promise<ObjectSource> {
return invoke("get_object_source", { connectionId, database, schema, name, objectType, signature });
export async function getObjectSource(connectionId: string, database: string, schema: string, name: string, objectType: ObjectSourceKind, signature?: string, relationName?: string): Promise<ObjectSource> {
return invoke("get_object_source", { connectionId, database, schema, name, objectType, signature, relationName });
}
export async function listSchemas(connectionId: string, database: string, applyVisibleFilter = false): Promise<string[]> {
@@ -1,7 +1,7 @@
import type { ObjectSourceKind, TreeNode, TreeNodeType } from "@/types/database";
import { matchesShortcut, type ShortcutLikeEvent } from "@/lib/editor/keyboardShortcuts";
export type TreeNodeRowAction = "open-data" | "toggle" | "none";
export type TreeNodeRowAction = "open-data" | "open-source" | "toggle" | "none";
export type TreeNodeRowDoubleClickAction = "open-data" | "activate-data" | "open-object-browser" | "open-object-browser-and-expand" | "open-source" | "open-saved-sql" | "toggle" | "none";
export type SidebarSelectionCopyAction = "copy-name" | "none";
export type SidebarActivation = "single" | "double";
@@ -36,6 +36,7 @@ export function isDocumentBrowserTreeNode(type: TreeNodeType): boolean {
export function treeNodeRowAction(type: TreeNodeType, canExpand: boolean, activation: SidebarActivation = "single"): TreeNodeRowAction {
if (activation === "double") return "none";
if (dataNodeTypes.has(type)) return "open-data";
if (sourceNodeTypes.has(type)) return "open-source";
if (toggleLeafNodeTypes.has(type)) return "toggle";
if (canExpand) return "toggle";
return "none";