feat(xugu): add object dependency inspection
This commit is contained in:
1 parent
dc7b905220
commit
c0c97ef0e4
13 files changed
+252
No files matched your search
@@ -85,6 +85,7 @@ import { loadSidebarObjectGroup } from "@/lib/sidebar/sidebarObjectGroupRouting"
|
||||
import { isXuguTypeMemberContainer } from "@/lib/sidebar/xuguTypeMembers";
|
||||
import { isXuguSyntheticTreeNode } from "@/lib/sidebar/xuguPublicSynonyms";
|
||||
import { buildXuguSchedulerJobSql, type XuguSchedulerJobAction } from "@/lib/database/xuguSchedulerJobSql";
|
||||
import { canViewDatabaseObjectDependencies, databaseDependencyProviderFor } from "@/lib/database/databaseObjectDependencies";
|
||||
import { elasticsearchClearIndexPreview, isElasticsearchClearConfirmed, isElasticsearchIndexPattern } from "@/lib/sidebar/elasticsearchIndexActions";
|
||||
import { mysqlObjectTemplateForGroup } from "@/lib/sidebar/mysqlObjectTemplates";
|
||||
import { buildTableDeleteTemplate, buildTableInsertTemplate, buildTableSelectTemplate, buildTableUpdateTemplate } from "@/lib/table/tableSqlTemplates";
|
||||
@@ -2492,6 +2493,25 @@ function openProcedureExecution() {
|
||||
emit("open-procedure", node);
|
||||
}
|
||||
|
||||
async function openDatabaseObjectDependencies() {
|
||||
const node = activeNode.value;
|
||||
const provider = databaseDependencyProviderFor(currentDatabaseType());
|
||||
if (!provider || !node.connectionId || !node.database || !provider.supports(node)) return;
|
||||
const sql = provider.buildQuery(node);
|
||||
if (!sql) return;
|
||||
|
||||
try {
|
||||
await connectionStore.ensureConnected(node.connectionId);
|
||||
connectionStore.activeConnectionId = node.connectionId;
|
||||
const objectName = node.objectName || node.label;
|
||||
const tabId = queryStore.createTab(node.connectionId, node.database, `${t("contextMenu.viewDependencies")} - ${objectName}`, "query", node.schema, undefined, node.catalog, { forceNew: true });
|
||||
queryStore.updateSql(tabId, sql);
|
||||
await queryStore.executeTabSql(tabId, sql);
|
||||
} catch (e: any) {
|
||||
toast(t("contextMenu.tableOperationFailed", { message: e?.message || String(e) }), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
async function compileXuguObject() {
|
||||
const node = activeNode.value;
|
||||
if (currentDatabaseType() !== "xugu" || !node.connectionId || !node.database) return;
|
||||
@@ -5789,6 +5809,9 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
icon: FileCode,
|
||||
});
|
||||
}
|
||||
if (canViewDatabaseObjectDependencies(currentDatabaseType(), node)) {
|
||||
items.push({ label: t("contextMenu.viewDependencies"), action: openDatabaseObjectDependencies, icon: Network });
|
||||
}
|
||||
if (node.type === "view" || node.type === "materialized_view") {
|
||||
items.push({ label: t("contextMenu.editView"), action: () => openObjectSourceDialog(true), icon: Pencil });
|
||||
items.push({ label: t("contextMenu.viewSource"), action: () => openObjectSourceDialog(false), icon: Code2 });
|
||||
@@ -5930,6 +5953,9 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
if (currentDatabaseType() === "xugu" && buildXuguCompileSql({ objectType: node.type, schema: node.schema, name: node.objectName || node.label })) {
|
||||
items.push({ label: t("contextMenu.compileObject"), action: compileXuguObject, icon: Wrench });
|
||||
}
|
||||
if (canViewDatabaseObjectDependencies(currentDatabaseType(), node)) {
|
||||
items.push({ label: t("contextMenu.viewDependencies"), action: openDatabaseObjectDependencies, icon: Network });
|
||||
}
|
||||
if (node.type === "index" && canOpenStructureEditor.value) {
|
||||
items.push({ label: "", separator: true });
|
||||
items.push({ label: t("contextMenu.editIndex"), action: openStructureEditor, icon: PencilRuler });
|
||||
@@ -5966,6 +5992,9 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
items.push({ label: t("contextMenu.compileObject"), action: compileXuguObject, icon: Wrench });
|
||||
}
|
||||
items.push({ label: t("contextMenu.viewSource"), action: () => openObjectSourceDialog(false), icon: Code2 });
|
||||
if (!isPackageMember && canViewDatabaseObjectDependencies(currentDatabaseType(), node)) {
|
||||
items.push({ label: t("contextMenu.viewDependencies"), action: openDatabaseObjectDependencies, icon: Network });
|
||||
}
|
||||
if (currentDatabaseType() === "mysql") {
|
||||
items.push(copyNameMenuItem());
|
||||
}
|
||||
@@ -6031,6 +6060,9 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
items.push({ label: t("contextMenu.compileObject"), action: compileXuguObject, icon: Wrench });
|
||||
}
|
||||
items.push({ label: t("contextMenu.viewSource"), action: () => openObjectSourceDialog(false), icon: Code2 });
|
||||
if (canViewDatabaseObjectDependencies(currentDatabaseType(), node)) {
|
||||
items.push({ label: t("contextMenu.viewDependencies"), action: openDatabaseObjectDependencies, icon: Network });
|
||||
}
|
||||
if (node.type === "package" && currentDatabaseType() === "xugu" && node.xuguPackageBodyAvailable === true) {
|
||||
items.push({
|
||||
label: `${t("contextMenu.viewSource")} (${t("objects.packageBody")})`,
|
||||
|
||||
Reference in new issue
Block a user