1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Allow computed catalog source from extension (#7053)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2023-01-30 16:37:31 +02:00 committed by GitHub
parent a370dbb15a
commit 4a47e92b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@
import { LensExtension, lensExtensionDependencies } from "./lens-extension"; import { LensExtension, lensExtensionDependencies } from "./lens-extension";
import type { CatalogEntity } from "../common/catalog"; import type { CatalogEntity } from "../common/catalog";
import type { IComputedValue, IObservableArray } from "mobx"; import type { IComputedValue, IObservableArray } from "mobx";
import { isObservableArray } from "mobx";
import type { MenuRegistration } from "../features/application-menu/main/menu-registration"; import type { MenuRegistration } from "../features/application-menu/main/menu-registration";
import type { TrayMenuRegistration } from "../main/tray/tray-menu-registration"; import type { TrayMenuRegistration } from "../main/tray/tray-menu-registration";
import type { ShellEnvModifier } from "../main/shell-session/shell-env-modifier/shell-env-modifier-registration"; import type { ShellEnvModifier } from "../main/shell-session/shell-env-modifier/shell-env-modifier-registration";
@ -34,8 +35,12 @@ export class LensMainExtension extends LensExtension<LensMainExtensionDependenci
await this[lensExtensionDependencies].navigate(this.id, pageId, params, frameId); await this[lensExtensionDependencies].navigate(this.id, pageId, params, frameId);
} }
addCatalogSource(id: string, source: IObservableArray<CatalogEntity>) { addCatalogSource(id: string, source: IObservableArray<CatalogEntity> | IComputedValue<CatalogEntity[]>) {
this[lensExtensionDependencies].entityRegistry.addObservableSource(`${this.name}:${id}`, source); if (isObservableArray(source)) {
this[lensExtensionDependencies].entityRegistry.addObservableSource(`${this.name}:${id}`, source);
} else {
this[lensExtensionDependencies].entityRegistry.addComputedSource(`${this.name}:${id}`, source);
}
} }
removeCatalogSource(id: string) { removeCatalogSource(id: string) {