From 1d55facfe3f195a02dd3210edfdad438ff5f3121 Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Wed, 12 May 2021 19:27:04 -0700 Subject: [PATCH] fix azure context menu (#15447) * fix azure context menu * fix node issue * change to undefined * just use interface * set connection profile * add save profile --- .../azurecore/src/azureResource/commands.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/azurecore/src/azureResource/commands.ts b/extensions/azurecore/src/azureResource/commands.ts index a23d4c688e..54a7f1588f 100644 --- a/extensions/azurecore/src/azureResource/commands.ts +++ b/extensions/azurecore/src/azureResource/commands.ts @@ -181,17 +181,22 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT vscode.commands.executeCommand('workbench.actions.modal.linkedAccount'); }); - vscode.commands.registerCommand('azure.resource.connectsqlserver', async (node?: TreeNode) => { + vscode.commands.registerCommand('azure.resource.connectsqlserver', async (node?: TreeNode | azdata.ObjectExplorerContext) => { if (!node) { return; } - - const treeItem: azdata.TreeItem = await node.getTreeItem(); - if (!treeItem.payload) { - return; + let connectionProfile: azdata.IConnectionProfile = undefined; + if (node instanceof TreeNode) { + const treeItem: azdata.TreeItem = await node.getTreeItem(); + if (!treeItem.payload) { + return; + } + // Ensure connection is saved to the Connections list, then open connection dialog + connectionProfile = Object.assign({}, treeItem.payload, { saveProfile: true }); + } else if (node.isConnectionNode) { + connectionProfile = Object.assign({}, node.connectionProfile, { saveProfile: true }); } - // Ensure connection is saved to the Connections list, then open connection dialog - let connectionProfile = Object.assign({}, treeItem.payload, { saveProfile: true }); + const conn = await azdata.connection.openConnectionDialog(undefined, connectionProfile, { saveConnection: true, showDashboard: true }); if (conn) { vscode.commands.executeCommand('workbench.view.connections');