Fixes ADS Web bug around copying user codes and opening a browser tab when adding an Azure Account. (#17760)

* Fixes bug around copying user codes and opening a browser tab.

* Code review changes

* Additional review changes.

* Unnecessary import removed
This commit is contained in:
Lewis Sanchez
2021-11-30 10:37:56 -08:00
committed by GitHub
parent 917a30e66f
commit c073897056
4 changed files with 9 additions and 9 deletions

View File

@@ -21,7 +21,6 @@ import { localize } from 'vs/nls';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { URI } from 'vs/base/common/uri';
import { values } from 'vs/base/common/collections';
import { onUnexpectedError } from 'vs/base/common/errors';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService, Severity, INotification } from 'vs/platform/notification/common/notification';
import { Action } from 'vs/base/common/actions';
@@ -362,9 +361,10 @@ export class AccountManagementService implements IAccountManagementService {
/**
* Copy the user code to the clipboard and open a browser to the verification URI
*/
public copyUserCodeAndOpenBrowser(userCode: string, uri: string): void {
this._clipboardService.writeText(userCode).catch(err => onUnexpectedError(err));
this._openerService.open(URI.parse(uri)).catch(err => onUnexpectedError(err));
public async copyUserCodeAndOpenBrowser(userCode: string, uri: string): Promise<void> {
await this._clipboardService.writeText(userCode);
await this._openerService.open(URI.parse(uri));
}
private async _registerProvider(providerMetadata: azdata.AccountProviderMetadata, provider: azdata.AccountProvider): Promise<void> {

View File

@@ -72,9 +72,9 @@ export class AutoOAuthDialogController {
this._providerId = undefined;
}
private handleOnAddAccount(): void {
private async handleOnAddAccount(): Promise<void> {
if (this._userCode && this._uri) {
this._accountManagementService.copyUserCodeAndOpenBrowser(this._userCode, this._uri);
return this._accountManagementService.copyUserCodeAndOpenBrowser(this._userCode, this._uri);
} else {
throw new Error('Missing user code and uri');
}