From 0442b9e317e062ee24e3f0cda23915e508a5db02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 22 May 2025 21:12:19 +0200 Subject: [PATCH] additional context name for 'content property context' (#19375) rename to UmbPropertyTypeBasedPropertyContext --- .../property-type-based-property/index.ts | 2 ++ .../property-type-based-property.context-token.ts | 14 ++++++++++++++ .../property-type-based-property.context.ts} | 12 +++++++++--- .../property-type-based-property.element.ts | 13 +++++++------ .../content/content-property.context-token.ts | 4 ---- .../src/packages/content/content/index.ts | 3 --- 6 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context-token.ts rename src/Umbraco.Web.UI.Client/src/packages/content/content/{content-property.context.ts => components/property-type-based-property/property-type-based-property.context.ts} (58%) delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context-token.ts diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/index.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/index.ts index 2eac1fce0d..abab62bf9e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/index.ts @@ -1 +1,3 @@ export * from './property-type-based-property.element.js'; +export * from './property-type-based-property.context-token.js'; +export * from './property-type-based-property.context.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context-token.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context-token.ts new file mode 100644 index 0000000000..35fb27fe88 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context-token.ts @@ -0,0 +1,14 @@ +import type { UmbPropertyTypeBasedPropertyContext } from './property-type-based-property.context.js'; +import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; + +export const UMB_PROPERTY_TYPE_BASED_PROPERTY_CONTEXT = new UmbContextToken( + 'UmbPropertyTypeBasedPropertyContext', +); + +/** + * @deprecated Use `UMB_PROPERTY_TYPE_BASED_PROPERTY_CONTEXT` instead. + * This will be removed in v.18 + */ +export const UMB_CONTENT_PROPERTY_CONTEXT = new UmbContextToken( + 'UmbContentPropertyContext', +); diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context.ts similarity index 58% rename from src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context.ts rename to src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context.ts index b5380a0923..e1e101b4b7 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.context.ts @@ -1,18 +1,24 @@ -import { UMB_CONTENT_PROPERTY_CONTEXT } from './content-property.context-token.js'; +import { UMB_PROPERTY_TYPE_BASED_PROPERTY_CONTEXT } from './property-type-based-property.context-token.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; import type { UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type'; -export class UmbContentPropertyContext extends UmbContextBase { +export class UmbPropertyTypeBasedPropertyContext extends UmbContextBase { #dataType = new UmbObjectState(undefined); dataType = this.#dataType.asObservable(); constructor(host: UmbControllerHost) { - super(host, UMB_CONTENT_PROPERTY_CONTEXT); + super(host, UMB_PROPERTY_TYPE_BASED_PROPERTY_CONTEXT); } setDataType(dataType: UmbPropertyTypeModel['dataType'] | undefined) { this.#dataType.setValue(dataType); } } + +/** + * @deprecated Use `UmbPropertyTypeBasedPropertyContext` instead. + * This will be removed in v.18 + */ +export { UmbPropertyTypeBasedPropertyContext as UmbContentPropertyContext }; diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.element.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.element.ts index 37eae27d6f..fea5d1fa32 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/components/property-type-based-property/property-type-based-property.element.ts @@ -1,4 +1,4 @@ -import { UmbContentPropertyContext } from '../../content-property.context.js'; +import { UmbPropertyTypeBasedPropertyContext } from './property-type-based-property.context.js'; import type { UmbPropertyEditorConfig } from '@umbraco-cms/backoffice/property-editor'; import { css, customElement, html, ifDefined, property, state } from '@umbraco-cms/backoffice/external/lit'; import { UmbDataTypeDetailRepository } from '@umbraco-cms/backoffice/data-type'; @@ -57,17 +57,18 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement { private _isUnsupported?: boolean; @state() - private _dataTypeData?: UmbPropertyEditorConfig; + private _dataTypeValues?: UmbPropertyEditorConfig; private _dataTypeDetailRepository = new UmbDataTypeDetailRepository(this); private _dataTypeObserver?: UmbObserverController; - #contentPropertyContext = new UmbContentPropertyContext(this); + #context = new UmbPropertyTypeBasedPropertyContext(this); private async _checkSchemaSupport() { if (!this._ownerEntityType || !this._propertyEditorSchemaAlias) return; if (this._ownerEntityType in UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES) { + // TODO: We should get rid of this system, f your reading this please dont rely on this, we will get rid of it in the future. [NL] this._isUnsupported = UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES[this._ownerEntityType].includes( this._propertyEditorSchemaAlias, ); @@ -83,9 +84,9 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement { await this._dataTypeDetailRepository.byUnique(dataTypeUnique), (dataType) => { const contextValue = dataType ? { unique: dataType.unique } : undefined; - this.#contentPropertyContext.setDataType(contextValue); + this.#context.setDataType(contextValue); - this._dataTypeData = dataType?.values; + this._dataTypeValues = dataType?.values; this._propertyEditorUiAlias = dataType?.editorUiAlias || undefined; this._propertyEditorSchemaAlias = dataType?.editorAlias || undefined; this._checkSchemaSupport(); @@ -127,7 +128,7 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement { .description=${this._property.description ?? undefined} .appearance=${this._property.appearance} property-editor-ui-alias=${ifDefined(this._propertyEditorUiAlias)} - .config=${this._dataTypeData} + .config=${this._dataTypeValues} .validation=${this._property.validation} ?readonly=${this.readonly}> diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context-token.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context-token.ts deleted file mode 100644 index 8e9bf8626a..0000000000 --- a/src/Umbraco.Web.UI.Client/src/packages/content/content/content-property.context-token.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { UmbContentPropertyContext } from './content-property.context.js'; -import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; - -export const UMB_CONTENT_PROPERTY_CONTEXT = new UmbContextToken('UmbContentPropertyContext'); diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/index.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/index.ts index a532e7485e..d9a9888ec0 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/content/content/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/index.ts @@ -1,6 +1,3 @@ -export { UMB_CONTENT_PROPERTY_CONTEXT } from './content-property.context-token.js'; -export { UmbContentPropertyContext } from './content-property.context.js'; - export * from './collection/index.js'; export * from './components/index.js'; export * from './constants.js';