From 3005d5435feddd1701ec558fba1121bd34fcd8e4 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 11 Oct 2022 15:46:32 -0700 Subject: [PATCH] Add preview features enabled flag to issue reporter info (#20808) * Add preview features enabled flag to issue reporter info * fix tests * fix key --- src/sql/workbench/common/constants.ts | 2 ++ .../workbench/contrib/backup/browser/backupActions.ts | 3 ++- .../workbench/contrib/query/browser/queryEditor.ts | 5 +++-- .../browser/resourceViewer.contribution.ts | 3 ++- .../contrib/restore/browser/restoreActions.ts | 3 ++- .../browser/abstractEnablePreviewFeatures.ts | 11 ++++++----- .../objectExplorer/browser/treeCreationUtils.ts | 3 ++- .../services/query/common/queryManagement.ts | 3 ++- .../code/electron-sandbox/issue/issueReporterMain.ts | 6 ++++++ .../code/electron-sandbox/issue/issueReporterModel.ts | 2 ++ .../issue/test/testReporterModel.test.ts | 2 ++ src/vs/platform/issue/common/issue.ts | 1 + .../services/issue/electron-sandbox/issueService.ts | 6 +++++- 13 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/sql/workbench/common/constants.ts b/src/sql/workbench/common/constants.ts index 16f4f6250b..de84bfa360 100644 --- a/src/sql/workbench/common/constants.ts +++ b/src/sql/workbench/common/constants.ts @@ -26,6 +26,8 @@ export const ToggleWholeWordCommandId = 'toggleSearchWholeWord'; export const ToggleRegexCommandId = 'toggleSearchRegex'; export const AddCursorsAtSearchResults = 'addCursorsAtSearchResults'; +export const CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES = 'workbench.enablePreviewFeatures'; + export const SearchViewFocusedKey = new RawContextKey('notebookSearchViewletFocus', false); export const InputBoxFocusedKey = new RawContextKey('inputBoxFocus', false); export const SearchInputBoxFocusedKey = new RawContextKey('searchInputBoxFocus', false); diff --git a/src/sql/workbench/contrib/backup/browser/backupActions.ts b/src/sql/workbench/contrib/backup/browser/backupActions.ts index b053cf1b75..82eef852bd 100644 --- a/src/sql/workbench/contrib/backup/browser/backupActions.ts +++ b/src/sql/workbench/contrib/backup/browser/backupActions.ts @@ -17,6 +17,7 @@ import { IBackupUiService } from 'sql/workbench/contrib/backup/common/backupUiSe import { Task } from 'sql/workbench/services/tasks/browser/tasksRegistry'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; export const BackupFeatureName = 'backup'; export const backupIsPreviewFeature = localize('backup.isPreviewFeature', "You must enable preview features in order to use backup"); @@ -44,7 +45,7 @@ export class BackupAction extends Task { runTask(accessor: ServicesAccessor, profile?: IConnectionProfile): void | Promise { const configurationService = accessor.get(IConfigurationService); - const previewFeaturesEnabled = configurationService.getValue<{ enablePreviewFeatures: boolean }>('workbench').enablePreviewFeatures; + const previewFeaturesEnabled = configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES); if (!previewFeaturesEnabled) { return accessor.get(INotificationService).info(backupIsPreviewFeature); } diff --git a/src/sql/workbench/contrib/query/browser/queryEditor.ts b/src/sql/workbench/contrib/query/browser/queryEditor.ts index faa6726196..21336362b3 100644 --- a/src/sql/workbench/contrib/query/browser/queryEditor.ts +++ b/src/sql/workbench/contrib/query/browser/queryEditor.ts @@ -46,6 +46,7 @@ import { ITextResourceConfigurationService } from 'vs/editor/common/services/tex import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { ConnectionOptionSpecialType } from 'sql/platform/connection/common/interfaces'; import { ICodeEditorViewState } from 'vs/editor/common/editorCommon'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; const QUERY_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'queryEditorViewState'; @@ -211,7 +212,7 @@ export class QueryEditor extends EditorPane { this._exportAsNotebookAction = this.instantiationService.createInstance(actions.ExportAsNotebookAction, this); this.setTaskbarContent(); this._register(this.configurationService.onDidChangeConfiguration(e => { - if (e.affectsConfiguration('workbench.enablePreviewFeatures')) { + if (e.affectsConfiguration(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES)) { this.setTaskbarContent(); } })); @@ -297,7 +298,7 @@ export class QueryEditor extends EditorPane { } private setTaskbarContent(): void { - const previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures']; + const previewFeaturesEnabled = this.configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES); const fileExtension = path.extname(this.input?.uri || ''); const providerId = this.currentProvider; const content: ITaskbarContent[] = [ diff --git a/src/sql/workbench/contrib/resourceViewer/browser/resourceViewer.contribution.ts b/src/sql/workbench/contrib/resourceViewer/browser/resourceViewer.contribution.ts index 67c41c5b43..508eea0bd7 100644 --- a/src/sql/workbench/contrib/resourceViewer/browser/resourceViewer.contribution.ts +++ b/src/sql/workbench/contrib/resourceViewer/browser/resourceViewer.contribution.ts @@ -24,6 +24,7 @@ import { localize } from 'vs/nls'; import { Extensions as ViewContainerExtensions, IViewsRegistry, IViewContainersRegistry, ViewContainerLocation } from 'vs/workbench/common/views'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IProductService } from 'vs/platform/product/common/productService'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; CommandsRegistry.registerCommand({ id: 'resourceViewer.openResourceViewer', @@ -56,7 +57,7 @@ class ResourceViewerContributor implements IWorkbenchContribution { @IProductService readonly productService: IProductService ) { // Only show for insiders and dev - if (['insider', ''].includes(productService.quality ?? '') && configurationService.getValue('workbench.enablePreviewFeatures')) { + if (['insider', ''].includes(productService.quality ?? '') && configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES)) { registerResourceViewerContainer(); } } diff --git a/src/sql/workbench/contrib/restore/browser/restoreActions.ts b/src/sql/workbench/contrib/restore/browser/restoreActions.ts index 661fbbe0da..2d84667eb8 100644 --- a/src/sql/workbench/contrib/restore/browser/restoreActions.ts +++ b/src/sql/workbench/contrib/restore/browser/restoreActions.ts @@ -17,6 +17,7 @@ import { Task } from 'sql/workbench/services/tasks/browser/tasksRegistry'; import { mssqlProviderName } from 'sql/platform/connection/common/constants'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; export function showRestore(accessor: ServicesAccessor, connection: IConnectionProfile): Promise { const restoreDialogService = accessor.get(IRestoreDialogController); @@ -46,7 +47,7 @@ export class RestoreAction extends Task { runTask(accessor: ServicesAccessor, withProfile?: IConnectionProfile): void | Promise { let profile = withProfile; const configurationService = accessor.get(IConfigurationService); - const previewFeaturesEnabled: boolean = configurationService.getValue<{ enablePreviewFeatures: boolean }>('workbench').enablePreviewFeatures; + const previewFeaturesEnabled: boolean = configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES); if (!previewFeaturesEnabled) { return accessor.get(INotificationService).info(restoreIsPreviewFeature); } diff --git a/src/sql/workbench/contrib/welcome/gettingStarted/browser/abstractEnablePreviewFeatures.ts b/src/sql/workbench/contrib/welcome/gettingStarted/browser/abstractEnablePreviewFeatures.ts index 33615b048e..ae249dd819 100644 --- a/src/sql/workbench/contrib/welcome/gettingStarted/browser/abstractEnablePreviewFeatures.ts +++ b/src/sql/workbench/contrib/welcome/gettingStarted/browser/abstractEnablePreviewFeatures.ts @@ -10,6 +10,7 @@ import { localize } from 'vs/nls'; import { onUnexpectedError } from 'vs/base/common/errors'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IHostService } from 'vs/workbench/services/host/browser/host'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContribution { @@ -23,7 +24,7 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib ) { } protected handlePreviewFeatures(): void { - let previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures']; + let previewFeaturesEnabled = this.configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES); if (previewFeaturesEnabled || this.storageService.get(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, StorageScope.GLOBAL)) { return; } @@ -34,7 +35,7 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib if (!focused && count > 1) { return null; } - await this.configurationService.updateValue('workbench.enablePreviewFeatures', false); + await this.configurationService.updateValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES, false); const enablePreviewFeaturesNotice = localize('enablePreviewFeatures.notice', "Preview features enhance your experience in Azure Data Studio by giving you full access to new features and improvements. You can learn more about preview features [here]({0}). Would you like to enable preview features?", 'https://aka.ms/ads-preview-features'); this.notificationService.prompt( @@ -43,18 +44,18 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib [{ label: localize('enablePreviewFeatures.yes', "Yes (recommended)"), run: () => { - this.configurationService.updateValue('workbench.enablePreviewFeatures', true).catch(e => onUnexpectedError(e)); + this.configurationService.updateValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES, true).catch(e => onUnexpectedError(e)); this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL, StorageTarget.MACHINE); } }, { label: localize('enablePreviewFeatures.no', "No"), run: () => { - this.configurationService.updateValue('workbench.enablePreviewFeatures', false).catch(e => onUnexpectedError(e)); + this.configurationService.updateValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES, false).catch(e => onUnexpectedError(e)); } }, { label: localize('enablePreviewFeatures.never', "No, don't show again"), run: () => { - this.configurationService.updateValue('workbench.enablePreviewFeatures', false).catch(e => onUnexpectedError(e)); + this.configurationService.updateValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES, false).catch(e => onUnexpectedError(e)); this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL, StorageTarget.MACHINE); }, isSecondary: true diff --git a/src/sql/workbench/services/objectExplorer/browser/treeCreationUtils.ts b/src/sql/workbench/services/objectExplorer/browser/treeCreationUtils.ts index 661077466e..107ec4ddc2 100644 --- a/src/sql/workbench/services/objectExplorer/browser/treeCreationUtils.ts +++ b/src/sql/workbench/services/objectExplorer/browser/treeCreationUtils.ts @@ -25,6 +25,7 @@ import { AsyncRecentConnectionTreeDataSource } from 'sql/workbench/services/obje import { AsyncServerTreeDataSource } from 'sql/workbench/services/objectExplorer/browser/asyncServerTreeDataSource'; import { AsyncServerTree, ServerTreeElement } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; export class TreeCreationUtils { /** @@ -141,5 +142,5 @@ export class TreeCreationUtils { } function useAsyncServerTree(configurationService: IConfigurationService): boolean { - return configurationService.getValue('workbench.enablePreviewFeatures') && configurationService.getValue('serverTree.useAsyncServerTree'); + return configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES) && configurationService.getValue('serverTree.useAsyncServerTree'); } diff --git a/src/sql/workbench/services/query/common/queryManagement.ts b/src/sql/workbench/services/query/common/queryManagement.ts index b52c3a99e0..96e562868a 100644 --- a/src/sql/workbench/services/query/common/queryManagement.ts +++ b/src/sql/workbench/services/query/common/queryManagement.ts @@ -18,6 +18,7 @@ import { isUndefined } from 'vs/base/common/types'; import { ILogService } from 'vs/platform/log/common/log'; import * as nls from 'vs/nls'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; export const SERVICE_ID = 'queryManagementService'; @@ -336,7 +337,7 @@ export class QueryManagementService implements IQueryManagementService { public onResultSetUpdated(resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void { this._notify(resultSetInfo.ownerUri, (runner: QueryRunner) => { runner.handleResultSetUpdated(resultSetInfo.resultSetSummary); - if (resultSetInfo.executionPlans && this._configurationService.getValue('workbench.enablePreviewFeatures')) { + if (resultSetInfo.executionPlans && this._configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES)) { runner.handleExecutionPlanAvailable(resultSetInfo.executionPlans); } }); diff --git a/src/vs/code/electron-sandbox/issue/issueReporterMain.ts b/src/vs/code/electron-sandbox/issue/issueReporterMain.ts index f200628dba..44d3d2b42f 100644 --- a/src/vs/code/electron-sandbox/issue/issueReporterMain.ts +++ b/src/vs/code/electron-sandbox/issue/issueReporterMain.ts @@ -142,6 +142,7 @@ export class IssueReporter extends Disposable { this.handleExtensionData(configuration.data.enabledExtensions); this.updateExperimentsInfo(configuration.data.experiments); this.updateRestrictedMode(configuration.data.restrictedMode); + this.updatePreviewFeaturesEnabled(configuration.data.previewFeaturesEnabled); // {{SQL CARBON EDIT}} Add preview features flag } render(): void { @@ -1165,6 +1166,11 @@ export class IssueReporter extends Disposable { this.issueReporterModel.update({ restrictedMode }); } + // {{SQL CARBON EDIT}} Add preview features flag + private updatePreviewFeaturesEnabled(previewFeaturesEnabled: boolean) { + this.issueReporterModel.update({ previewFeaturesEnabled }); + } + private updateExperimentsInfo(experimentInfo: string | undefined) { this.issueReporterModel.update({ experimentInfo }); const target = document.querySelector('.block-experiments .block-info'); diff --git a/src/vs/code/electron-sandbox/issue/issueReporterModel.ts b/src/vs/code/electron-sandbox/issue/issueReporterModel.ts index f9a9a33e4a..02922c15d7 100644 --- a/src/vs/code/electron-sandbox/issue/issueReporterModel.ts +++ b/src/vs/code/electron-sandbox/issue/issueReporterModel.ts @@ -33,6 +33,7 @@ export interface IssueReporterData { filterResultCount?: number; experimentInfo?: string; restrictedMode?: boolean; + previewFeaturesEnabled?: boolean; // {{SQL CARBON EDIT}} Add preview features flag } export class IssueReporterModel { @@ -70,6 +71,7 @@ ${this.getExtensionVersion()} Azure Data Studio version: ${this._data.versionInfo && this._data.versionInfo.vscodeVersion} OS version: ${this._data.versionInfo && this._data.versionInfo.os} Restricted Mode: ${this._data.restrictedMode ? 'Yes' : 'No'} +Preview Features: ${this._data.previewFeaturesEnabled ? 'Enabled' : 'Disabled'} ${this.getRemoteOSes()} ${this.getInfos()} `; diff --git a/src/vs/code/electron-sandbox/issue/test/testReporterModel.test.ts b/src/vs/code/electron-sandbox/issue/test/testReporterModel.test.ts index cac90e5354..4c83f7de53 100644 --- a/src/vs/code/electron-sandbox/issue/test/testReporterModel.test.ts +++ b/src/vs/code/electron-sandbox/issue/test/testReporterModel.test.ts @@ -34,6 +34,7 @@ undefined Azure Data Studio version: undefined OS version: undefined Restricted Mode: No +Preview Features: Disabled Extensions: none `); @@ -65,6 +66,7 @@ undefined Azure Data Studio version: undefined OS version: undefined Restricted Mode: No +Preview Features: Disabled
System Info diff --git a/src/vs/platform/issue/common/issue.ts b/src/vs/platform/issue/common/issue.ts index 482e783b04..c1fec88333 100644 --- a/src/vs/platform/issue/common/issue.ts +++ b/src/vs/platform/issue/common/issue.ts @@ -59,6 +59,7 @@ export interface IssueReporterData extends WindowData { extensionId?: string; experiments?: string; restrictedMode: boolean; + previewFeaturesEnabled: boolean; // {{SQL CARBON EDIT}} Add preview features flag githubAccessToken: string; readonly issueTitle?: string; readonly issueBody?: string; diff --git a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts index 7f7eaa8d0a..2468fbcdfc 100644 --- a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts +++ b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts @@ -20,6 +20,8 @@ import { ITASExperimentService } from 'vs/workbench/services/experiment/common/e import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; import { registerMainProcessRemoteService } from 'vs/platform/ipc/electron-sandbox/services'; import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; // {{SQL CARBON EDIT}} Add preview features flag +import { CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES } from 'sql/workbench/common/constants'; // {{SQL CARBON EDIT}} Add preview features flag export class WorkbenchIssueService implements IWorkbenchIssueService { declare readonly _serviceBrand: undefined; @@ -33,7 +35,8 @@ export class WorkbenchIssueService implements IWorkbenchIssueService { @IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService, @IProductService private readonly productService: IProductService, @ITASExperimentService private readonly experimentService: ITASExperimentService, - @IAuthenticationService private readonly authenticationService: IAuthenticationService + @IAuthenticationService private readonly authenticationService: IAuthenticationService, + @IConfigurationService private readonly configurationService: IConfigurationService // {{SQL CARBON EDIT}} Add preview features flag ) { } async openReporter(dataOverrides: Partial = {}): Promise { @@ -89,6 +92,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService { enabledExtensions: extensionData, experiments: experiments?.join('\n'), restrictedMode: !this.workspaceTrustManagementService.isWorkspaceTrusted(), + previewFeaturesEnabled: this.configurationService.getValue(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES), // {{SQL CARBON EDIT}} Add preview features flag githubAccessToken, }, dataOverrides); return this.issueService.openReporter(issueReporterData);