Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "View authorities" option on SQL objects. Resolves codefori/vscode-db2i#266 #301

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions src/views/schemaBrowser/contributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions src/views/schemaBrowser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading