diff --git a/src/sql/workbench/browser/enablePreviewFeatures.ts b/src/sql/workbench/browser/enablePreviewFeatures.ts index 70f3da65ee..ea4cbab8a6 100644 --- a/src/sql/workbench/browser/enablePreviewFeatures.ts +++ b/src/sql/workbench/browser/enablePreviewFeatures.ts @@ -4,8 +4,24 @@ *--------------------------------------------------------------------------------------------*/ import { AbstractEnablePreviewFeatures } from 'sql/workbench/common/enablePreviewFeatures'; +import { IStorageService } from 'vs/platform/storage/common/storage'; +import { INotificationService } from 'vs/platform/notification/common/notification'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export class BrowserEnablePreviewFeatures extends AbstractEnablePreviewFeatures { + + constructor( + @IStorageService storageService: IStorageService, + @INotificationService notificationService: INotificationService, + @IHostService hostService: IHostService, + @IConfigurationService configurationService: IConfigurationService + ) { + super(storageService, notificationService, hostService, configurationService); + + this.handlePreviewFeatures(); + } + protected async getWindowCount(): Promise { return 1; } diff --git a/src/sql/workbench/common/enablePreviewFeatures.ts b/src/sql/workbench/common/enablePreviewFeatures.ts index 3f3d9122fa..69454c96d1 100644 --- a/src/sql/workbench/common/enablePreviewFeatures.ts +++ b/src/sql/workbench/common/enablePreviewFeatures.ts @@ -16,44 +16,46 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib private static ENABLE_PREVIEW_FEATURES_SHOWN = 'workbench.enablePreviewFeaturesShown'; constructor( - @IStorageService storageService: IStorageService, - @INotificationService notificationService: INotificationService, - @IHostService hostService: IHostService, - @IConfigurationService configurationService: IConfigurationService - ) { - let previewFeaturesEnabled = configurationService.getValue('workbench')['enablePreviewFeatures']; - if (previewFeaturesEnabled || storageService.get(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, StorageScope.GLOBAL)) { + @IStorageService private readonly storageService: IStorageService, + @INotificationService private readonly notificationService: INotificationService, + @IHostService private readonly hostService: IHostService, + @IConfigurationService private readonly configurationService: IConfigurationService + ) { } + + protected async handlePreviewFeatures(): Promise { + let previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures']; + if (previewFeaturesEnabled || this.storageService.get(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, StorageScope.GLOBAL)) { return; } Promise.all([ - hostService.hasFocus, + this.hostService.hasFocus, this.getWindowCount() ]).then(([focused, count]) => { if (!focused && count > 1) { return null; } - configurationService.updateValue('workbench.enablePreviewFeatures', false); + this.configurationService.updateValue('workbench.enablePreviewFeatures', false); const enablePreviewFeaturesNotice = localize('enablePreviewFeatures.notice', "Preview features are required in order for extensions to be fully supported and for some actions to be available. Would you like to enable preview features?"); - notificationService.prompt( + this.notificationService.prompt( Severity.Info, enablePreviewFeaturesNotice, [{ label: localize('enablePreviewFeatures.yes', "Yes"), run: () => { - configurationService.updateValue('workbench.enablePreviewFeatures', true); - storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL); + this.configurationService.updateValue('workbench.enablePreviewFeatures', true); + this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL); } }, { label: localize('enablePreviewFeatures.no', "No"), run: () => { - configurationService.updateValue('workbench.enablePreviewFeatures', false); + this.configurationService.updateValue('workbench.enablePreviewFeatures', false); } }, { label: localize('enablePreviewFeatures.never', "No, don't show again"), run: () => { - configurationService.updateValue('workbench.enablePreviewFeatures', false); - storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL); + this.configurationService.updateValue('workbench.enablePreviewFeatures', false); + this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL); }, isSecondary: true }] diff --git a/src/sql/workbench/electron-browser/enablePreviewFeatures.ts b/src/sql/workbench/electron-browser/enablePreviewFeatures.ts index 3c83b3f255..bb826f89e2 100644 --- a/src/sql/workbench/electron-browser/enablePreviewFeatures.ts +++ b/src/sql/workbench/electron-browser/enablePreviewFeatures.ts @@ -20,7 +20,10 @@ export class NativeEnablePreviewFeatures extends AbstractEnablePreviewFeatures { @IElectronService private readonly electronService: IElectronService ) { super(storageService, notificationService, hostService, configurationService); + + this.handlePreviewFeatures(); } + protected getWindowCount(): Promise { return this.electronService.getWindowCount(); }