From 040fffdda856c1d87244d77b4b685395f1e88624 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Sat, 2 Mar 2024 22:24:40 +0100 Subject: [PATCH] a bit of clean up --- .../packages/core/action/repository-action.ts | 13 ++---- .../core/entity-action/entity-action.ts | 46 +++++-------------- .../src/packages/core/entity-action/index.ts | 1 + .../src/packages/core/entity-action/types.ts | 5 ++ 4 files changed, 21 insertions(+), 44 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/packages/core/entity-action/types.ts diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/action/repository-action.ts b/src/Umbraco.Web.UI.Client/src/packages/core/action/repository-action.ts index da6edddeab..ab3346f9c8 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/action/repository-action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/action/repository-action.ts @@ -1,16 +1,9 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; -import { type UmbApi, UmbExtensionApiInitializer } from '@umbraco-cms/backoffice/extension-api'; -import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; +import type { UmbApi } from '@umbraco-cms/backoffice/extension-api'; -export class UmbActionBase extends UmbControllerBase implements UmbApi { - repository?: RepositoryType; - - constructor(host: UmbControllerHost, repositoryAlias: string) { +export abstract class UmbActionBase extends UmbControllerBase implements UmbApi { + constructor(host: UmbControllerHost) { super(host); - - new UmbExtensionApiInitializer(this, umbExtensionsRegistry, repositoryAlias, [this._host], (permitted, ctrl) => { - this.repository = permitted ? (ctrl.api as RepositoryType) : undefined; - }); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/entity-action.ts b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/entity-action.ts index b3001ee0a2..62b3b3ac6c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/entity-action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/entity-action.ts @@ -1,20 +1,12 @@ -import type { UmbAction } from '../action/index.js'; -import { UmbActionBase } from '../action/index.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; /** * Interface for an entity action. * @export - * @interface UmbEntityAction - * @extends {UmbAction} - * @template RepositoryType + * @interface UmbEntityAction */ -export interface UmbEntityAction extends UmbAction { - /** - * The unique identifier of the entity. - * @type {string} - */ - unique: string; +export interface UmbEntityAction { + args: UmbEntityActionArgs; /** * The href location, the action will act as a link. @@ -33,32 +25,18 @@ export interface UmbEntityAction extends UmbAction - * @extends {UmbActionBase} - * @implements {UmbEntityAction} + * @class UmbEntityActionBase + * @extends {UmbActionBase} + * @implements {UmbEntityAction} * @template RepositoryType */ -export abstract class UmbEntityActionBase - extends UmbActionBase - implements UmbEntityAction -{ - entityType: string; - unique: string; - repositoryAlias: string; +export abstract class UmbEntityActionBase implements UmbEntityAction { + public args: UmbEntityActionArgs; + protected _host: UmbControllerHost; - /** - * Creates an instance of UmbEntityActionBase. - * @param {UmbControllerHost} host - * @param {string} repositoryAlias - * @param {string} unique - * @param {string} entityType - * @memberof UmbEntityActionBase - */ - constructor(host: UmbControllerHost, repositoryAlias: string, unique: string, entityType: string) { - super(host, repositoryAlias); - this.entityType = entityType; - this.unique = unique; - this.repositoryAlias = repositoryAlias; + constructor(host: UmbControllerHost, args: UmbEntityActionArgs) { + this._host = host; + this.args = args; } /** diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/index.ts index 194dedab02..cb588ea9e5 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/index.ts @@ -3,3 +3,4 @@ export * from './entity-action.element.js'; export * from './entity-action.js'; export * from './common/index.js'; export * from './entity-action.event.js'; +export * from './types.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/types.ts b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/types.ts new file mode 100644 index 0000000000..909af23b20 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/types.ts @@ -0,0 +1,5 @@ +export interface UmbEntityActionArgs { + entityType: string; + unique: string | null; + meta: MetaArgsType; +}