mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 17:22:48 -05:00
Expand account picker support to multiple providers (#23952)
* fix dropdown behavior * expand account picker support to multiple providers * fix tests * fixed unresolved promise issue
This commit is contained in:
@@ -50,7 +50,12 @@ export class AddAccountAction extends Action {
|
||||
// Fire the event that we've started adding accounts
|
||||
this._addAccountStartEmitter.fire();
|
||||
try {
|
||||
await this._accountManagementService.addAccount(this._providerId);
|
||||
if (!this._providerId) {
|
||||
let providerId = await this._accountManagementService.promptProvider();
|
||||
await this._accountManagementService.addAccount(providerId);
|
||||
} else {
|
||||
await this._accountManagementService.addAccount(this._providerId);
|
||||
}
|
||||
this._addAccountCompleteEmitter.fire();
|
||||
} catch (err) {
|
||||
this.logService.error(`Error while adding account: ${err}`);
|
||||
|
||||
@@ -21,7 +21,6 @@ export class AccountPickerViewModel {
|
||||
public selectedTenantId: string | undefined;
|
||||
|
||||
constructor(
|
||||
_providerId: string,
|
||||
@IAccountManagementService private _accountManagementService: IAccountManagementService
|
||||
) {
|
||||
// Create our event emitters
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface IAccountManagementService {
|
||||
getAccountProviderMetadata(): Promise<azdata.AccountProviderMetadata[]>;
|
||||
getAccountsForProvider(providerId: string): Promise<azdata.Account[]>;
|
||||
getAccounts(): Promise<azdata.Account[]>;
|
||||
promptProvider(): Promise<string | undefined>;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ suite('Account picker view model tests', () => {
|
||||
test('Construction - Events are properly defined', () => {
|
||||
// If: I create an account picker viewmodel
|
||||
let mockAccountManagementService = getMockAccountManagementService(false, false);
|
||||
let vm = new AccountPickerViewModel('azure', mockAccountManagementService.object);
|
||||
let vm = new AccountPickerViewModel(mockAccountManagementService.object);
|
||||
|
||||
// Then:
|
||||
// ... The event for the view models should be properly initialized
|
||||
@@ -137,7 +137,7 @@ function getViewModel(
|
||||
ams: TestAccountManagementService,
|
||||
evUpdate: EventVerifierSingle<UpdateAccountListEventParams>
|
||||
): AccountPickerViewModel {
|
||||
let vm = new AccountPickerViewModel('azure', ams);
|
||||
let vm = new AccountPickerViewModel(ams);
|
||||
vm.updateAccountListEvent(evUpdate.eventHandler);
|
||||
|
||||
return vm;
|
||||
|
||||
@@ -59,6 +59,10 @@ export class TestAccountManagementService implements IAccountManagementService {
|
||||
return Promise.resolve(undefined!);
|
||||
}
|
||||
|
||||
promptProvider() {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
|
||||
removeAccount(accountKey: azdata.AccountKey): Promise<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user