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:
Sebastian MaltonandPanu Horsmalahti authored and GitHub committed 2021-08-31 16:00:56 +03:00
1 parent 7981e79cbd
commit 6fdb2f0b58
8 files changed
+192 -27

No files matched your search

@@ -129,10 +129,10 @@ export class CatalogEntityStore extends ItemStore<CatalogEntityItem<CatalogEntit
@computed get entities() {
if (!this.activeCategory) {
return catalogEntityRegistry.items.map(entity => new CatalogEntityItem(entity));
return catalogEntityRegistry.filteredItems.map(entity => new CatalogEntityItem(entity));
}
return catalogEntityRegistry.getItemsForCategory(this.activeCategory).map(entity => new CatalogEntityItem(entity));
return catalogEntityRegistry.getItemsForCategory(this.activeCategory, { filtered: true }).map(entity => new CatalogEntityItem(entity));
}
@computed get selectedItem() {
@@ -52,7 +52,7 @@ export class HotbarMenu extends React.Component<Props> {
return null;
}
return item ? catalogEntityRegistry.items.find((entity) => entity.metadata.uid === item.entity.uid) : null;
return catalogEntityRegistry.getById(item?.entity.uid) ?? null;
}
onDragEnd(result: DropResult) {