Skip to content

Commit

Permalink
Support showing walkthrough page titles (#231546)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavyaus authored Oct 17, 2024
1 parent 8addf83 commit 62a233c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1603,10 +1603,14 @@ export class GettingStartedInputSerializer implements IEditorSerializer {
}

public deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): GettingStartedInput {
try {
const { selectedCategory, selectedStep } = JSON.parse(serializedEditorInput);
return new GettingStartedInput({ selectedCategory, selectedStep });
} catch { }
return new GettingStartedInput({});

return instantiationService.invokeFunction(accessor => {
try {
const { selectedCategory, selectedStep } = JSON.parse(serializedEditorInput);
return new GettingStartedInput({ selectedCategory, selectedStep }, accessor.get(IWalkthroughsService));
} catch { }
return new GettingStartedInput({}, accessor.get(IWalkthroughsService));

});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { URI } from '../../../../base/common/uri.js';
import { Schemas } from '../../../../base/common/network.js';
import { IUntypedEditorInput } from '../../../common/editor.js';
import { IEditorOptions } from '../../../../platform/editor/common/editor.js';
import { IWalkthroughsService } from './gettingStartedService.js';

export const gettingStartedInputTypeId = 'workbench.editors.gettingStartedInput';

Expand All @@ -21,6 +22,10 @@ export class GettingStartedInput extends EditorInput {

static readonly ID = gettingStartedInputTypeId;
static readonly RESOURCE = URI.from({ scheme: Schemas.walkThrough, authority: 'vscode_getting_started_page' });
private _selectedCategory: string | undefined;
private _selectedStep: string | undefined;
private _showTelemetryNotice: boolean;
private _showWelcome: boolean;

override get typeId(): string {
return GettingStartedInput.ID;
Expand Down Expand Up @@ -56,21 +61,50 @@ export class GettingStartedInput extends EditorInput {
}

constructor(
options: GettingStartedEditorOptions
options: GettingStartedEditorOptions,
@IWalkthroughsService private readonly walkthroughService: IWalkthroughsService
) {
super();
this.selectedCategory = options.selectedCategory;
this.selectedStep = options.selectedStep;
this.showTelemetryNotice = !!options.showTelemetryNotice;
this.showWelcome = options.showWelcome ?? true;
this._selectedCategory = options.selectedCategory;
this._selectedStep = options.selectedStep;
this._showTelemetryNotice = !!options.showTelemetryNotice;
this._showWelcome = options.showWelcome ?? true;
}

override getName() {
return localize('getStarted', "Welcome");
return this.selectedCategory ? this.walkthroughService.getWalkthrough(this.selectedCategory).walkthroughPageTitle : localize('getStarted', "Welcome");
}

selectedCategory: string | undefined;
selectedStep: string | undefined;
showTelemetryNotice: boolean;
showWelcome: boolean;
get selectedCategory() {
return this._selectedCategory;
}

set selectedCategory(selectedCategory: string | undefined) {
this._selectedCategory = selectedCategory;
this._onDidChangeLabel.fire();
}

get selectedStep() {
return this._selectedStep;
}

set selectedStep(selectedStep: string | undefined) {
this._selectedStep = selectedStep;
}

get showTelemetryNotice(): boolean {
return this._showTelemetryNotice;
}

set showTelemetryNotice(value: boolean) {
this._showTelemetryNotice = value;
}

get showWelcome(): boolean {
return this._showWelcome;
}

set showWelcome(value: boolean) {
this._showWelcome = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface IWalkthrough {
icon:
| { type: 'icon'; icon: ThemeIcon }
| { type: 'image'; path: string };
walkthroughPageTitle: string;
}

export type IWalkthroughLoose = Omit<IWalkthrough, 'steps'> & { steps: (Omit<IWalkthroughStep, 'description'> & { description: string })[] };
Expand Down Expand Up @@ -390,6 +391,7 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
isFeatured,
source: extension.displayName ?? extension.name,
order: 0,
walkthroughPageTitle: extension.displayName ?? extension.name,
steps,
icon: {
type: 'image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type BuiltinGettingStartedCategory = {
when?: string;
content:
| { type: 'steps'; steps: BuiltinGettingStartedStep[] };
walkthroughPageTitle: string;
};

export type BuiltinGettingStartedStartEntry = {
Expand Down Expand Up @@ -216,6 +217,7 @@ export const walkthroughs: GettingStartedWalkthroughContent = [
isFeatured: true,
icon: setupIcon,
when: '!isWeb',
walkthroughPageTitle: localize('gettingStarted.setup.walkthroughPageTitle', 'Setup VS Code'),
next: 'Beginner',
content: {
type: 'steps',
Expand Down Expand Up @@ -317,6 +319,7 @@ export const walkthroughs: GettingStartedWalkthroughContent = [
icon: setupIcon,
when: 'isWeb',
next: 'Beginner',
walkthroughPageTitle: localize('gettingStarted.setupWeb.walkthroughPageTitle', 'Setup VS Code Web'),
content: {
type: 'steps',
steps: [
Expand Down Expand Up @@ -402,6 +405,7 @@ export const walkthroughs: GettingStartedWalkthroughContent = [
icon: setupIcon,
when: CONTEXT_ACCESSIBILITY_MODE_ENABLED.key,
next: 'Setup',
walkthroughPageTitle: localize('gettingStarted.setupAccessibility.walkthroughPageTitle', 'Setup VS Code Accessibility'),
content: {
type: 'steps',
steps: [
Expand Down Expand Up @@ -498,6 +502,7 @@ export const walkthroughs: GettingStartedWalkthroughContent = [
title: localize('gettingStarted.beginner.title', "Learn the Fundamentals"),
icon: beginnerIcon,
description: localize('gettingStarted.beginner.description', "Get an overview of the most essential features"),
walkthroughPageTitle: localize('gettingStarted.beginner.walkthroughPageTitle', 'Essential Features'),
content: {
type: 'steps',
steps: [
Expand Down Expand Up @@ -604,6 +609,7 @@ export const walkthroughs: GettingStartedWalkthroughContent = [
icon: setupIcon,
isFeatured: false,
when: `config.${NotebookSetting.openGettingStarted} && userHasOpenedNotebook`,
walkthroughPageTitle: localize('gettingStarted.notebook.walkthroughPageTitle', 'Notebooks'),
content: {
type: 'steps',
steps: [
Expand Down

0 comments on commit 62a233c

Please sign in to comment.