bring Azure context menu to the new tree and enhance start cloud shell command (#13101)

* bring context menu to the new tree

* enhance start cloud shell command

* text
This commit is contained in:
Alan Ren
2020-10-28 13:48:28 -07:00
committed by GitHub
parent 281592fa97
commit 1d4398388c
3 changed files with 86 additions and 38 deletions

View File

@@ -30,14 +30,35 @@ export function registerAzureResourceCommands(appContext: AppContext, trees: (Az
vscode.window.showInformationMessage(msg);
return;
}
if (!node || !(node instanceof AzureResourceAccountTreeNode)) {
return;
let azureAccount: AzureAccount | undefined;
if (node instanceof AzureResourceAccountTreeNode) {
azureAccount = node.account as AzureAccount;
} else {
let accounts = await azdata.accounts.getAllAccounts();
accounts = accounts.filter(a => a.key.providerId.startsWith('azure'));
if (accounts.length === 0) {
const signin = localize('azure.signIn', "Sign in");
const action = await vscode.window.showErrorMessage(localize('azure.noAccountError', "You are not currently signed into any Azure accounts, Please sign in and then try again."),
signin);
if (action === signin) {
vscode.commands.executeCommand('azure.resource.signin');
}
return;
} else if (accounts.length === 1) {
azureAccount = accounts[0];
} else {
const pickedAccount = await vscode.window.showQuickPick(accounts.map(account => account.displayInfo.displayName), {
canPickMany: false,
placeHolder: localize('azure.pickAnAzureAccount', "Select an Azure account")
});
if (!pickedAccount) {
vscode.window.showErrorMessage(localize('azure.accountNotSelectedError', "You must select an Azure account for this feature to work."));
return;
}
azureAccount = accounts.find(acct => acct.displayInfo.displayName === pickedAccount);
}
}
const accountNode = node as AzureResourceAccountTreeNode;
const azureAccount = accountNode.account as AzureAccount;
const terminalService = appContext.getService<IAzureTerminalService>(AzureResourceServiceNames.terminalService);
const listOfTenants = azureAccount.properties.tenants.map(t => t.displayName);