From f537e647b0eae32072b70f95bdb0af8801431d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 2 May 2024 13:21:38 +0200 Subject: [PATCH] rename token and context --- .../entity-actions-bundle.element.ts | 1 + .../entity-is-not-trashed.condition.ts | 4 ++-- .../is-trashed/entity-is-trashed.condition.ts | 4 ++-- .../is-trashed/entity-is-trashed.context-token.ts | 7 ------- .../core/recycle-bin/contexts/is-trashed/index.ts | 4 ++-- .../is-trashed/is-trashed.entity-context-token.ts | 7 +++++++ ...hed.context.ts => is-trashed.entity-context.ts} | 14 +++++++------- .../src/packages/core/recycle-bin/index.ts | 2 +- .../tree/tree-item/document-tree-item.context.ts | 5 +++-- .../workspace/document-workspace.context.ts | 4 ++-- .../tree/tree-item/media-tree-item.context.ts | 4 ++-- .../media/workspace/media-workspace.context.ts | 4 ++-- 12 files changed, 31 insertions(+), 29 deletions(-) delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context-token.ts create mode 100644 src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context-token.ts rename src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/{entity-is-trashed.context.ts => is-trashed.entity-context.ts} (63%) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts index 71090ba875..44e39874ad 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts @@ -31,6 +31,7 @@ export class UmbEntityActionsBundleElement extends UmbLitElement { #sectionSidebarContext?: UmbSectionSidebarContext; + // TODO: provide the entity context on a higher level, like the root element of this entity, tree-item/workspace/... [NL] #entityContext = new UmbEntityContext(this); constructor() { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-not-trashed/entity-is-not-trashed.condition.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-not-trashed/entity-is-not-trashed.condition.ts index 9911a42daf..56dce88cdf 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-not-trashed/entity-is-not-trashed.condition.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-not-trashed/entity-is-not-trashed.condition.ts @@ -1,4 +1,4 @@ -import { UMB_ENTITY_IS_TRASHED_CONTEXT } from '../../contexts/is-trashed/index.js'; +import { UMB_IS_TRASHED_ENTITY_CONTEXT } from '../../contexts/is-trashed/index.js'; import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { @@ -18,7 +18,7 @@ export class UmbEntityIsNotTrashedCondition // and therefore the condition is permitted this.permitted = true; - this.consumeContext(UMB_ENTITY_IS_TRASHED_CONTEXT, (context) => { + this.consumeContext(UMB_IS_TRASHED_ENTITY_CONTEXT, (context) => { this.observe(context.isTrashed, (isTrashed) => { this.permitted = isTrashed === false; }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-trashed/entity-is-trashed.condition.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-trashed/entity-is-trashed.condition.ts index 1c62dc2852..0c098771a2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-trashed/entity-is-trashed.condition.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/conditions/is-trashed/entity-is-trashed.condition.ts @@ -1,4 +1,4 @@ -import { UMB_ENTITY_IS_TRASHED_CONTEXT } from '../../contexts/is-trashed/index.js'; +import { UMB_IS_TRASHED_ENTITY_CONTEXT } from '../../contexts/is-trashed/index.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { UmbConditionConfigBase, @@ -11,7 +11,7 @@ export class UmbIsTrashedCondition extends UmbConditionBase) { super(host, args); - this.consumeContext(UMB_ENTITY_IS_TRASHED_CONTEXT, (context) => { + this.consumeContext(UMB_IS_TRASHED_ENTITY_CONTEXT, (context) => { this.observe(context.isTrashed, (isTrashed) => { this.permitted = isTrashed === true; }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context-token.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context-token.ts deleted file mode 100644 index fee62ff802..0000000000 --- a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context-token.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { UmbEntityIsTrashedContext } from './entity-is-trashed.context.js'; -import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; - -export const UMB_ENTITY_IS_TRASHED_CONTEXT = new UmbContextToken( - 'UmbEntityContext', - 'isTrashed', -); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/index.ts index 18e16130d9..fd31808557 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/index.ts @@ -1,2 +1,2 @@ -export { UmbEntityIsTrashedContext } from './entity-is-trashed.context.js'; -export { UMB_ENTITY_IS_TRASHED_CONTEXT } from './entity-is-trashed.context-token.js'; +export { UmbIsTrashedEntityContext } from './is-trashed.entity-context.js'; +export { UMB_IS_TRASHED_ENTITY_CONTEXT } from './is-trashed.entity-context-token.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context-token.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context-token.ts new file mode 100644 index 0000000000..ae4b9482c8 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context-token.ts @@ -0,0 +1,7 @@ +import type { UmbIsTrashedEntityContext } from './is-trashed.entity-context.js'; +import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; + +export const UMB_IS_TRASHED_ENTITY_CONTEXT = new UmbContextToken( + 'UmbEntityContext', + 'isTrashed', +); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context.ts similarity index 63% rename from src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context.ts rename to src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context.ts index 740c62cdc2..b80ed8301f 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/entity-is-trashed.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/contexts/is-trashed/is-trashed.entity-context.ts @@ -1,21 +1,21 @@ -import { UMB_ENTITY_IS_TRASHED_CONTEXT } from './entity-is-trashed.context-token.js'; +import { UMB_IS_TRASHED_ENTITY_CONTEXT } from './is-trashed.entity-context-token.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api'; /** - * Represents the context for the isTrashed state + * A entity context for the isTrashed state. * @export - * @class UmbIsTrashedContext - * @extends {UmbContextBase} - * @implements {UmbEntityIsTrashedContext} + * @class UmbIsTrashedEntityContext + * @extends {UmbContextBase} + * @implements {UmbIsTrashedEntityContext} */ -export class UmbEntityIsTrashedContext extends UmbContextBase { +export class UmbIsTrashedEntityContext extends UmbContextBase { #isTrashed = new UmbBooleanState(false); isTrashed = this.#isTrashed.asObservable(); constructor(host: UmbControllerHost) { - super(host, UMB_ENTITY_IS_TRASHED_CONTEXT); + super(host, UMB_IS_TRASHED_ENTITY_CONTEXT); } /** diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/index.ts b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/index.ts index 1760df1229..a43b594005 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/recycle-bin/index.ts @@ -13,6 +13,6 @@ export type { UmbRecycleBinOriginalParentRequestArgs, } from './types.js'; -export { UmbEntityIsTrashedContext, UMB_ENTITY_IS_TRASHED_CONTEXT } from './contexts/is-trashed/index.js'; +export { UmbIsTrashedEntityContext, UMB_IS_TRASHED_ENTITY_CONTEXT } from './contexts/is-trashed/index.js'; export { UMB_ENTITY_IS_NOT_TRASHED_CONDITION_ALIAS } from './conditions/is-not-trashed/constants.js'; export { UMB_ENTITY_IS_TRASHED_CONDITION_ALIAS } from './conditions/is-trashed/constants.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/tree/tree-item/document-tree-item.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/tree/tree-item/document-tree-item.context.ts index 9bd0d67e57..52621ece9a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/tree/tree-item/document-tree-item.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/tree/tree-item/document-tree-item.context.ts @@ -1,10 +1,11 @@ import type { UmbDocumentTreeItemModel } from '../types.js'; import { UmbDefaultTreeItemContext } from '@umbraco-cms/backoffice/tree'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; -import { UmbEntityIsTrashedContext } from '@umbraco-cms/backoffice/recycle-bin'; +import { UmbIsTrashedEntityContext } from '@umbraco-cms/backoffice/recycle-bin'; export class UmbDocumentTreeItemContext extends UmbDefaultTreeItemContext { - #isTrashedContext = new UmbEntityIsTrashedContext(this); + // TODO: Provide this together with the EntityContext, ideally this takes part via a extension-type [NL] + #isTrashedContext = new UmbIsTrashedEntityContext(this); constructor(host: UmbControllerHost) { super(host); diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts index c7b06607e7..a496a3a08e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts @@ -58,7 +58,7 @@ import { UmbDocumentBlueprintDetailRepository } from '@umbraco-cms/backoffice/do import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'; import type { UmbContentWorkspaceContext } from '@umbraco-cms/backoffice/content'; import type { UmbDocumentTypeDetailModel } from '@umbraco-cms/backoffice/document-type'; -import { UmbEntityIsTrashedContext } from '@umbraco-cms/backoffice/recycle-bin'; +import { UmbIsTrashedEntityContext } from '@umbraco-cms/backoffice/recycle-bin'; type EntityType = UmbDocumentDetailModel; export class UmbDocumentWorkspaceContext @@ -157,7 +157,7 @@ export class UmbDocumentWorkspaceContext // TODO: this should be set up for all entity workspace contexts in a base class #entityContext = new UmbEntityContext(this); // TODO: this might not be the correct place to spin this up - #isTrashedContext = new UmbEntityIsTrashedContext(this); + #isTrashedContext = new UmbIsTrashedEntityContext(this); constructor(host: UmbControllerHost) { super(host, UMB_DOCUMENT_WORKSPACE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/tree/tree-item/media-tree-item.context.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/tree/tree-item/media-tree-item.context.ts index 5df9fa848a..114805613a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/media/media/tree/tree-item/media-tree-item.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/tree/tree-item/media-tree-item.context.ts @@ -1,10 +1,10 @@ import type { UmbMediaTreeItemModel } from '../types.js'; import { UmbDefaultTreeItemContext } from '@umbraco-cms/backoffice/tree'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; -import { UmbEntityIsTrashedContext } from '@umbraco-cms/backoffice/recycle-bin'; +import { UmbIsTrashedEntityContext } from '@umbraco-cms/backoffice/recycle-bin'; export class UmbMediaTreeItemContext extends UmbDefaultTreeItemContext { - #isTrashedContext = new UmbEntityIsTrashedContext(this); + #isTrashedContext = new UmbIsTrashedEntityContext(this); constructor(host: UmbControllerHost) { super(host); diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts index 1b4201e3f8..8ea7e656cf 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/workspace/media-workspace.context.ts @@ -26,7 +26,7 @@ import { UmbRequestReloadStructureForEntityEvent } from '@umbraco-cms/backoffice import type { UmbMediaTypeDetailModel } from '@umbraco-cms/backoffice/media-type'; import type { UmbContentWorkspaceContext } from '@umbraco-cms/backoffice/content'; import { UmbEntityContext } from '@umbraco-cms/backoffice/entity'; -import { UmbEntityIsTrashedContext } from '@umbraco-cms/backoffice/recycle-bin'; +import { UmbIsTrashedEntityContext } from '@umbraco-cms/backoffice/recycle-bin'; type EntityType = UmbMediaDetailModel; export class UmbMediaWorkspaceContext @@ -112,7 +112,7 @@ export class UmbMediaWorkspaceContext // TODO: this should be set up for all entity workspace contexts in a base class #entityContext = new UmbEntityContext(this); // TODO: this might not be the correct place to spin this up - #isTrashedContext = new UmbEntityIsTrashedContext(this); + #isTrashedContext = new UmbIsTrashedEntityContext(this); constructor(host: UmbControllerHost) { super(host, 'Umb.Workspace.Media');