Allow configuring collection no-items text via manifest or attribute#19284
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enables custom configuration of the no-items text in a collection by allowing the label to be set via the collection manifest or an element's configuration.
- Added an optional noItemsLabel property to both the collection configuration and manifest meta interfaces.
- Updated the default collection element to dynamically generate the empty state label from the manifest, config, or fallback localization key.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/packages/core/collection/types.ts | Added the optional noItemsLabel property to the collection configuration interface. |
| src/Umbraco.Web.UI.Client/src/packages/core/collection/extensions/collection.extension.ts | Extended the manifest meta interface by adding an optional noItemsLabel property. |
| src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.element.ts | Introduced a helper method to determine the empty state label using manifest, config, or fallback localization. |
Comments suppressed due to low confidence (1)
src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.element.ts:73
- [nitpick] Consider checking if the noItemsLabel value starts with '#' to determine whether it should be interpreted as a localization key. If not, returning the provided custom text directly instead of passing it to this.localize.string could prevent unnecessary localization lookups.
const labelKey = this.#collectionContext?.manifest?.meta.noItemsLabel ??
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the ability to configure custom "no-items" text for collections using either the extension manifest or a configuration attribute, with the manifest value taking precedence over the configuration if both are provided. Key changes include:
- Adding a new noItemsLabel property to the collection configuration interface.
- Extending the manifest's metadata to include noItemsLabel.
- Implementing and using a helper method to determine and render the appropriate empty state label.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/packages/core/collection/types.ts | Added noItemsLabel property to the collection configuration interface. |
| src/Umbraco.Web.UI.Client/src/packages/core/collection/extensions/collection.extension.ts | Added noItemsLabel to the manifest metadata type. |
| src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.element.ts | Introduced a helper method to generate the empty state label based on manifest or config, and updated the render method accordingly. |
This PR introduces the ability to provide custom text for the no-items message in a collection, either via the collection extension manifest or collection configuration object.
To test via manifest:
/src/packages/members/member-group/collection/manifests.tsnoItemsLabel: 'Custom text'to themetapropertynoItemsLabelto#general_deleteTo test via config:
/src/packages/dictionary/dashboard/dictionary-overview-dashboard-element.tsumb-collectionelement:.config=${{ noItemsLabel: 'Custom text'}}noItemsLabelto#general_deleteIf both the manifest and element config set the
noItemsLabelproperty, the manifest value is prioritised. If neither is set, we fallback to the originalNo itemstext, via thecollection_noItemsTitlelocalization key.