Add excludeFlags to extenson marketplace query (#17121)

* Add excludeFlags to extenson marketplace query

* Remove dead code

* Remove extraneous blank line

* Address code review feedback
This commit is contained in:
Karl Burtram
2021-09-21 13:52:11 -07:00
committed by GitHub
parent a648877446
commit fad2963202
3 changed files with 17 additions and 1 deletions

View File

@@ -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 ? {

View File

@@ -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 {

View File

@@ -751,6 +751,7 @@ export class ExtensionsListView extends ViewPane {
// {{SQL CARBON EDIT}}
private getAllMarketplaceModel(query: Query, options: IQueryOptions, token: CancellationToken): Promise<IPagedModel<IExtension>> {
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 => {