From 9b7a7bd9dcdb4d93458c9fa1cf6eb2f37986fcfe Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Fri, 23 Aug 2019 14:50:08 -0700 Subject: [PATCH] Alanren/extension install (#6918) * fix extension install * fix azure account open url issue --- .../browser/accountManagementService.ts | 7 +++++-- .../test/browser/accountManagementService.test.ts | 2 +- .../extensions/browser/extensionsWorkbenchService.ts | 9 +++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts b/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts index edbf87cbe0..dcab85f8cf 100644 --- a/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts +++ b/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts @@ -18,6 +18,8 @@ import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 's import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces'; import { Deferred } from 'sql/base/common/promise'; import { localize } from 'vs/nls'; +import { IOpenerService } from 'vs/platform/opener/common/opener'; +import { URI } from 'vs/base/common/uri'; export class AccountManagementService implements IAccountManagementService { // CONSTANTS /////////////////////////////////////////////////////////// @@ -46,7 +48,8 @@ export class AccountManagementService implements IAccountManagementService { private _mementoObj: object, @IInstantiationService private _instantiationService: IInstantiationService, @IStorageService private _storageService: IStorageService, - @IClipboardService private _clipboardService: IClipboardService + @IClipboardService private _clipboardService: IClipboardService, + @IOpenerService private _openerService: IOpenerService ) { // Create the account store if (!this._mementoObj) { @@ -310,7 +313,7 @@ export class AccountManagementService implements IAccountManagementService { */ public copyUserCodeAndOpenBrowser(userCode: string, uri: string): void { this._clipboardService.writeText(userCode); - window.open(uri); + this._openerService.open(URI.parse(uri)); } // SERVICE MANAGEMENT METHODS ////////////////////////////////////////// diff --git a/src/sql/workbench/services/accountManagement/test/browser/accountManagementService.test.ts b/src/sql/workbench/services/accountManagement/test/browser/accountManagementService.test.ts index 1e469f6aa3..05dd0e686b 100644 --- a/src/sql/workbench/services/accountManagement/test/browser/accountManagementService.test.ts +++ b/src/sql/workbench/services/accountManagement/test/browser/accountManagementService.test.ts @@ -567,7 +567,7 @@ function getTestState(): AccountManagementState { let mockMemento = {}; // Create the account management service - let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, new TestStorageService(), null); + let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, new TestStorageService(), null, null); // Wire up event handlers let evUpdate = new EventVerifierSingle(); diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts index 3a553d299a..5386319541 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts @@ -39,8 +39,8 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { IProductService } from 'vs/platform/product/common/product'; import { asDomUri } from 'vs/base/browser/dom'; -// {{SQL CARBON EDIT}} -import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator'; +import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator'; // {{SQL CARBON EDIT}} +import { IOpenerService } from 'vs/platform/opener/common/opener'; // {{SQL CARBON EDIT}} interface IExtensionStateProvider { (extension: Extension): T; @@ -516,7 +516,8 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension @IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService, @IStorageService private readonly storageService: IStorageService, @IModeService private readonly modeService: IModeService, - @IProductService private readonly productService: IProductService + @IProductService private readonly productService: IProductService, + @IOpenerService private readonly openerService: IOpenerService // {{SQL CARBON EDIT}} ) { super(); if (this.extensionManagementServerService.localExtensionManagementServer) { @@ -852,7 +853,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension // {{SQL CARBON EDIT}} private downloadOrBrowse(ext: IExtension): Promise { if (ext.gallery.assets.downloadPage && ext.gallery.assets.downloadPage.uri) { - window.open(ext.gallery.assets.downloadPage.uri); + this.openerService.open(URI.parse(ext.gallery.assets.downloadPage.uri)); return Promise.resolve(undefined); } else { return this.extensionService.installFromGallery(ext.gallery);