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

vsx-registry: add support for additional queries #9572

Merged
merged 1 commit into from
Jun 14, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion packages/vsx-registry/src/browser/vsx-extensions-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { LabelProvider, PreferenceService } from '@theia/core/lib/browser';
import { VscodeCommands } from '@theia/plugin-ext-vscode/lib/browser/plugin-vscode-commands-contribution';
import { VSXExtensionsContextMenu, VSXExtension } from './vsx-extension';
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
import { RECOMMENDED_QUERY } from './vsx-extensions-search-model';
import { BUILTIN_QUERY, INSTALLED_QUERY, RECOMMENDED_QUERY } from './vsx-extensions-search-model';
import { IGNORE_RECOMMENDATIONS_ID } from './recommended-extensions/recommended-extensions-preference-contribution';

export namespace VSXExtensionsCommands {
Expand All @@ -56,6 +56,16 @@ export namespace VSXExtensionsCommands {
export const COPY_EXTENSION_ID: Command = {
id: 'vsxExtensions.copyExtensionId'
};
export const SHOW_BUILTINS: Command = {
id: 'vsxExtension.showBuiltins',
label: 'Show Built-in Extensions',
category: EXTENSIONS_CATEGORY,
};
export const SHOW_INSTALLED: Command = {
id: 'vsxExtension.showInstalled',
label: 'Show Installed Extensions',
category: EXTENSIONS_CATEGORY,
};
export const SHOW_RECOMMENDATIONS: Command = {
id: 'vsxExtension.showRecommendations',
label: 'Show Recommended Extensions',
Expand Down Expand Up @@ -121,6 +131,14 @@ export class VSXExtensionsContribution extends AbstractViewContribution<VSXExten
execute: (extension: VSXExtension) => this.copyExtensionId(extension)
});

commands.registerCommand(VSXExtensionsCommands.SHOW_BUILTINS, {
execute: () => this.showBuiltinExtensions()
});

commands.registerCommand(VSXExtensionsCommands.SHOW_INSTALLED, {
execute: () => this.showInstalledExtensions()
});

commands.registerCommand(VSXExtensionsCommands.SHOW_RECOMMENDATIONS, {
execute: () => this.showRecommendedExtensions()
});
Expand Down Expand Up @@ -263,6 +281,16 @@ export class VSXExtensionsContribution extends AbstractViewContribution<VSXExten
}
}

protected async showBuiltinExtensions(): Promise<void> {
await this.openView({ activate: true });
this.model.search.query = BUILTIN_QUERY;
}

protected async showInstalledExtensions(): Promise<void> {
await this.openView({ activate: true });
this.model.search.query = INSTALLED_QUERY;
}

protected async showRecommendedExtensions(): Promise<void> {
await this.openView({ activate: true });
this.model.search.query = RECOMMENDED_QUERY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ export enum VSXSearchMode {
Initial,
None,
Search,
Installed,
Builtin,
Recommended,
}

export const BUILTIN_QUERY = '@builtin';
export const INSTALLED_QUERY = '@installed';
export const RECOMMENDED_QUERY = '@recommended';

@injectable()
Expand All @@ -32,7 +36,9 @@ export class VSXExtensionsSearchModel {
protected readonly onDidChangeQueryEmitter = new Emitter<string>();
readonly onDidChangeQuery = this.onDidChangeQueryEmitter.event;
protected readonly specialQueries = new Map<string, VSXSearchMode>([
[RECOMMENDED_QUERY, VSXSearchMode.Recommended]
[BUILTIN_QUERY, VSXSearchMode.Builtin],
[INSTALLED_QUERY, VSXSearchMode.Installed],
[RECOMMENDED_QUERY, VSXSearchMode.Recommended],
]);

protected _query = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export class VSXExtensionsViewContainer extends ViewContainer {

protected getWidgetsForMode(): string[] {
switch (this.currentMode) {
case VSXSearchMode.Builtin:
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.BUILT_IN)];
case VSXSearchMode.Installed:
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.INSTALLED)];
case VSXSearchMode.Recommended:
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.RECOMMENDED)];
case VSXSearchMode.Search:
Expand Down