Add CatalogCategory filter to the extension API (#3718)

* Add CatalogCategory filter to the extension API.

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>

* Fix test.

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti authored and GitHub committed 2021-09-13 15:46:28 +03:00
1 parent e2b096fae1
commit 936927af98
6 files changed
+96 -8

No files matched your search

+16 -2
View File
@@ -26,6 +26,7 @@ import { getExtensionPageUrl } from "./registries/page-registry";
import type { CatalogEntity } from "../common/catalog";
import type { Disposer } from "../common/utils";
import { catalogEntityRegistry, EntityFilter } from "../renderer/api/catalog-entity-registry";
import { catalogCategoryRegistry, CategoryFilter } from "../renderer/api/catalog-category-registry";
export class LensRendererExtension extends LensExtension {
globalPages: registries.PageRegistration[] = [];
@@ -63,8 +64,8 @@ export class LensRendererExtension extends LensExtension {
}
/**
* Add a filtering function for the catalog. This will be removed if the extension is disabled.
* @param fn The function which should return a truthy value for those entities which should be kepted
* Add a filtering function for the catalog entities. This will be removed if the extension is disabled.
* @param fn The function which should return a truthy value for those entities which should be kept.
* @returns A function to clean up the filter
*/
addCatalogFilter(fn: EntityFilter): Disposer {
@@ -74,4 +75,17 @@ export class LensRendererExtension extends LensExtension {
return dispose;
}
/**
* Add a filtering function for the catalog catogries. This will be removed if the extension is disabled.
* @param fn The function which should return a truthy value for those categories which should be kept.
* @returns A function to clean up the filter
*/
addCatalogCategoryFilter(fn: CategoryFilter): Disposer {
const dispose = catalogCategoryRegistry.addCatalogCategoryFilter(fn);
this[Disposers].push(dispose);
return dispose;
}
}