1
0
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:
Hung-Han (Henry) Chen 2021-10-07 10:39:49 +03:00
parent ae96ae7d50
commit 82ad163af0
No known key found for this signature in database
GPG Key ID: 54B44603D251B788
2 changed files with 6 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -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
*/