additional context name for 'content property context' (#19375)

rename to UmbPropertyTypeBasedPropertyContext
This commit is contained in:
Niels Lyngsø
2025-05-22 21:12:19 +02:00
committed by GitHub
parent 62cedeec13
commit 0442b9e317
6 changed files with 32 additions and 16 deletions

View File

@@ -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';

View File

@@ -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>(
'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<UmbPropertyTypeBasedPropertyContext>(
'UmbContentPropertyContext',
);

View File

@@ -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<UmbPropertyTypeModel['dataType'] | undefined>(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 };

View File

@@ -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<UmbDataTypeDetailModel | undefined>;
#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}>
</umb-property>

View File

@@ -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>('UmbContentPropertyContext');

View File

@@ -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';