Connection management service updates to support multiple providers (#9698)

* Connection management service work

* Fix tests

* Change how accounts are deleted

* Be consistent with names

* feedback

* Fix based on feedback

* Change sqltoolsservice version
This commit is contained in:
Amir Omidi
2020-03-25 12:48:01 -07:00
committed by GitHub
parent 74b0dc28c4
commit 176edde2aa
15 changed files with 162 additions and 41 deletions

View File

@@ -780,9 +780,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti
return true;
}
let azureResource = this.getAzureResourceForConnection(connection);
let accounts = await this._accountManagementService.getAccountsForProvider('azurePublicCloud');
let accounts = (await this._accountManagementService.getAccounts()).filter(a => a.key.providerId.startsWith('azure'));
if (accounts && accounts.length > 0) {
let accountName = (connection.authenticationType !== Constants.azureMFA) ? connection.azureAccount : connection.userName;
let accountName = (connection.authenticationType === Constants.azureMFA) ? connection.azureAccount : connection.userName;
let account = find(accounts, account => account.key.accountId === accountName);
if (account) {
if (account.isStale) {

View File

@@ -56,7 +56,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
private _azureTenantDropdown: SelectBox;
private _refreshCredentialsLink: HTMLLinkElement;
private _addAzureAccountMessage: string = localize('connectionWidget.AddAzureAccount', "Add an account...");
private readonly _azureProviderId = 'azurePublicCloud';
private readonly _azureProviderId = 'azure_publicCloud';
private _azureTenantId: string;
private _azureAccountList: azdata.Account[];
private _callbacks: IConnectionComponentCallbacks;
@@ -518,7 +518,8 @@ export class ConnectionWidget extends lifecycle.Disposable {
private async fillInAzureAccountOptions(): Promise<void> {
let oldSelection = this._azureAccountDropdown.value;
this._azureAccountList = await this._accountManagementService.getAccountsForProvider(this._azureProviderId);
const accounts = await this._accountManagementService.getAccounts();
this._azureAccountList = accounts.filter(a => a.key.providerId.startsWith('azure'));
let accountDropdownOptions = this._azureAccountList.map(account => account.key.accountId);
if (accountDropdownOptions.length === 0) {
// If there are no accounts add a blank option so that add account isn't automatically selected
@@ -821,7 +822,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
}
public get azureAccount(): string {
return this.authenticationType === AuthenticationType.AzureMFAAndUser ? this._azureAccountDropdown.value : undefined;
return this.authenticationType === AuthenticationType.AzureMFAAndUser || this.authenticationType === AuthenticationType.AzureMFA ? this._azureAccountDropdown.value : undefined;
}
private validateAzureAccountSelection(showMessage: boolean = true): boolean {