From 34d28e7d4f2792697393b9ac0727fa47997daf7c Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Feb 2023 20:45:32 +0100 Subject: [PATCH] pass unique to api --- .../workspace/entity-action.element.ts | 24 +++++++++++++++++-- .../workspace-action-menu.element.ts | 7 +++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/entity-action.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/entity-action.element.ts index 16d72680a9..c08b1b8b6a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/entity-action.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/entity-action.element.ts @@ -6,9 +6,24 @@ import { ManifestEntityAction } from 'libs/extensions-registry/entity-action.mod @customElement('umb-entity-action') class UmbEntityActionElement extends UmbLitElement { + private _unique?: string; + @property({ type: String }) + public get unique() { + return this._unique; + } + public set unique(value: string | undefined) { + if (!value) return; + const oldValue = this._unique; + this._unique = value; + if (oldValue !== this._unique) { + this.#createApi(); + this.requestUpdate('unique', oldValue); + } + } + private _manifest?: ManifestEntityAction; @property({ type: Object, attribute: false }) - public get entityType() { + public get manifest() { return this._manifest; } public set manifest(value: ManifestEntityAction | undefined) { @@ -16,11 +31,16 @@ class UmbEntityActionElement extends UmbLitElement { const oldValue = this._manifest; this._manifest = value; if (oldValue !== this._manifest) { - this.#api = new this._manifest.meta.api(this); + this.#createApi(); this.requestUpdate('manifest', oldValue); } } + #createApi() { + if (!this._manifest?.meta.api) return; + this.#api = new this._manifest.meta.api(this, this.unique); + } + #api: any; async #onClickLabel() { diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-action-menu/workspace-action-menu.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-action-menu/workspace-action-menu.element.ts index 3880305334..8963af3d1b 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-action-menu/workspace-action-menu.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-action-menu/workspace-action-menu.element.ts @@ -28,6 +28,9 @@ export class UmbWorkspaceActionMenuElement extends UmbLitElement { `, ]; + @property({ type: String }) + public unique?: string; + private _entityType = ''; @property({ type: String, attribute: 'entity-type' }) public get entityType() { @@ -73,7 +76,9 @@ export class UmbWorkspaceActionMenuElement extends UmbLitElement {
- ${this._entityActions?.map((manifest) => html``)} + ${this._entityActions?.map( + (manifest) => html`` + )}