Skip to content

Commit ac7d637

Browse files
committed
working table and db context menus
1 parent 0bfeb37 commit ac7d637

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@
8282
"objectExplorer/item/context": [
8383
{
8484
"command": "extension.testmenus",
85+
"when": "connectionProvider == MSSQL && nodeType",
86+
"group": "FRK"
87+
},
88+
{
89+
"command": "extension.run_sp_blitzindex",
8590
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
8691
"group": "FRK"
8792
},
8893
{
8994
"command": "extension.run_sp_blitzindex",
90-
"when": "connectionProvider == MSSQL && nodeType",
95+
"when": "connectionProvider == MSSQL && nodeType && nodeType == Table",
9196
"group": "FRK"
9297
}
9398
]

src/extension.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,27 @@ export function activate(context: vscode.ExtensionContext) {
106106
let scriptText = '';
107107
if (context) {
108108
let scriptType = context.nodeInfo.nodeType;
109+
fileName = context.nodeInfo.label + '-' + fileName;
110+
var nodeBreakdown = context.nodeInfo.nodePath.split("/");
111+
let dbName = nodeBreakdown[2];
109112
switch (scriptType) {
110113
case "Database": {
111114
scriptText = `EXEC [dbo].[sp_BlitzIndex]
112-
@DatabaseName = '${context.nodeInfo.label}',
115+
@DatabaseName = '${dbName}',
113116
--@TableName = '',
114117
@Mode = 4
115118
--0=Diagnose, 1=Summarize, 2=Index Usage Detail, 3=Missing Index Detail, 4=Diagnose Details`;
116119
break;
117120
}
121+
case "Table": {
122+
var tblParts = context.nodeInfo.label.split(".");
123+
let tblName = tblParts[1];
124+
scriptText = `EXEC [dbo].[sp_BlitzIndex]
125+
@DatabaseName = '${dbName}',
126+
@TableName = '${tblName}'
127+
`;
128+
break;
129+
}
118130
default: {
119131
scriptText = `EXEC [dbo].[sp_BlitzIndex]
120132
@DatabaseName = '',

0 commit comments

Comments
 (0)