Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GettingStartedService/Registry and initial getting started UI #111175

Merged
merged 8 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/lib/i18n.resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@
{
"name": "vs/workbench/services/extensionRecommendations",
"project": "vscode-workbench"
},
{
"name": "vs/workbench/services/gettingStarted",
"project": "vscode-workbench"
}
]
}
4 changes: 2 additions & 2 deletions src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1373,8 +1373,8 @@ export function safeInnerHtml(node: HTMLElement, value: string): void {
const options = _extInsaneOptions({
allowedTags: ['a', 'button', 'blockquote', 'code', 'div', 'h1', 'h2', 'h3', 'input', 'label', 'li', 'p', 'pre', 'select', 'small', 'span', 'strong', 'textarea', 'ul', 'ol'],
allowedAttributes: {
'a': ['href'],
'button': ['data-href'],
'a': ['href', 'x-dispatch'],
'button': ['data-href', 'x-dispatch'],
'input': ['type', 'placeholder', 'checked', 'required'],
'label': ['for'],
'select': ['required'],
Expand Down
36 changes: 30 additions & 6 deletions src/vs/workbench/browser/actions/workspaceActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IWorkspacesService, hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
import { GettingStartedCategory, GettingStartedRegistryID, IGettingStartedRegistry } from 'vs/workbench/services/gettingStarted/common/gettingStartedRegistry';
import product from 'vs/platform/product/common/product';
import { isMacintosh } from 'vs/base/common/platform';
import { IGettingStartedService } from 'vs/workbench/services/gettingStarted/common/gettingStartedService';

export class OpenFileAction extends Action {

Expand Down Expand Up @@ -50,13 +54,15 @@ export class OpenFolderAction extends Action {
constructor(
id: string,
label: string,
@IFileDialogService private readonly dialogService: IFileDialogService
@IFileDialogService private readonly dialogService: IFileDialogService,
@IGettingStartedService private readonly gettingStartedService: IGettingStartedService
) {
super(id, label);
}

run(event?: unknown, data?: ITelemetryData): Promise<void> {
return this.dialogService.pickFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data });
async run(event?: unknown, data?: ITelemetryData): Promise<void> {
await this.dialogService.pickFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data });
this.gettingStartedService.progressTask(pickAFolderTask);
}
}

Expand All @@ -68,13 +74,15 @@ export class OpenFileFolderAction extends Action {
constructor(
id: string,
label: string,
@IFileDialogService private readonly dialogService: IFileDialogService
@IFileDialogService private readonly dialogService: IFileDialogService,
@IGettingStartedService private readonly gettingStartedService: IGettingStartedService
) {
super(id, label);
}

run(event?: unknown, data?: ITelemetryData): Promise<void> {
return this.dialogService.pickFileFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data });
async run(event?: unknown, data?: ITelemetryData): Promise<void> {
await this.dialogService.pickFileFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data });
this.gettingStartedService.progressTask(pickAFolderTask);
}
}

Expand Down Expand Up @@ -314,3 +322,19 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
order: 3,
when: ContextKeyExpr.and(WorkbenchStateContext.isEqualTo('workspace'), EmptyWorkspaceSupportContext)
});

// --- Getting Started Tasks Registration

const gettingStartedRegistry = Registry.as<IGettingStartedRegistry>(GettingStartedRegistryID);

const pickAFolderTask = gettingStartedRegistry.registerTask({
category: GettingStartedCategory.Beginner,
description: nls.localize('gettingStartedOpenFolder.description', "Open a project folder to get started with {0}!", product.nameLong),
id: 'pickAFolder',
title: nls.localize('gettingStartedOpenFolder.title', "Open Folder"),
order: 3,
button: {
title: nls.localize('gettingStartedOpenFolder.button', "Pick a Folder"),
command: isMacintosh ? OpenFileFolderAction.ID : OpenFolderAction.ID
},
});
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/media/code-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 33 additions & 2 deletions src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ import { ActionWithDropdownActionViewItem, IActionWithDropdownActionViewItemOpti
import { IContextMenuProvider } from 'vs/base/browser/contextmenu';
import { ILogService } from 'vs/platform/log/common/log';
import * as Constants from 'vs/workbench/contrib/logs/common/logConstants';
import { GettingStartedCategory, GettingStartedRegistry } from 'vs/workbench/services/gettingStarted/common/gettingStartedRegistry';
import { IGettingStartedService } from 'vs/workbench/services/gettingStarted/common/gettingStartedService';

function getRelativeDateLabel(date: Date): string {
const delta = new Date().getTime() - date.getTime();
Expand Down Expand Up @@ -2098,7 +2100,8 @@ export class ShowRecommendedKeymapExtensionsAction extends Action {
constructor(
id: string,
label: string,
@IViewletService private readonly viewletService: IViewletService
@IViewletService private readonly viewletService: IViewletService,
@IGettingStartedService private readonly gettingStartedService: IGettingStartedService
) {
super(id, label, undefined, true);
}
Expand All @@ -2109,6 +2112,7 @@ export class ShowRecommendedKeymapExtensionsAction extends Action {
.then(viewlet => {
viewlet.search('@recommended:keymaps ');
viewlet.focus();
this.gettingStartedService.progressTask(findKeybindingsExtensionsTask);
});
}
}
Expand All @@ -2121,7 +2125,8 @@ export class ShowLanguageExtensionsAction extends Action {
constructor(
id: string,
label: string,
@IViewletService private readonly viewletService: IViewletService
@IViewletService private readonly viewletService: IViewletService,
@IGettingStartedService private readonly gettingStartedService: IGettingStartedService
) {
super(id, label, undefined, true);
}
Expand All @@ -2132,6 +2137,7 @@ export class ShowLanguageExtensionsAction extends Action {
.then(viewlet => {
viewlet.search('@category:"programming languages" @sort:installs ');
viewlet.focus();
this.gettingStartedService.progressTask(findLanguageExtensionsTask);
});
}
}
Expand Down Expand Up @@ -3193,6 +3199,31 @@ export class InstallRemoteExtensionsInLocalAction extends AbstractInstallExtensi
}
}

const findKeybindingsExtensionsTask = GettingStartedRegistry.registerTask({
category: GettingStartedCategory.Beginner,
description: localize('findKeybindingsTask.description', "Find keyboard shortcuts for Vim, Sublime, Atom and others."),
id: 'findKeybindingsExtensions',
title: localize('findKeybindingsTask.title', "Configure Keybindings"),
order: 1,
button: {
title: localize('findKeybindingsTask.button', "Search for Keymaps'"),
command: ShowRecommendedKeymapExtensionsAction.ID
},
});

const findLanguageExtensionsTask = GettingStartedRegistry.registerTask({
category: GettingStartedCategory.Beginner,
description: localize('findLanguageExtsTask.description', "Get support for your languages like JavaScript, Python, Java, Azure, Docker, and more."),
id: 'findLanguageExtensions',
title: localize('findLanguageExtsTask.title', "Languages & Tools"),
order: 2,
button: {
title: localize('findLanguageExtsTask.button', "Install Language Support"),
command: ShowLanguageExtensionsAction.ID,
}
});


CommandsRegistry.registerCommand('workbench.extensions.action.showExtensionsForLanguage', function (accessor: ServicesAccessor, fileExtension: string) {
const viewletService = accessor.get(IViewletService);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { TriggerAction } from 'vs/platform/quickinput/browser/pickerQuickAccess';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { GettingStartedCategory, GettingStartedRegistry } from 'vs/workbench/services/gettingStarted/common/gettingStartedRegistry';
import { IGettingStartedService } from 'vs/workbench/services/gettingStarted/common/gettingStartedService';

export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAccessProvider {

Expand Down Expand Up @@ -170,6 +172,7 @@ export class ShowAllCommandsAction extends Action2 {

async run(accessor: ServicesAccessor): Promise<void> {
accessor.get(IQuickInputService).quickAccess.show(CommandsQuickAccessProvider.PREFIX);
accessor.get(IGettingStartedService).progressTask(findLanguageExtensionsTask);
}
}

Expand All @@ -195,3 +198,19 @@ export class ClearCommandHistoryAction extends Action2 {
}

//#endregion

//#region Getting Started Tasks

const findLanguageExtensionsTask = GettingStartedRegistry.registerTask({
category: GettingStartedCategory.Intermediate,
description: localize('commandPaletteTask.description', "The easiest way to find everything VS Code can do. If you\'re ever looking for a feature, check here first!"),
id: 'findLanguageExtensions',
title: localize('commandPaletteTask.title', "Command Palette"),
order: 0,
button: {
title: localize('commandPaletteTask.button', "View All Commands"),
command: ShowAllCommandsAction.ID
},
});

//#endregion
14 changes: 14 additions & 0 deletions src/vs/workbench/contrib/themes/browser/themes.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import { IQuickInputService, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { DEFAULT_PRODUCT_ICON_THEME_ID } from 'vs/workbench/services/themes/browser/productIconThemeData';
import { GettingStartedCategory, GettingStartedRegistryID, IGettingStartedRegistry } from 'vs/workbench/services/gettingStarted/common/gettingStartedRegistry';
import { IGettingStartedService } from 'vs/workbench/services/gettingStarted/common/gettingStartedService';

export class SelectColorThemeAction extends Action {

Expand All @@ -34,6 +36,7 @@ export class SelectColorThemeAction extends Action {
@IQuickInputService private readonly quickInputService: IQuickInputService,
@IWorkbenchThemeService private readonly themeService: IWorkbenchThemeService,
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService,
@IGettingStartedService private readonly gettingStartedService: IGettingStartedService,
@IViewletService private readonly viewletService: IViewletService
) {
super(id, label);
Expand Down Expand Up @@ -84,6 +87,7 @@ export class SelectColorThemeAction extends Action {
openExtensionViewlet(this.viewletService, `category:themes ${quickpick.value}`);
} else {
selectTheme(theme, true);
this.gettingStartedService.progressTask(pickColorThemeTask);
}
isCompleted = true;
quickpick.hide();
Expand Down Expand Up @@ -380,3 +384,13 @@ MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
},
order: 2
});


const pickColorThemeTask = Registry.as<IGettingStartedRegistry>(GettingStartedRegistryID).registerTask({
category: GettingStartedCategory.Beginner,
description: localize('pickColorTask.description', "Modify the colors in the user interface to suit your preferences and work environment."),
id: 'pickColorTheme',
title: localize('pickColorTask.title', "Color Theme"),
order: 0,
button: { title: localize('pickColorTask.button', "Find a Theme"), command: SelectColorThemeAction.ID },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { GettingStartedInputFactory, GettingStartedPage } from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as EditorInputExtensions, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
import { MenuId, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
import product from 'vs/platform/product/common/product';

registerAction2(class extends Action2 {
constructor() {
super({
id: 'workbench.action.showGettingStarted',
title: localize('Getting Started', "Getting Started"),
category: localize('help', "Help"),
f1: true,
precondition: ContextKeyExpr.has('config.workbench.experimental.gettingStarted'),
menu: {
id: MenuId.MenubarHelpMenu,
when: ContextKeyExpr.has('config.workbench.experimental.gettingStarted'),
group: '1_welcome',
order: 2,
}
});
}

public run(accessor: ServicesAccessor) {
return accessor.get(IInstantiationService).createInstance(GettingStartedPage).openEditor();
}
});

Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerEditorInputFactory(GettingStartedInputFactory.ID, GettingStartedInputFactory);

if (product.quality !== 'stable') {
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
...workbenchConfigurationNodeBase,
properties: {
'workbench.experimental.gettingStarted': {
type: 'boolean',
description: localize('gettingStartedDescription', "Enables an experimental Getting Started page, accesible via the Help menu."),
default: false,
}
}
});
}
Loading