fix(xugu): reload package member groups from owner
This commit is contained in:
1 parent
dcbd034afa
commit
50607826d0
6 files changed
+116
-3
No files matched your search
@@ -684,6 +684,20 @@ async function toggle(requestId = beginNavigationRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Xugu package members are represented with the same visual group types as
|
||||
// schema-level procedures/functions, but their children are already loaded
|
||||
// from the owning package specification. Keep this scoped group local:
|
||||
// routing it through loadSidebarObjectGroup would query every routine in the
|
||||
// schema and replace the package's member list with unrelated objects.
|
||||
if (currentDatabaseType() === "xugu" && (node.type === "group-procedures" || node.type === "group-functions") && node.parentType === "package") {
|
||||
node.isExpanded = !node.isExpanded;
|
||||
// Package member groups have no group-level reload path: their children
|
||||
// are hydrated together with the owning package. Releasing a large group
|
||||
// here would leave it empty on the next local-only expand.
|
||||
emitNodeToggled(node, wasExpanded);
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep the click path aligned with every object-group definition. In
|
||||
// particular, schema-level trigger/type groups have no tableName, so they
|
||||
// must use the generic object loader rather than the table-trigger loader.
|
||||
|
||||
+67
@@ -322,4 +322,71 @@ describe("SidebarTreeRuntimeHost expansion", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("toggles Xugu package member groups locally instead of loading schema routines", async () => {
|
||||
const packageFunctionGroup: TreeNode = {
|
||||
id: "xugu:SHOP_DEMO:APP_TEST:package:PKG_CUSTOMER:members:functions",
|
||||
label: "tree.functions",
|
||||
type: "group-functions",
|
||||
parentType: "package",
|
||||
parentName: "PKG_CUSTOMER",
|
||||
parentSchema: "APP_TEST",
|
||||
connectionId: "xugu",
|
||||
database: "SHOP_DEMO",
|
||||
schema: "APP_TEST",
|
||||
objectCount: 401,
|
||||
isExpanded: false,
|
||||
children: Array.from({ length: 401 }, (_, index) => ({
|
||||
id: `xugu:SHOP_DEMO:APP_TEST:package:PKG_CUSTOMER:member:function:FUNC_${index}`,
|
||||
label: `FUNC_${index}()`,
|
||||
type: "function" as const,
|
||||
parentType: "package" as const,
|
||||
parentName: "PKG_CUSTOMER",
|
||||
parentSchema: "APP_TEST",
|
||||
connectionId: "xugu",
|
||||
database: "SHOP_DEMO",
|
||||
schema: "APP_TEST",
|
||||
objectName: `FUNC_${index}`,
|
||||
signature: "",
|
||||
})),
|
||||
};
|
||||
connectionStore.treeNodes = [packageFunctionGroup];
|
||||
connectionStore.getConfig.mockReturnValue({ db_type: "xugu" });
|
||||
connectionStore.canUseLoadedTreeNodeToggle.mockReturnValue(false);
|
||||
|
||||
const host = ref<InstanceType<typeof SidebarTreeRuntimeHost> | null>(null);
|
||||
const toggled = vi.fn();
|
||||
const app = createApp(
|
||||
defineComponent({
|
||||
setup: () => () => h(SidebarTreeRuntimeHost, { ref: host, node: packageFunctionGroup, depth: 0, onNodeToggled: toggled }),
|
||||
}),
|
||||
);
|
||||
mountedApps.push(app);
|
||||
const container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
app.use(i18n);
|
||||
app.mount(container);
|
||||
|
||||
host.value?.toggleNode(packageFunctionGroup);
|
||||
await nextTick();
|
||||
|
||||
expect(packageFunctionGroup.isExpanded).toBe(true);
|
||||
expect(connectionStore.loadObjectGroupChildren).not.toHaveBeenCalled();
|
||||
expect(toggled).toHaveBeenCalledWith(packageFunctionGroup, true);
|
||||
|
||||
host.value?.toggleNode(packageFunctionGroup);
|
||||
await nextTick();
|
||||
|
||||
expect(packageFunctionGroup.isExpanded).toBe(false);
|
||||
expect(connectionStore.loadObjectGroupChildren).not.toHaveBeenCalled();
|
||||
|
||||
expect(connectionStore.releaseCollapsedTreeNodeChildren).not.toHaveBeenCalled();
|
||||
expect(packageFunctionGroup.children).toHaveLength(401);
|
||||
|
||||
host.value?.toggleNode(packageFunctionGroup);
|
||||
await nextTick();
|
||||
|
||||
expect(packageFunctionGroup.isExpanded).toBe(true);
|
||||
expect(packageFunctionGroup.children).toHaveLength(401);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user