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

Prototype side by side commands for getting started #120436

Merged
merged 2 commits into from Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -39,6 +39,7 @@ import { coalesce } from 'vs/base/common/arrays';
import { isMacintosh } from 'vs/base/common/platform';
import { Throttler } from 'vs/base/common/async';
import { GettingStartedInput } from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedInput';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';

const SLIDE_TRANSITION_TIME_MS = 250;
const configurationKey = 'workbench.startupEditor';
Expand Down Expand Up @@ -93,6 +94,7 @@ export class GettingStartedPage extends EditorPane {
@IOpenerService private readonly openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@IStorageService private storageService: IStorageService,
@IEditorGroupsService private readonly groupsService: IEditorGroupsService,
@IContextKeyService contextService: IContextKeyService,
@IWorkspacesService workspacesService: IWorkspacesService,
@ILabelService private readonly labelService: ILabelService,
Expand Down Expand Up @@ -201,83 +203,93 @@ export class GettingStartedPage extends EditorPane {

this.commandService.executeCommand('workbench.action.keepEditor');
this.telemetryService.publicLog2<GettingStartedActionEvent, GettingStartedActionClassification>('gettingStarted.ActionExecuted', { command, argument });

switch (command) {
case 'scrollPrev': {
this.scrollPrev();
break;
}
case 'skip': {
this.runSkip();
break;
}
case 'showMoreRecents': {
this.commandService.executeCommand('workbench.action.openRecent');
break;
}
case 'configureVisibility': {
this.commandService.executeCommand('workbench.action.openSettings', hiddenEntriesConfigurationKey);
break;
}
case 'openFolder': {
this.commandService.executeCommand(isMacintosh ? 'workbench.action.files.openFileFolder' : 'workbench.action.files.openFolder');
break;
}
case 'selectCategory': {
const selectedCategory = this.gettingStartedCategories.find(category => category.id === argument);
if (!selectedCategory) { throw Error('Could not find category with ID ' + argument); }
if (selectedCategory.content.type === 'startEntry') {
this.commandService.executeCommand(selectedCategory.content.command);
} else {
this.scrollToCategory(argument);
(async () => {
switch (command) {
case 'scrollPrev': {
this.scrollPrev();
break;
}
break;
}
case 'hideCategory': {
const selectedCategory = this.gettingStartedCategories.find(category => category.id === argument);
if (!selectedCategory) { throw Error('Could not find category with ID ' + argument); }
this.configurationService.updateValue(hiddenEntriesConfigurationKey,
[...(this.configurationService.getValue<string[]>(hiddenEntriesConfigurationKey) ?? []), argument]);
element.parentElement?.remove();
break;
}
case 'selectTask': {
this.selectTask(argument);
break;
}
case 'toggleTaskCompletion': {
if (!this.currentCategory || this.currentCategory.content.type !== 'items') {
throw Error('cannot run task action for category of non items type' + this.currentCategory?.id);
case 'skip': {
this.runSkip();
break;
}

const taskToggle = assertIsDefined(this.currentCategory?.content.items.find(task => task.id === argument));
if (taskToggle.done) {
this.gettingStartedService.deprogressTask(argument);
} else {
this.gettingStartedService.progressTask(argument);
case 'showMoreRecents': {
this.commandService.executeCommand('workbench.action.openRecent');
break;
}
break;
}
case 'runTaskAction': {
if (!this.currentCategory || this.currentCategory.content.type !== 'items') {
throw Error('cannot run task action for category of non items type' + this.currentCategory?.id);
case 'configureVisibility': {
this.commandService.executeCommand('workbench.action.openSettings', hiddenEntriesConfigurationKey);
break;
}
const taskToRun = assertIsDefined(this.currentCategory?.content.items.find(task => task.id === argument));
if (taskToRun.button.command) {
this.commandService.executeCommand(taskToRun.button.command);
} else if (taskToRun.button.link) {
this.openerService.open(taskToRun.button.link);
this.gettingStartedService.progressByEvent('linkOpened:' + taskToRun.button.link);
} else {
throw Error('Task ' + JSON.stringify(taskToRun) + ' does not have an associated action');
case 'openFolder': {
this.commandService.executeCommand(isMacintosh ? 'workbench.action.files.openFileFolder' : 'workbench.action.files.openFolder');
break;
}
case 'selectCategory': {
const selectedCategory = this.gettingStartedCategories.find(category => category.id === argument);
if (!selectedCategory) { throw Error('Could not find category with ID ' + argument); }
if (selectedCategory.content.type === 'startEntry') {
this.commandService.executeCommand(selectedCategory.content.command);
} else {
this.scrollToCategory(argument);
}
break;
}
case 'hideCategory': {
const selectedCategory = this.gettingStartedCategories.find(category => category.id === argument);
if (!selectedCategory) { throw Error('Could not find category with ID ' + argument); }
this.configurationService.updateValue(hiddenEntriesConfigurationKey,
[...(this.configurationService.getValue<string[]>(hiddenEntriesConfigurationKey) ?? []), argument]);
element.parentElement?.remove();
break;
}
case 'selectTask': {
this.selectTask(argument);
break;
}
case 'toggleTaskCompletion': {
if (!this.currentCategory || this.currentCategory.content.type !== 'items') {
throw Error('cannot run task action for category of non items type' + this.currentCategory?.id);
}

const taskToggle = assertIsDefined(this.currentCategory?.content.items.find(task => task.id === argument));
if (taskToggle.done) {
this.gettingStartedService.deprogressTask(argument);
} else {
this.gettingStartedService.progressTask(argument);
}
break;
}
case 'runTaskAction': {
if (!this.currentCategory || this.currentCategory.content.type !== 'items') {
throw Error('cannot run task action for category of non items type' + this.currentCategory?.id);
}
const taskToRun = assertIsDefined(this.currentCategory?.content.items.find(task => task.id === argument));
const command = taskToRun.button.command;
if (command) {
if (taskToRun.button.command && taskToRun.button.sideBySide) {
if (this.groupsService.count === 1) {
await this.commandService.executeCommand('workbench.action.editorLayoutTwoColumns');
}
await this.commandService.executeCommand('workbench.action.focusNextGroup');
await this.commandService.executeCommand(command);
} else {
await this.commandService.executeCommand(command);
}
} else if (taskToRun.button.link) {
this.openerService.open(taskToRun.button.link);
this.gettingStartedService.progressByEvent('linkOpened:' + taskToRun.button.link);
} else {
throw Error('Task ' + JSON.stringify(taskToRun) + ' does not have an associated action');
}
break;
}
default: {
console.error('Dispatch to', command, argument, 'not defined');
break;
}
break;
}
default: {
console.error('Dispatch to', command, argument, 'not defined');
break;
}
}
})();
e.stopPropagation();
}));
}
Expand Down
Expand Up @@ -48,7 +48,7 @@ export interface IGettingStartedTask {
order: number
button:
| { title: string, command?: never, link: string }
| { title: string, command: string, link?: never },
| { title: string, command: string, link?: never, sideBySide?: boolean }
doneOn: { commandExecuted: string, eventFired?: never } | { eventFired: string, commandExecuted?: never }
media: { type: 'image', path: { hc: URI, light: URI, dark: URI }, altText: string }
}
Expand Down
Expand Up @@ -20,7 +20,7 @@ export type BuiltinGettingStartedItem = {
description: string,
button:
| { title: string, command?: never, link: string }
| { title: string, command: string, link?: never },
| { title: string, command: string, link?: never, sideBySide?: boolean },
doneOn: { commandExecuted: string, eventFired?: never } | { eventFired: string, commandExecuted?: never, }
when?: string,
media: { type: 'image', path: string | { hc: string, light: string, dark: string }, altText: string },
Expand Down Expand Up @@ -290,7 +290,8 @@ export const content: GettingStartedContent = [
when: 'workspaceFolderCount != 0',
button: {
title: localize('gettingStarted.quickOpen.button', "Quick Open a File"),
command: 'workbench.action.quickOpen'
command: 'workbench.action.quickOpen',
sideBySide: true
},
doneOn: { commandExecuted: 'workbench.action.quickOpen' },
media: {
Expand Down Expand Up @@ -371,7 +372,8 @@ export const content: GettingStartedContent = [
description: localize('gettingStarted.settings.description', "Tweak every aspect of VS Code and your extensions to your liking. Commonly used settings are listed first to get you started."),
button: {
title: localize('gettingStarted.settings.button', "Tweak my Settings"),
command: 'workbench.action.openSettings'
command: 'workbench.action.openSettings',
sideBySide: true
},
doneOn: { commandExecuted: 'workbench.action.openSettings' },
media: {
Expand Down