Unverified Commit 82ad163a authored by Hung-Han (Henry) Chen's avatar Hung-Han (Henry) Chen
Browse files

Allow entity uid

Signed-off-by: default avatarHung-Han (Henry) Chen <chenhungh@gmail.com>
No related merge requests found
Showing with 6 additions and 5 deletions
+6 -5
......@@ -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
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment