From fad29632027942ef1a215bd108d348c2ced8e5dc Mon Sep 17 00:00:00 2001 From: Karl Burtram Date: Tue, 21 Sep 2021 13:52:11 -0700 Subject: [PATCH] Add excludeFlags to extenson marketplace query (#17121) * Add excludeFlags to extenson marketplace query * Remove dead code * Remove extraneous blank line * Address code review feedback --- .../common/extensionGalleryService.ts | 12 +++++++++++- .../common/extensionManagement.ts | 5 +++++ .../contrib/extensions/browser/extensionsViews.ts | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts index 1190a2eaa5..77f3a9760b 100644 --- a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts @@ -542,6 +542,10 @@ export class ExtensionGalleryService implements IExtensionGalleryService { .withPage(1, pageSize) .withFilter(FilterType.Target, 'Microsoft.VisualStudio.Code'); + if (options.excludeFlags) { + query = query.withFilter(FilterType.ExcludeWithFlags, options.excludeFlags); // {{SQL CARBON EDIT}} exclude extensions matching excludeFlags options + } + if (text) { // Use category filter instead of "category:themes" text = text.replace(/\bcategory:("([^"]*)"|([^"]\S*))(\s+|\b|$)/g, (_, quotedCategory, category) => { @@ -645,6 +649,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService { } }); } + + // {{SQL CARBON EDIT}} - filter out extensions that match the excludeFlags options + const flags = query.criteria.filter(x => x.filterType === FilterType.ExcludeWithFlags).map(v => v.value ? v.value.toLocaleLowerCase() : undefined); + if (flags && flags.length > 0) { + filteredExtensions = filteredExtensions.filter(e => !e.flags || flags.find(x => x === e.flags.toLocaleLowerCase()) === undefined); + } } // Sorting @@ -811,7 +821,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService { */ const log = (duration: number) => this.telemetryService.publicLog('galleryService:downloadVSIX', { ...data, duration }); - // {{SQL Carbon Edit}} - Don't append install or update on to the URL + // {{SQL CARBON EDIT}} - Don't append install or update on to the URL // const operationParam = operation === InstallOperation.Install ? 'install' : operation === InstallOperation.Update ? 'update' : ''; const operationParam = undefined; const downloadAsset = operationParam ? { diff --git a/src/vs/platform/extensionManagement/common/extensionManagement.ts b/src/vs/platform/extensionManagement/common/extensionManagement.ts index 201137aaa1..49877e421a 100644 --- a/src/vs/platform/extensionManagement/common/extensionManagement.ts +++ b/src/vs/platform/extensionManagement/common/extensionManagement.ts @@ -136,6 +136,11 @@ export interface IQueryOptions { sortBy?: SortBy; sortOrder?: SortOrder; source?: string; + // {{SQL CARBON EDIT}} do not show extensions matching excludeFlags in the marketplace + // This field only supports an exact match of a single flag. It doesn't currently + // support setting multiple flags such as "hidden,preview" since this functionality isn't + // required by current usage scenarios. + excludeFlags?: string; } export const enum StatisticType { diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsViews.ts b/src/vs/workbench/contrib/extensions/browser/extensionsViews.ts index 62378fb893..c56e12b1de 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsViews.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsViews.ts @@ -751,6 +751,7 @@ export class ExtensionsListView extends ViewPane { // {{SQL CARBON EDIT}} private getAllMarketplaceModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise> { const value = query.value.trim().toLowerCase(); + options.excludeFlags = 'hidden'; // {{SQL CARBON EDIT}} exclude extensions with 'hidden' flag from marketplace query return this.extensionsWorkbenchService.queryLocal() .then(result => result.filter(e => e.type === ExtensionType.User)) .then(local => {