feat(sidebar): copy display paths for all database types

This commit is contained in:
lxk955 authored and GitHub committed 2026-10-03 13:44:40 +08:00
1 parent 8dc1297f6a
commit 30a4131bb2
3 files changed
+142 -12

No files matched your search

@@ -2369,7 +2369,7 @@ async function copyDisplayPath() {
function copyNameMenuItem(): ContextMenuItem {
const node = activeNode.value;
const connectionName = node.connectionId ? connectionStore.getConfig(node.connectionId)?.name || "" : "";
if (currentDatabaseType() === "mysql" && copyDisplayPathForTreeNode(node, connectionName)) {
if (copyDisplayPathForTreeNode(node, connectionName)) {
return {
label: t("contextMenu.copyName"),
icon: Copy,
@@ -6521,9 +6521,7 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
if (!isPackageMember && canViewDatabaseObjectDependencies(currentDatabaseType(), node)) {
items.push({ label: t("contextMenu.viewDependencies"), action: openDatabaseObjectDependencies, icon: Network });
}
if (currentDatabaseType() === "mysql") {
items.push(copyNameMenuItem());
}
items.push(copyNameMenuItem());
if (!isPackageMember && canRenameObject.value) {
items.push({
label: t("contextMenu.renameObject"),
@@ -6569,7 +6567,7 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
if (currentDatabaseType() === "oceanbase-oracle") {
items.push({ label: t("contextMenu.editObject"), action: () => openObjectSourceDialog(true), icon: Pencil });
}
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
items.push(copyNameMenuItem());
items.push({ label: t("contextMenu.changeOpenMode"), action: () => emit("open-settings", "navigation"), icon: Settings2 });
return true;
}
@@ -6605,7 +6603,7 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
icon: Code2,
});
}
items.push(node.type === "trigger" ? copyNameMenuItem() : { label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
items.push(copyNameMenuItem());
items.push({ label: t("contextMenu.changeOpenMode"), action: () => emit("open-settings", "navigation"), icon: Settings2 });
return true;
}
@@ -6615,7 +6613,7 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
if (node.type === "type" || node.type === "type-body") {
if (supportsTypeObjectSource(currentDatabaseType())) {
items.push({ label: t("contextMenu.viewSource"), action: () => openObjectSourceDialog(false), icon: Code2 });
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
items.push(copyNameMenuItem());
items.push({ label: t("contextMenu.changeOpenMode"), action: () => emit("open-settings", "navigation"), icon: Settings2 });
return true;
}
@@ -6623,7 +6621,7 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
items.push({ label: t("contextMenu.copyDdl"), action: copyCustomTypeDdl, icon: Copy });
items.push({ label: "", separator: true });
}
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
items.push(copyNameMenuItem());
return true;
}
return false;
+23 -4
View File
@@ -72,7 +72,7 @@ const databaseChildGroupNodeTypes = new Set<TreeNodeType>([
"group-packages",
"group-types",
]);
const displayPathObjectNodeTypes = new Set<TreeNodeType>(["table", "view", "materialized_view", "procedure", "function", "trigger", "event"]);
const displayPathObjectNodeTypes = new Set<TreeNodeType>(["table", "view", "materialized_view", "procedure", "function", "trigger", "event", "sequence", "synonym", "package", "package-body", "type", "type-body"]);
export function objectSourceKindForTreeNode(type: TreeNodeType): ObjectSourceKind | null {
if (type === "view") return "VIEW";
@@ -198,9 +198,28 @@ export function copyNameForTreeNode(node: TreeNode): string {
export function copyDisplayPathForTreeNode(node: TreeNode, connectionName: string): string | null {
const connection = connectionName.trim();
const database = node.database?.trim();
if (!connection || !database) return null;
if (node.type === "database") return `${connection}.${database}`;
const schema = (node.schema || (node.type === "schema" ? node.label : undefined))?.trim();
if (!connection) return null;
if (!database && !schema) return null;
if (node.type === "database") {
return database ? `${connection}.${database}` : null;
}
if (node.type === "schema") {
const parts = [connection];
if (database) parts.push(database);
if (schema && schema !== database) parts.push(schema);
return parts.length > 1 ? parts.join(".") : null;
}
if (!displayPathObjectNodeTypes.has(node.type)) return null;
const objectName = (node.objectName || (node.type === "table" ? node.tableName : undefined) || node.label).trim();
return objectName ? `${connection}.${database}.${objectName}` : null;
if (!objectName) return null;
const parts = [connection];
if (database) parts.push(database);
if (schema && schema !== database) parts.push(schema);
parts.push(objectName);
return parts.join(".");
}