Skip to content

Commit b2c598f

Browse files
loivseniOvergaard
authored andcommitted
Feature: Unsupported properties
1 parent a5500fd commit b2c598f

File tree

8 files changed

+97
-0
lines changed

8 files changed

+97
-0
lines changed

src/packages/block/block/workspace/views/edit/block-workspace-view-edit-properties.element.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ export class UmbBlockWorkspaceViewEditPropertiesElement extends UmbLitElement {
3535
@state()
3636
_dataPaths?: Array<string>;
3737

38+
@state()
39+
private _ownerEntityType?: string;
40+
3841
constructor() {
3942
super();
4043

4144
this.consumeContext(UMB_BLOCK_WORKSPACE_CONTEXT, (workspaceContext) => {
4245
this.#blockWorkspace = workspaceContext;
46+
this._ownerEntityType = this.#blockWorkspace.getEntityType();
4347
this.#setStructureManager();
4448
});
4549
}
@@ -70,6 +74,7 @@ export class UmbBlockWorkspaceViewEditPropertiesElement extends UmbLitElement {
7074
html`<umb-property-type-based-property
7175
class="property"
7276
data-path=${this._dataPaths![index]}
77+
.ownerEntityType=${this._ownerEntityType}
7378
.property=${property}
7479
${umbDestroyOnDisconnect()}></umb-property-type-based-property>`,
7580
);

src/packages/core/content-type/components/property-type-based-property/property-type-based-property.element.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
88
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
99
import type { UmbDataTypeDetailModel } from '@umbraco-cms/backoffice/data-type';
1010
import type { UmbObserverController } from '@umbraco-cms/backoffice/observable-api';
11+
import { UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES } from '@umbraco-cms/backoffice/property';
1112

1213
@customElement('umb-property-type-based-property')
1314
export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
@@ -27,9 +28,26 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
2728
@property({ type: String, attribute: 'data-path' })
2829
public dataPath?: string;
2930

31+
@property({ type: String })
32+
public get ownerEntityType(): string | undefined {
33+
return this._ownerEntityType;
34+
}
35+
public set ownerEntityType(value: string | undefined) {
36+
// Change this to ownerSchemaEditorAlias and retrieve the correct information.
37+
this._ownerEntityType = value;
38+
}
39+
40+
private _ownerEntityType?: string;
41+
3042
@state()
3143
private _propertyEditorUiAlias?: string;
3244

45+
@state()
46+
private _propertyEditorSchemaAlias?: string;
47+
48+
@state()
49+
private _isUnsupported?: boolean;
50+
3351
@state()
3452
private _dataTypeData?: UmbPropertyEditorConfig;
3553

@@ -38,6 +56,16 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
3856

3957
#contentPropertyContext = new UmbContentPropertyContext(this);
4058

59+
private async _checkSchemaSupport() {
60+
if (!this._ownerEntityType || !this._propertyEditorSchemaAlias) return;
61+
62+
if (this._ownerEntityType in UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES) {
63+
this._isUnsupported = UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES[this._ownerEntityType].includes(
64+
this._propertyEditorSchemaAlias,
65+
);
66+
}
67+
}
68+
4169
private async _observeDataType(dataTypeUnique?: string) {
4270
this._dataTypeObserver?.destroy();
4371
if (dataTypeUnique) {
@@ -51,6 +79,9 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
5179

5280
this._dataTypeData = dataType?.values;
5381
this._propertyEditorUiAlias = dataType?.editorUiAlias || undefined;
82+
this._propertyEditorSchemaAlias = dataType?.editorAlias || undefined;
83+
this._checkSchemaSupport();
84+
5485
// If there is no UI, we will look up the Property editor model to find the default UI alias:
5586
if (!this._propertyEditorUiAlias && dataType?.editorAlias) {
5687
//use 'dataType.editorAlias' to look up the extension in the registry:
@@ -75,6 +106,12 @@ export class UmbPropertyTypeBasedPropertyElement extends UmbLitElement {
75106

76107
override render() {
77108
if (!this._propertyEditorUiAlias || !this._property?.alias) return;
109+
if (this._isUnsupported) {
110+
return html`<umb-unsupported-property
111+
.alias=${this._property.alias}
112+
.ownerEntityType=${this._ownerEntityType}
113+
.schema=${this._propertyEditorSchemaAlias!}></umb-unsupported-property>`;
114+
}
78115
return html`
79116
<umb-property
80117
.dataPath=${this.dataPath}

src/packages/core/property/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './property-dataset/index.js';
33
export * from './property-layout/index.js';
44
export * from './property/index.js';
55
export * from './types/index.js';
6+
export * from './unsupported-property/index.js';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './property-value-data.type.js';
2+
export * from './unsupported-properties.type.js';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type UmbUnsupportedEditorSchemaAliases = Record<string, Array<string>>;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './utils.js';
2+
export * from './unsupported-property.element.js';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { css, customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
2+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
3+
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
4+
5+
/**
6+
* @description Component for displaying an unsupported property
7+
*/
8+
9+
@customElement('umb-unsupported-property')
10+
export class UmbUnsupportedPropertyElement extends UmbLitElement {
11+
@property({ type: String })
12+
public alias = '';
13+
14+
@property({ type: String })
15+
public schema = '';
16+
17+
override render() {
18+
return html`<div id="not-supported">
19+
<umb-localize key="blockEditor_propertyEditorNotSupported" .args=${[this.alias, this.schema]}></umb-localize>
20+
</div>`;
21+
}
22+
23+
static override styles = [
24+
UmbTextStyles,
25+
css`
26+
:host {
27+
display: block;
28+
padding: var(--uui-size-layout-1) 0;
29+
}
30+
31+
#not-supported {
32+
background-color: var(--uui-color-danger);
33+
color: var(--uui-color-surface);
34+
padding: var(--uui-size-space-4);
35+
border-radius: var(--uui-border-radius);
36+
}
37+
`,
38+
];
39+
}
40+
41+
declare global {
42+
interface HTMLElementTagNameMap {
43+
'umb-unsupported-property': UmbUnsupportedPropertyElement;
44+
}
45+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { UmbUnsupportedEditorSchemaAliases } from '../types/index.js';
2+
3+
export const UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES: UmbUnsupportedEditorSchemaAliases = {
4+
block: ['Umbraco.ImageCropper', 'Umbraco.UploadField'],
5+
};

0 commit comments

Comments
 (0)