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 6c8da753..e6cbf806 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.viewPermissions", + "title": "View permissions", + "category": "Db2 for i" } ], "menus": { @@ -177,6 +182,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/index.ts b/src/views/schemaBrowser/index.ts index 4503ced3..0ed41354 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.viewPermissions`, 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));