From 250532f39d2c460f25e646e701bb94d9860d7365 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Wed, 9 Feb 2022 20:53:58 -0800 Subject: [PATCH] remove preview flag check for ADS welcome page (#18280) * remove preview flag for welcome page * remove old welcome page * remove vscode welcome page --- .../page/browser/az_data_welcome_page.ts | 7 - .../welcome/page/browser/welcomePage.css | 8 - .../page/browser/az_data_welcome_page.ts | 77 ---------- .../page/browser/welcomePage.contribution.ts | 29 +--- .../welcome/page/browser/welcomePage.ts | 140 ------------------ 5 files changed, 8 insertions(+), 253 deletions(-) delete mode 100644 src/sql/workbench/contrib/welcome2/page/browser/az_data_welcome_page.ts delete mode 100644 src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts diff --git a/src/sql/workbench/contrib/welcome/page/browser/az_data_welcome_page.ts b/src/sql/workbench/contrib/welcome/page/browser/az_data_welcome_page.ts index 65e3bbfec5..989165d968 100644 --- a/src/sql/workbench/contrib/welcome/page/browser/az_data_welcome_page.ts +++ b/src/sql/workbench/contrib/welcome/page/browser/az_data_welcome_page.ts @@ -7,8 +7,6 @@ import { AddServerAction } from 'sql/workbench/services/objectExplorer/browser/c import { escape } from 'vs/base/common/strings'; import { localize } from 'vs/nls'; -const previewImgDescription = escape(localize('welcomePage.previewBody', "This feature page is in preview. Preview features introduce new functionalities that are on track to becoming a permanent part the product. They are stable, but need additional accessibility improvements. We welcome your early feedback while they are under development.")); - // Note - this content is passed through an HTML sanitizer defined in src\vs\base\browser\dom.ts (safeInnerHtml). If something // isn't rendering correctly make sure that the tags/attributes and schemas are all listed in the allowed lists. export default () => ` @@ -17,11 +15,6 @@ export default () => `
-
diff --git a/src/sql/workbench/contrib/welcome/page/browser/welcomePage.css b/src/sql/workbench/contrib/welcome/page/browser/welcomePage.css index 40dd83cf9f..fb8663b922 100644 --- a/src/sql/workbench/contrib/welcome/page/browser/welcomePage.css +++ b/src/sql/workbench/contrib/welcome/page/browser/welcomePage.css @@ -270,14 +270,6 @@ cursor: default } -.ads-homepage .preview-link { - padding: 4px -} - -.ads-homepage .preview-link i { - margin-right: 4px -} - .ads-homepage .preview-text { display: flex; justify-content: flex-end; diff --git a/src/sql/workbench/contrib/welcome2/page/browser/az_data_welcome_page.ts b/src/sql/workbench/contrib/welcome2/page/browser/az_data_welcome_page.ts deleted file mode 100644 index 069dbc5250..0000000000 --- a/src/sql/workbench/contrib/welcome2/page/browser/az_data_welcome_page.ts +++ /dev/null @@ -1,77 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { AddServerAction } from 'sql/workbench/services/objectExplorer/browser/connectionTreeAction'; -import { escape } from 'vs/base/common/strings'; -import { localize } from 'vs/nls'; - -export default () => ` -
-
-
-

${escape(localize('welcomePage.azdata', "Azure Data Studio"))}

-

-
-
- -
-
-

${escape(localize('welcomePage.customize', "Customize"))}

-
-
-
-
-
-
-
-

${escape(localize('welcomePage.learn', "Learn"))}

-
-
-
-
-
-
-
-
-
-
-`; diff --git a/src/vs/workbench/contrib/welcome/page/browser/welcomePage.contribution.ts b/src/vs/workbench/contrib/welcome/page/browser/welcomePage.contribution.ts index 3623874591..6720085dd0 100644 --- a/src/vs/workbench/contrib/welcome/page/browser/welcomePage.contribution.ts +++ b/src/vs/workbench/contrib/welcome/page/browser/welcomePage.contribution.ts @@ -9,10 +9,8 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { WelcomePageContribution, WelcomePageAction, WelcomeInputSerializer } from 'sql/workbench/contrib/welcome/page/browser/welcomePage'; // {{SQL CARBON EDIT}} use our welcome page import { IWorkbenchActionRegistry, Extensions as ActionExtensions, CATEGORIES } from 'vs/workbench/common/actions'; // {{SQL CARBON EDIT}} import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions'; // {{SQL CARBON EDIT}} -import { WelcomePageContribution as WelcomePageContributionVs } from 'vs/workbench/contrib/welcome/page/browser/welcomePage'; // {{SQL CARBON EDIT}} use our welcome page import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; // {{SQL CARBON EDIT}} - use our welcome page import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration'; import { EditorExtensions, IEditorFactoryRegistry } from 'vs/workbench/common/editor'; @@ -38,33 +36,22 @@ Registry.as(ConfigurationExtensions.Configuration) } }); -// {{SQL CARBON EDIT}} - determine whether to show preview or stable welcome page +// {{SQL CARBON EDIT}} class WelcomeContributions { - constructor( - @IConfigurationService configurationService: IConfigurationService, - ) { - const previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures']; - if (previewFeaturesEnabled) { + constructor() { + Registry.as(WorkbenchExtensions.Workbench) + .registerWorkbenchContribution(WelcomePageContribution, LifecyclePhase.Restored); + Registry.as(ActionExtensions.WorkbenchActions) + .registerWorkbenchAction(SyncActionDescriptor.create(WelcomePageAction, WelcomePageAction.ID, WelcomePageAction.LABEL), 'Help: Welcome', CATEGORIES.Help.value); - Registry.as(WorkbenchExtensions.Workbench) - .registerWorkbenchContribution(WelcomePageContribution, LifecyclePhase.Restored); - - Registry.as(ActionExtensions.WorkbenchActions) - .registerWorkbenchAction(SyncActionDescriptor.create(WelcomePageAction, WelcomePageAction.ID, WelcomePageAction.LABEL), 'Help: Welcome', CATEGORIES.Help.value); - - Registry.as(EditorExtensions.EditorFactory).registerEditorSerializer(WelcomeInputSerializer.ID, WelcomeInputSerializer); - - } else { - Registry.as(WorkbenchExtensions.Workbench) - .registerWorkbenchContribution(WelcomePageContributionVs, LifecyclePhase.Restored); - } + Registry.as(EditorExtensions.EditorFactory).registerEditorSerializer(WelcomeInputSerializer.ID, WelcomeInputSerializer); } } Registry.as(WorkbenchExtensions.Workbench) .registerWorkbenchContribution(WelcomeContributions, LifecyclePhase.Starting); -// {{SQL CARBON EDIT}} - end preview startup customization +// {{SQL CARBON EDIT}} // {{SQL CARBON EDIT}} We still use legacy welcome page - not walkthrough MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, { diff --git a/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts b/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts deleted file mode 100644 index 08977e539e..0000000000 --- a/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts +++ /dev/null @@ -1,140 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { URI } from 'vs/base/common/uri'; -import { ICommandService } from 'vs/platform/commands/common/commands'; -import * as arrays from 'vs/base/common/arrays'; -import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { onUnexpectedError } from 'vs/base/common/errors'; -import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup'; -import { ILifecycleService, StartupKind } from 'vs/workbench/services/lifecycle/common/lifecycle'; -import { IFileService } from 'vs/platform/files/common/files'; -import { joinPath } from 'vs/base/common/resources'; -import { IEditorOptions } from 'vs/platform/editor/common/editor'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; -import { GettingStartedInput, gettingStartedInputTypeId } from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedInput'; -import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; -import 'sql/workbench/contrib/welcome2/page/browser/az_data_welcome_page'; // {{SQL CARBON EDIT}} - -const configurationKey = 'workbench.startupEditor'; -const oldConfigurationKey = 'workbench.welcome.enabled'; -const telemetryOptOutStorageKey = 'workbench.telemetryOptOutShown'; - -export class WelcomePageContribution implements IWorkbenchContribution { - - constructor( - @IInstantiationService private readonly instantiationService: IInstantiationService, - @IConfigurationService private readonly configurationService: IConfigurationService, - @IEditorService private readonly editorService: IEditorService, - @IWorkingCopyBackupService private readonly workingCopyBackupService: IWorkingCopyBackupService, - @IFileService private readonly fileService: IFileService, - @IWorkspaceContextService private readonly contextService: IWorkspaceContextService, - @ILifecycleService private readonly lifecycleService: ILifecycleService, - @IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService, - @ICommandService private readonly commandService: ICommandService, - @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, - @IStorageService private readonly storageService: IStorageService - ) { - this.run().then(undefined, onUnexpectedError); - } - - private async run() { - - // Always open Welcome page for first-launch, no matter what is open or which startupEditor is set. - if (this.configurationService.getValue('telemetry.enableTelemetry') && !this.storageService.get(telemetryOptOutStorageKey, StorageScope.GLOBAL)) { - this.storageService.store(telemetryOptOutStorageKey, true, StorageScope.GLOBAL, StorageTarget.USER); - await this.openWelcome(true); - return; - } - - const enabled = isWelcomePageEnabled(this.configurationService, this.contextService, this.environmentService); - if (enabled && this.lifecycleService.startupKind !== StartupKind.ReloadedWindow) { - const hasBackups = await this.workingCopyBackupService.hasBackups(); - if (hasBackups) { return; } - - // Open the welcome even if we opened a set of default editors - if (!this.editorService.activeEditor || this.layoutService.openedDefaultEditors) { - const startupEditorSetting = this.configurationService.inspect(configurationKey); - - // 'readme' should not be set in workspace settings to prevent tracking, - // but it can be set as a default (as in codespaces) or a user setting - const openWithReadme = startupEditorSetting.value === 'readme' && - (startupEditorSetting.userValue === 'readme' || startupEditorSetting.defaultValue === 'readme'); - - if (openWithReadme) { - await this.openReadme(); - } else { - await this.openWelcome(); - } - } - } - } - - private async openReadme() { - const readmes = arrays.coalesce( - await Promise.all(this.contextService.getWorkspace().folders.map( - async folder => { - const folderUri = folder.uri; - const folderStat = await this.fileService.resolve(folderUri).catch(onUnexpectedError); - const files = folderStat?.children ? folderStat.children.map(child => child.name).sort() : []; - const file = files.find(file => file.toLowerCase() === 'readme.md') || files.find(file => file.toLowerCase().startsWith('readme')); - if (file) { return joinPath(folderUri, file); } - else { return undefined; } - }))); - - if (!this.editorService.activeEditor) { - if (readmes.length) { - const isMarkDown = (readme: URI) => readme.path.toLowerCase().endsWith('.md'); - await Promise.all([ - this.commandService.executeCommand('markdown.showPreview', null, readmes.filter(isMarkDown), { locked: true }), - this.editorService.openEditors(readmes.filter(readme => !isMarkDown(readme)).map(readme => ({ resource: readme }))), - ]); - } else { - await this.openWelcome(); - } - } - } - - private async openWelcome(showTelemetryNotice?: boolean) { - const startupEditorTypeID = gettingStartedInputTypeId; - const editor = this.editorService.activeEditor; - - // Ensure that the welcome editor won't get opened more than once - if (editor?.typeId === startupEditorTypeID || this.editorService.editors.some(e => e.typeId === startupEditorTypeID)) { - return; - } - - const options: IEditorOptions = editor ? { pinned: false, index: 0 } : { pinned: false }; - if (startupEditorTypeID === gettingStartedInputTypeId) { - this.editorService.openEditor(this.instantiationService.createInstance(GettingStartedInput, { showTelemetryNotice }), options); - } - } -} - -function isWelcomePageEnabled(configurationService: IConfigurationService, contextService: IWorkspaceContextService, environmentService: IWorkbenchEnvironmentService) { - if (environmentService.skipWelcome) { - return false; - } - - const startupEditor = configurationService.inspect(configurationKey); - if (!startupEditor.userValue && !startupEditor.workspaceValue) { - const welcomeEnabled = configurationService.inspect(oldConfigurationKey); - if (welcomeEnabled.value !== undefined && welcomeEnabled.value !== null) { - return welcomeEnabled.value; - } - } - - if (startupEditor.value === 'readme' && startupEditor.userValue !== 'readme' && startupEditor.defaultValue !== 'readme') { - console.error(`Warning: 'workbench.startupEditor: readme' setting ignored due to being set somewhere other than user or default settings (user=${startupEditor.userValue}, default=${startupEditor.defaultValue})`); - } - return startupEditor.value === 'welcomePage' - || startupEditor.value === 'readme' && (startupEditor.userValue === 'readme' || startupEditor.defaultValue === 'readme') - || (contextService.getWorkbenchState() === WorkbenchState.EMPTY && startupEditor.value === 'welcomePageInEmptyWorkbench'); -}