mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Support filtering catalog entities (#3647)
* Support filtering catalog entities - This allows extensions and OpenLens to restrict which of the entities the sources have provied are "visible" to the rest of Lens Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * switch to filtering only for catalog view Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix test Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Add test to iter reduce Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> Co-authored-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
1 parent
7981e79cbd
commit
6fdb2f0b58
8 files changed
+192
-27
No files matched your search
@@ -21,9 +21,11 @@
|
||||
|
||||
import type * as registries from "./registries";
|
||||
import type { Cluster } from "../main/cluster";
|
||||
import { LensExtension } from "./lens-extension";
|
||||
import { Disposers, LensExtension } from "./lens-extension";
|
||||
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";
|
||||
|
||||
export class LensRendererExtension extends LensExtension {
|
||||
globalPages: registries.PageRegistration[] = [];
|
||||
@@ -59,4 +61,17 @@ export class LensRendererExtension extends LensExtension {
|
||||
async isEnabledForCluster(cluster: Cluster): Promise<Boolean> {
|
||||
return (void cluster) || true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @returns A function to clean up the filter
|
||||
*/
|
||||
addCatalogFilter(fn: EntityFilter): Disposer {
|
||||
const dispose = catalogEntityRegistry.addCatalogFilter(fn);
|
||||
|
||||
this[Disposers].push(dispose);
|
||||
|
||||
return dispose;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user