From 9d77129df9cde3ed482b83f27f3765ee7588f086 Mon Sep 17 00:00:00 2001 From: DF Date: Sun, 24 Nov 2024 17:29:37 -0500 Subject: [PATCH 1/2] Add "View authorities" option on SQL objects. --- src/views/schemaBrowser/contributes.json | 10 ++++++++++ src/views/schemaBrowser/index.ts | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/views/schemaBrowser/contributes.json b/src/views/schemaBrowser/contributes.json index 6c8da753..4ac110b2 100644 --- a/src/views/schemaBrowser/contributes.json +++ b/src/views/schemaBrowser/contributes.json @@ -95,6 +95,11 @@ "title": "Set filter", "category": "Db2 for i", "icon": "$(search)" + }, + { + "command": "vscode-db2i.viewAuthorities", + "title": "View authorities", + "category": "Db2 for i" } ], "menus": { @@ -177,6 +182,11 @@ "when": "viewItem == table || viewItem == view || viewItem == index", "group": "db2data@4" }, + { + "command": "vscode-db2i.viewAuthorities", + "when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type", + "group": "db2data@5" + }, { "command": "vscode-db2i.advisedIndexes", "when": "viewItem == table || viewItem == schema", diff --git a/src/views/schemaBrowser/index.ts b/src/views/schemaBrowser/index.ts index 4503ced3..d35ff3ae 100644 --- a/src/views/schemaBrowser/index.ts +++ b/src/views/schemaBrowser/index.ts @@ -162,6 +162,22 @@ export default class schemaBrowser { } }), + vscode.commands.registerCommand(`vscode-db2i.viewAuthorities`, async (object: SQLObject) => { + if (object) { + const content = `SELECT AUTHORIZATION_NAME, OBJECT_AUTHORITY, + OWNER, OBJECT_OPERATIONAL, OBJECT_MANAGEMENT, OBJECT_EXISTENCE, OBJECT_ALTER, OBJECT_REFERENCE, + DATA_READ, DATA_ADD, DATA_UPDATE, DATA_DELETE, DATA_EXECUTE FROM QSYS2.OBJECT_PRIVILEGES + WHERE OBJECT_SCHEMA='${object.schema}' AND OBJECT_NAME='${object.name}' AND + SQL_OBJECT_TYPE='${object.type.toUpperCase()}'`; + + vscode.commands.executeCommand(`vscode-db2i.runEditorStatement`, { + content, + qualifier: `statement`, + open: false, + }); + } + }), + vscode.commands.registerCommand(`vscode-db2i.getMTIs`, async (object: SQLObject|SchemaItem) => { if (object) { const content = getMTIStatement(object.schema, (`name` in object ? object.name : undefined)); From 72656f7ef590670e9f37abc42bb9a55c32ed0418 Mon Sep 17 00:00:00 2001 From: DF Date: Tue, 3 Dec 2024 21:16:29 -0500 Subject: [PATCH 2/2] Change "View authorities" to "View permissions" --- package.json | 10 ++++++++++ src/views/schemaBrowser/contributes.json | 6 +++--- src/views/schemaBrowser/index.ts | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 991af5aa..f1e92364 100644 --- a/package.json +++ b/package.json @@ -379,6 +379,11 @@ "category": "Db2 for i", "icon": "$(search)" }, + { + "command": "vscode-db2i.viewPermissions", + "title": "View permissions", + "category": "Db2 for i" + }, { "command": "vscode-db2i.runEditorStatement", "title": "Run statement", @@ -940,6 +945,11 @@ "when": "viewItem == table || viewItem == view || viewItem == index", "group": "db2data@4" }, + { + "command": "vscode-db2i.viewPermissions", + "when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type", + "group": "db2data@5" + }, { "command": "vscode-db2i.advisedIndexes", "when": "viewItem == table || viewItem == schema", diff --git a/src/views/schemaBrowser/contributes.json b/src/views/schemaBrowser/contributes.json index 4ac110b2..e6cbf806 100644 --- a/src/views/schemaBrowser/contributes.json +++ b/src/views/schemaBrowser/contributes.json @@ -97,8 +97,8 @@ "icon": "$(search)" }, { - "command": "vscode-db2i.viewAuthorities", - "title": "View authorities", + "command": "vscode-db2i.viewPermissions", + "title": "View permissions", "category": "Db2 for i" } ], @@ -183,7 +183,7 @@ "group": "db2data@4" }, { - "command": "vscode-db2i.viewAuthorities", + "command": "vscode-db2i.viewPermissions", "when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type", "group": "db2data@5" }, diff --git a/src/views/schemaBrowser/index.ts b/src/views/schemaBrowser/index.ts index d35ff3ae..0ed41354 100644 --- a/src/views/schemaBrowser/index.ts +++ b/src/views/schemaBrowser/index.ts @@ -162,7 +162,7 @@ export default class schemaBrowser { } }), - vscode.commands.registerCommand(`vscode-db2i.viewAuthorities`, async (object: SQLObject) => { + vscode.commands.registerCommand(`vscode-db2i.viewPermissions`, async (object: SQLObject) => { if (object) { const content = `SELECT AUTHORIZATION_NAME, OBJECT_AUTHORITY, OWNER, OBJECT_OPERATIONAL, OBJECT_MANAGEMENT, OBJECT_EXISTENCE, OBJECT_ALTER, OBJECT_REFERENCE,