Remove "primary" in favor of alway opening the first applicable walkthrough

This commit is contained in:
Jackson Kearl 2021-05-29 10:17:35 -07:00
parent 6adfa8b313
commit bb5b6afdce
No known key found for this signature in database
GPG key ID: DA09A59C409FC400
3 changed files with 32 additions and 40 deletions

View file

@ -131,7 +131,6 @@ export interface IWalkthrough {
readonly title: string;
readonly description: string;
readonly steps: IWalkthroughStep[];
readonly primary?: boolean;
readonly when?: string;
}

View file

@ -11,7 +11,7 @@ export const walkthroughsExtensionPoint = ExtensionsRegistry.registerExtensionPo
extensionPoint: 'walkthroughs',
jsonSchema: {
doNotSuggest: true,
description: localize('walkthroughs', "Contribute collections of steps to help users with your extension. Experimental, available in VS Code Insiders only."),
description: localize('walkthroughs', "Contribute walkthroughs to help users getting started with your extension."),
type: 'array',
items: {
type: 'object',
@ -31,8 +31,7 @@ export const walkthroughsExtensionPoint = ExtensionsRegistry.registerExtensionPo
description: localize('walkthroughs.description', "Description of walkthrough.")
},
primary: {
type: 'boolean',
description: localize('walkthroughs.primary', "if this is a `primary` walkthrough, hinting if it should be opened on install of the extension. The first `primary` walkthough with a `when` condition matching the current context may be opened by core on install of the extension.")
deprecationMessage: localize('walkthroughs.primary.deprecated', "Deprecated. The first walkthrough with a satisfied when condition will be opened on install.")
},
when: {
type: 'string',

View file

@ -366,45 +366,37 @@ export class GettingStartedService extends Disposable implements IGettingStarted
}
};
let sectionToOpen: string | undefined;
if (!(extension.contributes?.walkthroughs?.length)) {
return;
}
if (this.productService.quality === 'stable') {
console.warn('Extension', extension.identifier.value, 'contributes welcome page content but this is a Stable build and extension contributions are only available in Insiders. The contributed content will be disregarded.');
return;
}
if (!this.configurationService.getValue<boolean>('workbench.welcomePage.experimental.extensionContributions')) {
console.warn('Extension', extension.identifier.value, 'contributes welcome page content but the welcome page extension contribution feature flag has not been set. Set `workbench.welcomePage.experimental.extensionContributions` to begin using this experimental feature.');
return;
}
extension.contributes.startEntries?.forEach(entry => {
const entryID = extension.identifier.value + '#startEntry#' + idForStartEntry(entry);
this.registerStartEntry({
content: {
type: 'startEntry',
command: entry.command,
},
description: entry.description,
title: entry.title,
id: entryID,
order: 0,
when: ContextKeyExpr.deserialize(entry.when) ?? ContextKeyExpr.true(),
icon: {
type: 'image',
path: extension.icon
? FileAccess.asBrowserUri(joinPath(extension.extensionLocation, extension.icon)).toString(true)
: DefaultIconPath
}
if (this.configurationService.getValue<boolean>('workbench.welcomePage.experimental.startEntryContributions') && this.productService.quality !== 'stable') {
extension.contributes.startEntries?.forEach(entry => {
const entryID = extension.identifier.value + '#startEntry#' + idForStartEntry(entry);
this.registerStartEntry({
content: {
type: 'startEntry',
command: entry.command,
},
description: entry.description,
title: entry.title,
id: entryID,
order: 0,
when: ContextKeyExpr.deserialize(entry.when) ?? ContextKeyExpr.true(),
icon: {
type: 'image',
path: extension.icon
? FileAccess.asBrowserUri(joinPath(extension.extensionLocation, extension.icon)).toString(true)
: DefaultIconPath
}
});
});
});
}
await Promise.all(extension.contributes?.walkthroughs?.map(async walkthrough => {
let sectionToOpen: string | undefined;
let sectionToOpenIndex = Math.max();
await Promise.all(extension.contributes?.walkthroughs?.map(async (walkthrough, index) => {
const categoryID = extension.identifier.value + '#' + walkthrough.id;
const override = await Promise.race([
@ -414,11 +406,13 @@ export class GettingStartedService extends Disposable implements IGettingStarted
if (
this.sessionInstalledExtensions.has(extension.identifier.value)
&& walkthrough.primary
&& this.contextService.contextMatchesRules(ContextKeyExpr.deserialize(override ?? walkthrough.when) ?? ContextKeyExpr.true())
) {
this.sessionInstalledExtensions.delete(extension.identifier.value);
sectionToOpen = categoryID;
if (index < sectionToOpenIndex) {
sectionToOpen = categoryID;
sectionToOpenIndex = index;
}
}
const walkthoughDescriptior = {
@ -433,7 +427,7 @@ export class GettingStartedService extends Disposable implements IGettingStarted
? FileAccess.asBrowserUri(joinPath(extension.extensionLocation, extension.icon)).toString(true)
: DefaultIconPath
},
when: ContextKeyExpr.deserialize(walkthrough.when) ?? ContextKeyExpr.true(),
when: ContextKeyExpr.deserialize(override ?? walkthrough.when) ?? ContextKeyExpr.true(),
} as const;
const steps = (walkthrough.steps ?? (walkthrough as any).tasks).map((step, index) => {
@ -498,7 +492,7 @@ export class GettingStartedService extends Disposable implements IGettingStarted
this.triggerInstalledExtensionsRegistered();
if (sectionToOpen && this.configurationService.getValue<string>('workbench.welcomePage.experimental.extensionContributions') !== 'hide') {
if (sectionToOpen && this.configurationService.getValue<string>('workbench.welcomePage.walkthroughs.openOnInstall')) {
this.commandService.executeCommand('workbench.action.openWalkthrough', sectionToOpen);
}
}