mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Run extension queries in sections only if applicable
This commit is contained in:
parent
d96cf918b7
commit
7e9474edbe
|
@ -144,6 +144,12 @@ export class ExtensionsListView extends ViewletPanel {
|
|||
return this.list.length;
|
||||
}
|
||||
|
||||
protected showEmptyModel(): TPromise<IPagedModel<IExtension>> {
|
||||
const emptyModel = new PagedModel([]);
|
||||
this.setModel(emptyModel);
|
||||
return TPromise.as(emptyModel);
|
||||
}
|
||||
|
||||
private async query(value: string): Promise<IPagedModel<IExtension>> {
|
||||
const query = Query.parse(value);
|
||||
|
||||
|
@ -686,42 +692,41 @@ export class GroupByServerExtensionsView extends ExtensionsListView {
|
|||
}
|
||||
|
||||
export class EnabledExtensionsView extends ExtensionsListView {
|
||||
private readonly enabledExtensionsQuery = '@enabled';
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show('@enabled');
|
||||
return (query && query.trim() !== this.enabledExtensionsQuery) ? this.showEmptyModel() : super.show(this.enabledExtensionsQuery);
|
||||
}
|
||||
}
|
||||
|
||||
export class DisabledExtensionsView extends ExtensionsListView {
|
||||
private readonly disabledExtensionsQuery = '@disabled';
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show('@disabled');
|
||||
return (query && query.trim() !== this.disabledExtensionsQuery) ? this.showEmptyModel() : super.show(this.disabledExtensionsQuery);
|
||||
}
|
||||
}
|
||||
|
||||
export class BuiltInExtensionsView extends ExtensionsListView {
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show(query.replace('@builtin', '@builtin:features'));
|
||||
return (query && query.trim() !== '@builtin') ? this.showEmptyModel() : super.show('@builtin:features');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class BuiltInThemesExtensionsView extends ExtensionsListView {
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show(query.replace('@builtin', '@builtin:themes'));
|
||||
return (query && query.trim() !== '@builtin') ? this.showEmptyModel() : super.show('@builtin:themes');
|
||||
}
|
||||
}
|
||||
|
||||
export class BuiltInBasicsExtensionsView extends ExtensionsListView {
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show(query.replace('@builtin', '@builtin:basics'));
|
||||
return (query && query.trim() !== '@builtin') ? this.showEmptyModel() : super.show('@builtin:basics');
|
||||
}
|
||||
}
|
||||
|
||||
export class DefaultRecommendedExtensionsView extends ExtensionsListView {
|
||||
private readonly recommendedExtensionsQuery = '@recommended:all';
|
||||
|
||||
renderBody(container: HTMLElement): void {
|
||||
super.renderBody(container);
|
||||
|
@ -732,13 +737,13 @@ export class DefaultRecommendedExtensionsView extends ExtensionsListView {
|
|||
}
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show('@recommended:all');
|
||||
return (query && query.trim() !== this.recommendedExtensionsQuery) ? this.showEmptyModel() : super.show(this.recommendedExtensionsQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class RecommendedExtensionsView extends ExtensionsListView {
|
||||
|
||||
private readonly recommendedExtensionsQuery = '@recommended';
|
||||
|
||||
renderBody(container: HTMLElement): void {
|
||||
super.renderBody(container);
|
||||
|
@ -749,12 +754,12 @@ export class RecommendedExtensionsView extends ExtensionsListView {
|
|||
}
|
||||
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
return super.show('@recommended');
|
||||
return (query && query.trim() !== this.recommendedExtensionsQuery) ? this.showEmptyModel() : super.show(this.recommendedExtensionsQuery);
|
||||
}
|
||||
}
|
||||
|
||||
export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
|
||||
|
||||
private readonly recommendedExtensionsQuery = '@recommended:workspace';
|
||||
private installAllAction: InstallWorkspaceRecommendedExtensionsAction;
|
||||
|
||||
renderBody(container: HTMLElement): void {
|
||||
|
@ -788,14 +793,14 @@ export class WorkspaceRecommendedExtensionsView extends ExtensionsListView {
|
|||
this.disposables.push(...[this.installAllAction, configureWorkspaceFolderAction, actionbar]);
|
||||
}
|
||||
|
||||
async show(): Promise<IPagedModel<IExtension>> {
|
||||
let model = await super.show('@recommended:workspace');
|
||||
async show(query: string): Promise<IPagedModel<IExtension>> {
|
||||
let model = await ((query && query.trim() !== '@recommended') ? this.showEmptyModel() : super.show(this.recommendedExtensionsQuery));
|
||||
this.setExpanded(model.length > 0);
|
||||
return model;
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
this.show();
|
||||
this.show(this.recommendedExtensionsQuery);
|
||||
this.setRecommendationsToInstall();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue