Property editors: Add configuration and validation of allowed types for element picker, document picker, media picker - #23026
Conversation
|
Claude finished @NguyenThuyLan's task in 6m 43s —— View job PR ReviewTarget: Adds an "Allow items of type" configuration option to the Element Picker property editor, restricting which element types can be selected. Touches the C# value editor (new
Critical
Important
Suggestions
Request ChangesThe Critical issue (value converter not updated) must be addressed — it causes a complete regression for anyone using the Element Picker in templates or the Delivery API after this PR ships. The data migration concern is also worth resolving before merging since this is a release candidate. The feature itself is well-structured: the backend validator, configuration model, and frontend components are cleanly implemented, and the unit tests cover the key scenarios. |
…8/feature/element-picker-configuration-allowed-types
… of https://github.com/umbraco/Umbraco-CMS into v18/feature/element-picker-configuration-allowed-types
|
Claude finished @NguyenThuyLan's task in 5m 17s —— View job Claude finished @NguyenThuyLan's task in 6m 43s —— View job PR ReviewTarget: Adds "Allow items of type" configuration to the Element Picker property editor: a backend
Important
Suggestions
Approved with Suggestions for improvementThe previous Critical issue (value converter regression) has been resolved, and the overall structure is clean. Please address the dead parameter and review the silent-bypass behaviour before merging. |
…8/feature/element-picker-configuration-allowed-types
AndyButland
left a comment
There was a problem hiding this comment.
I had a quick look over @NguyenThuyLan. I haven't tested as I wanted to give you some feedback that you'd have in the morning. Looks great so far, but I found a few things to suggest inline.
Don't forget also that we discussed on the Azure board story that we wanted to align the document picker with this and the media picker for validation. It's also missing the ability to select allowed types, so we should introduce that. And I think it makes sense to do so in this PR, so we can see it's all aligned and guarantee that it's released together (in C# the document picker is called ``ContentPickerPropertyEditor(with nestedContentPickerPropertyValueEditor`).
In the end we'd like to get the document, media and element picker all as aligned as we can in terms of features, validation and how they are handled client and server-side.
There was a problem hiding this comment.
Pull request overview
This PR introduces an “accepted/allowed content types” configuration for picker-style property editors—most notably the Element Picker—so editors can restrict which element types may be selected, with corresponding server-side validation to enforce the restriction.
Changes:
- Adds an “Accepted types” configuration UI for the Element Picker (and Document Picker), and wires the allowed-type IDs through to client-side pickers for filtering pickable tree items.
- Adds server-side allowed-type validation for Element Picker and Content Picker, plus a shared
AllowedContentTypeKeysParserhelper. - Refactors validation infrastructure by introducing
ITypedValidatorandTypedValidatorRunner, and improves Media Picker validation to fail when referenced media no longer exists.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MediaPicker3ValueEditorValidationTests.cs | Adds unit coverage for missing-media validation when allowed-type filtering is configured. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ElementPickerPropertyEditorValidationTests.cs | New tests covering allowed-type validation behavior for Element Picker. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ElementPickerPropertyEditorMinMaxValidationTests.cs | New tests covering min/max validation behavior for Element Picker. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ContentPickerPropertyEditorValidationTests.cs | New tests covering allowed-type validation behavior for Content Picker. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/AllowedContentTypeKeysParserTests.cs | New tests for parsing comma-separated content-type GUIDs. |
| src/Umbraco.Web.UI.Client/src/packages/property-editors/content-picker/manifests.ts | Updates config label/description copy for the content picker “filter” setting. |
| src/Umbraco.Web.UI.Client/src/packages/elements/property-editor/element-picker/Umbraco.ElementPicker.ts | Adjusts config UI weights (ordering). |
| src/Umbraco.Web.UI.Client/src/packages/elements/property-editor/element-picker/manifests.ts | Adds “Accepted types” config property and registers the new config UI manifest. |
| src/Umbraco.Web.UI.Client/src/packages/elements/property-editor/element-picker/element-picker-property-editor-ui.element.ts | Reads allowedContentTypes config and forwards allowed IDs to the input component. |
| src/Umbraco.Web.UI.Client/src/packages/elements/property-editor/element-picker/config/allowed-element-types/property-editor-ui-element-picker-allowed-element-types.element.ts | New config UI element for selecting allowed element types. |
| src/Umbraco.Web.UI.Client/src/packages/elements/property-editor/element-picker/config/allowed-element-types/manifests.ts | New manifest registering the Element Picker allowed-types config UI. |
| src/Umbraco.Web.UI.Client/src/packages/elements/picker-data-source/element-tree.picker-data-source.ts | Adds pickable filtering by allowed content type IDs for element tree items. |
| src/Umbraco.Web.UI.Client/src/packages/elements/global-components/input-element.element.ts | Plumbs allowed content type IDs into the element picker data source config. |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/property-editors/document-picker/Umbraco.ContentPicker.ts | Adds missing weight to “Ignore user start nodes” config UI. |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/property-editors/document-picker/property-editor-ui-document-picker.element.ts | Reads allowedContentTypes config and forwards allowed IDs to <umb-input-document>. |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/property-editors/document-picker/manifests.ts | Adds “Accepted types” config property and registers allowed-types config UI manifest. |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/property-editors/document-picker/allowed-document-types/property-editor-ui-document-picker-allowed-document-types.element.ts | New config UI element for selecting allowed document types. |
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/property-editors/document-picker/allowed-document-types/manifests.ts | New manifest registering the Document Picker allowed-types config UI. |
| src/Umbraco.Infrastructure/Serialization/SystemTextJsonSerializerBase.cs | Removes unused usings / minor formatting cleanup. |
| src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs | Switches validator interface from ITypedJsonValidator to ITypedValidator. |
| src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs | Switches validator interfaces from ITypedJsonValidator to ITypedValidator. |
| src/Umbraco.Infrastructure/PropertyEditors/MediaPicker3PropertyEditor.cs | Switches validator interfaces and adds missing-media validation when resolving media types by lookup. |
| src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditorBase.cs | Switches validator interface from ITypedJsonValidator to ITypedValidator. |
| src/Umbraco.Core/PropertyEditors/Validation/TypedValidatorRunner.cs | New runner for already-typed editor values (casts once, runs multiple typed validators). |
| src/Umbraco.Core/PropertyEditors/Validation/TypedJsonValidatorRunner.cs | Updates docs, switches to ITypedValidator, adds obsolete compatibility constructor. |
| src/Umbraco.Core/PropertyEditors/Validation/ITypedValidator.cs | New typed validator interface (non-JSON-specific). |
| src/Umbraco.Core/PropertyEditors/Validation/ITypedJsonValidator.cs | Obsoletes old interface in favor of ITypedValidator. |
| src/Umbraco.Core/PropertyEditors/EntityDataPickerPropertyEditor.cs | Switches validator interface from ITypedJsonValidator to ITypedValidator. |
| src/Umbraco.Core/PropertyEditors/ElementPickerPropertyEditor.cs | Adds typed validation runner + min/max + allowed-type validators for Element Picker. |
| src/Umbraco.Core/PropertyEditors/ElementPickerConfiguration.cs | Adds validation limit + allowed content types configuration fields. |
| src/Umbraco.Core/PropertyEditors/ContentPickerPropertyEditor.cs | Adds allowed-type validation for Content Picker using typed validator runner. |
| src/Umbraco.Core/PropertyEditors/ContentPickerConfiguration.cs | Adds allowed content types configuration field. |
| src/Umbraco.Core/PropertyEditors/AllowedContentTypeKeysParser.cs | New helper to parse comma-separated GUID config values. |
| src/Umbraco.Core/EmbeddedResources/Lang/en.xml | Adds validation/missingMedia localization key. |
|



Prerequisites
(Element Picker: Add setting "Allow items of type" #22851)
Description
Adds an "Allow items of type" configuration option to the Element Picker, Document Picker property editor, allowing editors to restrict which element types can be selected.
How to test