Skip to content

Commit

Permalink
Close #121778
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl committed Aug 17, 2021
1 parent 6546ea8 commit 5294e11
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/vs/platform/extensions/common/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export interface IWalkthrough {
readonly title: string;
readonly description: string;
readonly steps: IWalkthroughStep[];
readonly featuredFor: string[] | undefined;
readonly when?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export class GettingStartedPage extends EditorPane {

const rerender = () => {
this.gettingStartedCategories = this.gettingStartedService.getWalkthroughs();
console.log(this.gettingStartedCategories);
if (this.currentWalkthrough) {
const existingSteps = this.currentWalkthrough.steps.map(step => step.id);
const newCategory = this.gettingStartedCategories.find(category => this.currentWalkthrough?.id === category.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { IStartEntry, IWalkthrough } from 'vs/platform/extensions/common/extensions';
import { IWalkthrough } from 'vs/platform/extensions/common/extensions';
import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry';

const titleTranslated = localize('title', "Title");
Expand All @@ -31,16 +31,17 @@ export const walkthroughsExtensionPoint = ExtensionsRegistry.registerExtensionPo
type: 'string',
description: localize('walkthroughs.description', "Description of walkthrough.")
},
primary: {
deprecationMessage: localize('walkthroughs.primary.deprecated', "Deprecated. The first walkthrough with a satisfied when condition will be opened on install.")
featuredFor: {
type: 'array',
description: localize('walkthroughs.featuredFor', "Walkthroughs that match one of these glob patterns appear as 'featured' in workspaces with the specified files. For example, a walkthrough for TypeScript projects might specify `tsconfig.json` here."),
items: {
type: 'string'
},
},
when: {
type: 'string',
description: localize('walkthroughs.when', "Context key expression to control the visibility of this walkthrough.")
},
tasks: {
deprecationMessage: localize('usesteps', "Deprecated. Use `steps` instead")
},
steps: {
type: 'array',
description: localize('walkthroughs.steps', "Steps to complete as part of this walkthrough."),
Expand Down Expand Up @@ -195,10 +196,3 @@ export const walkthroughsExtensionPoint = ExtensionsRegistry.registerExtensionPo
}
}
});

ExtensionsRegistry.registerExtensionPoint<IStartEntry[]>({
extensionPoint: 'startEntries',
jsonSchema: {
deprecationMessage: localize('removed', "Removed, use the menus => file/newFile contribution point instead"),
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx

private entries: T[];

private lastRendered: string[];
private lastRendered: string[] | undefined;

public itemCount: number;

Expand All @@ -49,7 +49,6 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx
this.contextService = options.contextService;

this.entries = [];
this.lastRendered = [];

this.itemCount = 0;
this.list = $('ul');
Expand Down Expand Up @@ -101,7 +100,6 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx
if (ranker) {
entries = entries.filter(e => ranker(e) !== null);
entries.sort((a, b) => ranker(b)! - ranker(a)!);
console.log(entries, entries.map(ranker));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { createDecorator, optional, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator, IInstantiationService, optional, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { Emitter, Event } from 'vs/base/common/event';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { Memento } from 'vs/workbench/common/memento';
Expand Down Expand Up @@ -32,6 +32,9 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
import { isLinux, isMacintosh, isWindows, OperatingSystem as OS } from 'vs/base/common/platform';
import { localize } from 'vs/nls';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { checkGlobFileExists } from 'vs/workbench/api/common/shared/workspaceContains';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { CancellationTokenSource } from 'vs/base/common/cancellation';

export const WorkspacePlatform = new RawContextKey<'mac' | 'linux' | 'windows' | undefined>('workspacePlatform', undefined, localize('workspacePlatform', "The platform of the current workspace, which in remote contexts may be different from the platform of the UI"));
export const HasMultipleNewFileEntries = new RawContextKey<boolean>('hasMultipleNewFileEntries', false);
Expand Down Expand Up @@ -147,6 +150,8 @@ export class GettingStartedService extends Disposable implements IWalkthroughsSe
constructor(
@IStorageService private readonly storageService: IStorageService,
@ICommandService private readonly commandService: ICommandService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@IContextKeyService private readonly contextService: IContextKeyService,
@IUserDataAutoSyncEnablementService private readonly userDataAutoSyncEnablementService: IUserDataAutoSyncEnablementService,
@IConfigurationService private readonly configurationService: IConfigurationService,
Expand Down Expand Up @@ -406,11 +411,19 @@ export class GettingStartedService extends Disposable implements IWalkthroughsSe
});
});

let isFeatured = false;
if (walkthrough.featuredFor) {
const folders = this.workspaceContextService.getWorkspace().folders.map(f => f.uri);
const token = new CancellationTokenSource();
setTimeout(() => token.cancel(), 2000);
isFeatured = await this.instantiationService.invokeFunction(a => checkGlobFileExists(a, folders, walkthrough.featuredFor!, token.token));
}

const walkthoughDescriptor: IWalkthrough = {
description: walkthrough.description,
title: walkthrough.title,
id: categoryID,
isFeatured: false,
isFeatured,
source: extension.displayName ?? extension.name,
order: 0,
steps,
Expand Down Expand Up @@ -459,7 +472,7 @@ export class GettingStartedService extends Disposable implements IWalkthroughsSe
});
}

getWalkthrough(id: string) {
getWalkthrough(id: string): IResolvedWalkthrough {
const walkthrough = this.gettingStartedContributions.get(id);
if (!walkthrough) { throw Error('Trying to get unknown walkthrough: ' + id); }
return this.resolveWalkthrough(walkthrough);
Expand All @@ -479,7 +492,7 @@ export class GettingStartedService extends Disposable implements IWalkthroughsSe
})
.filter(category => category.content.type !== 'steps' || category.content.steps.length)
.map(category => this.resolveWalkthrough(category));
// .sort((a, b) => b.order - a.order);

return categoriesWithCompletion;
}

Expand Down

0 comments on commit 5294e11

Please sign in to comment.