diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.context.ts index c3c997d5e0..a6928e0afe 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.context.ts @@ -14,8 +14,8 @@ const DefaultDocumentTypeData = ({ export class UmbWorkspaceDocumentTypeContext extends UmbWorkspaceNodeContext { - constructor(target:HTMLElement, entityType: string, entityKey: string) { - super(target, DefaultDocumentTypeData, 'umbDocumentTypeStore', entityType, entityKey); + constructor(target:HTMLElement, entityKey: string) { + super(target, DefaultDocumentTypeData, 'umbDocumentTypeStore', entityKey); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.element.ts index f3bb55e6b7..70c4e2a558 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document-type/workspace-document-type.element.ts @@ -88,7 +88,7 @@ export class UmbWorkspaceDocumentTypeElement extends UmbContextProviderMixin( protected _provideWorkspace() { if(this._entityType && this._entityKey) { - this._workspaceContext = new UmbWorkspaceDocumentTypeContext(this, this._entityType, this._entityKey); + this._workspaceContext = new UmbWorkspaceDocumentTypeContext(this, this._entityKey); this.provideContext('umbWorkspaceContext', this._workspaceContext); this._observeWorkspace() } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.context.ts index 21f5bef967..327cb5a82c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.context.ts @@ -33,8 +33,8 @@ const DefaultDocumentData = ({ export class UmbWorkspaceDocumentContext extends UmbWorkspaceNodeContext { - constructor(target:HTMLElement, entityType: string, entityKey: string) { - super(target, DefaultDocumentData, 'umbDocumentStore', entityType, entityKey); + constructor(target:HTMLElement, entityKey: string) { + super(target, DefaultDocumentData, 'umbDocumentStore', entityKey); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.element.ts index 8bdbe0de43..cfda1092d1 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/document/workspace-document.element.ts @@ -68,7 +68,7 @@ export class UmbWorkspaceDocumentElement extends UmbObserverMixin(UmbContextCons protected _provideWorkspace() { if(this._entityType && this._entityKey) { - this._workspaceContext = new UmbWorkspaceDocumentContext(this, this._entityType, this._entityKey); + this._workspaceContext = new UmbWorkspaceDocumentContext(this, this._entityKey); this.provideContext('umbWorkspaceContext', this._workspaceContext); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-node.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-node.context.ts index c859962810..763890e2ed 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-node.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace-context/workspace-node.context.ts @@ -1,13 +1,37 @@ import { UmbWorkspaceWithStoreContext } from "./workspace-with-store.context"; import { UmbNodeStoreBase } from "@umbraco-cms/stores/store"; -import { UmbNotificationDefaultData } from "@umbraco-cms/services"; +import { UmbNotificationDefaultData, UmbNotificationService } from "@umbraco-cms/services"; import { ContentTreeItem } from "@umbraco-cms/backend-api"; +import { UmbContextConsumer } from "@umbraco-cms/context-api"; +// TODO: Consider if its right to have this many WorkspaceContext export class UmbWorkspaceNodeContext> extends UmbWorkspaceWithStoreContext { - constructor(target:HTMLElement, defaultData:ContentTypeType, storeAlias:string, entityType: string, entityKey: string) { - super(target, defaultData, storeAlias, entityType, entityKey); + protected _notificationService?: UmbNotificationService; + protected _notificationConsumer!:UmbContextConsumer; + + public entityKey:string; + + constructor(target:HTMLElement, defaultData:ContentTypeType, storeAlias:string, entityKey: string) { + super(target, defaultData, storeAlias); + + this._notificationConsumer = new UmbContextConsumer(this._target, 'umbNotificationService', (_instance: UmbNotificationService) => { + this._notificationService = _instance; + }); + + this.entityKey = entityKey; + } + + + connectedCallback() { + super.connectedCallback(); + this._notificationConsumer.attach(); + } + + disconnectedCallback() { + super.connectedCallback(); + this._notificationConsumer.detach(); } @@ -29,8 +53,6 @@ export class UmbWorkspaceNodeContext> extends UmbWorkspaceContext { - protected _notificationConsumer!:UmbContextConsumer; - protected _notificationService?: UmbNotificationService; protected _storeConsumer!:UmbContextConsumer; protected _store!: StoreType; // TODO: Double check its right to assume it here, at least from a type perspective? protected _dataObserver?:Subscription; - public entityType:string; - public entityKey:string; - - constructor(target:HTMLElement, defaultData:DataType, storeAlias:string, entityType: string, entityKey: string) { + constructor(target:HTMLElement, defaultData:DataType, storeAlias:string) { super(target, defaultData) - this.entityType = entityType; - this.entityKey = entityKey; - - this._notificationConsumer = new UmbContextConsumer(this._target, 'umbNotificationService', (_instance: UmbNotificationService) => { - this._notificationService = _instance; - }); // TODO: consider if store alias should be configurable of manifest: this._storeConsumer = new UmbContextConsumer(this._target, storeAlias, (_instance: StoreType) => { @@ -41,12 +29,10 @@ export abstract class UmbWorkspaceWithStoreContext