дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
feat(plugins): expose database table menus and read-only schema (#7372)
Plugin API 1.20 adds wit/database.wit with describe-table behind the database.schema capability: a read-only view of a connected source's table (columns, keys, indexes) through DbManager::connected_table_details. Plugins can contribute database.table.context menu entries (needs_api 20) that receive the non-secret table identity and the when keys databaseDriver, databaseObjectKind, databaseSchema, databaseTable and databaseSelectionCount. Co-authored-by: gejun123456 <[email protected]>
Цей коміт міститься в:
1 джерело
abc5b2b2c6
коміт
b7c2d4eacb
201 files changed
+1180
-176
No files matched your search
@@ -1,5 +1,6 @@
|
||||
/** Menus of the Database tool window, laid out like IDEA's (New ▸, Copy/Paste ▸, SQL Scripts ▸ …). */
|
||||
import { choosePath } from "@/platform/choosePath";
|
||||
import { pluginDatabaseTableMenuItems } from "@/features/plugins/uiPoints";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import type { MenuItem } from "@/ui";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
@@ -194,6 +195,24 @@ function batchSourceMenu(sources: Extract<DbNode, { kind: "source" }>[]): MenuIt
|
||||
|
||||
/** Context menu of a tree node (`null`: the empty area). */
|
||||
export function nodeMenu(n: DbNode | null, selection: readonly DbNode[] = []): MenuItem[] {
|
||||
const builtin = builtinNodeMenu(n, selection);
|
||||
if (n?.kind !== "table") return builtin;
|
||||
const selected = selection.some((node) => node.key === n.key) ? selection : [n];
|
||||
// Mixed selections cannot be represented as a table command; do not silently drop nodes.
|
||||
if (!selected.every((node) => node.kind === "table")) return builtin;
|
||||
const tables = selected.map((node) => ({
|
||||
sourceId: node.id,
|
||||
catalog: node.catalog ?? null,
|
||||
schema: node.schema,
|
||||
table: node.table.name,
|
||||
kind: node.table.kind,
|
||||
driver: sourceById(node.id)?.driver ?? "",
|
||||
}));
|
||||
const plugins = pluginDatabaseTableMenuItems(tables);
|
||||
return plugins.length ? [...builtin, sep, ...plugins] : builtin;
|
||||
}
|
||||
|
||||
function builtinNodeMenu(n: DbNode | null, selection: readonly DbNode[] = []): MenuItem[] {
|
||||
if (!n) return [{ label: "New", icon: "plus", submenu: newMenu() }];
|
||||
if (n.kind === "workspace")
|
||||
return [
|
||||
|
||||
Reference in new issue
Заблокувати користувача