mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow entity uid
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
parent
ae96ae7d50
commit
82ad163af0
@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
import type { CatalogCategory, CatalogEntity } from "../../common/catalog";
|
||||
import type { CatalogEntityUid } from "../../renderer/api/catalog-entity-registry";
|
||||
import { catalogEntityRegistry as registry } from "../../renderer/api/catalog-entity-registry";
|
||||
import type { CatalogEntityOnBeforeRun } from "../../renderer/api/catalog-entity-registry";
|
||||
import type { Disposer } from "../../common/utils";
|
||||
@ -52,12 +53,12 @@ export class CatalogEntityRegistry {
|
||||
|
||||
/**
|
||||
* Add a onBeforeRun hook to a catalog entity. If `onBeforeRun` was previously added then it will not be added again
|
||||
* @param catalogEntityUid The uid of the catalog entity
|
||||
* @param entityOrId Catalog entity or the uid of the catalog entity
|
||||
* @param onBeforeRun The function that should return a boolean if the onRun of catalog entity should be triggered.
|
||||
* @returns A function to remove that hook
|
||||
*/
|
||||
addOnBeforeRun(entity: CatalogEntity, onBeforeRun: CatalogEntityOnBeforeRun): Disposer {
|
||||
return registry.addOnBeforeRun(entity, onBeforeRun);
|
||||
addOnBeforeRun(entityOrId: CatalogEntity | CatalogEntityUid, onBeforeRun: CatalogEntityOnBeforeRun): Disposer {
|
||||
return registry.addOnBeforeRun(entityOrId, onBeforeRun);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ import { catalogEntityRunContext } from "./catalog-entity";
|
||||
export type EntityFilter = (entity: CatalogEntity) => any;
|
||||
export type CatalogEntityOnBeforeRun = (entity: CatalogEntity) => boolean | Promise<boolean>;
|
||||
|
||||
type CatalogEntityUid = CatalogEntity["metadata"]["uid"];
|
||||
export type CatalogEntityUid = CatalogEntity["metadata"]["uid"];
|
||||
|
||||
export class CatalogEntityRegistry {
|
||||
@observable protected activeEntityId: string | undefined = undefined;
|
||||
@ -180,7 +180,7 @@ export class CatalogEntityRegistry {
|
||||
|
||||
/**
|
||||
* Add a onBeforeRun hook to a catalog entity. If `onBeforeRun` was previously added then it will not be added again
|
||||
* @param catalogEntityUid The uid of the catalog entity
|
||||
* @param entityOrId Catalog entity or the uid of the catalog entity
|
||||
* @param onBeforeRun The function that should return a boolean if the onRun of catalog entity should be triggered.
|
||||
* @returns A function to remove that hook
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user