fix azure context menu (#15447)

* fix azure context menu

* fix node issue

* change to undefined

* just use interface

* set connection profile

* add save profile
This commit is contained in:
Aditya Bist
2021-05-12 19:27:04 -07:00
committed by GitHub
parent 70b0d89b5d
commit 1d55facfe3

View File

@@ -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');