Skip to content

Allow configuring collection no-items text via manifest or attribute#19284

Merged
nielslyngsoe merged 4 commits intorelease/16.0from
v16/hotfix/configure-empty-collection-text
May 9, 2025
Merged

Allow configuring collection no-items text via manifest or attribute#19284
nielslyngsoe merged 4 commits intorelease/16.0from
v16/hotfix/configure-empty-collection-text

Conversation

@nathanwoulfe
Copy link
Contributor

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:

  • edit /src/packages/members/member-group/collection/manifests.ts
    • add noItemsLabel: 'Custom text' to the meta property
  • verify the member group collection displays 'Custom text' in the empty state,
  • edit the manifest again
    • update noItemsLabel to #general_delete
  • verify the member group collection displays the localized text in the empty state

To test via config:

  • edit /src/packages/dictionary/dashboard/dictionary-overview-dashboard-element.ts
    • add a config attribute to the umb-collection element: .config=${{ noItemsLabel: 'Custom text'}}
  • verify the dictionary/translation section dashboard displays 'Custom text' in the empty state
  • edit the element again
    • update noItemsLabel to #general_delete
  • verify the dictionary/translation section dashboard displays the localized text in the empty state

If both the manifest and element config set the noItemsLabel property, the manifest value is prioritised. If neither is set, we fallback to the original No items text, via the collection_noItemsTitle localization key.

Copilot AI review requested due to automatic review settings May 8, 2025 23:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ??

@nathanwoulfe nathanwoulfe requested a review from Copilot May 8, 2025 23:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nielslyngsoe nielslyngsoe enabled auto-merge (squash) May 9, 2025 07:22
@nielslyngsoe nielslyngsoe merged commit 1fc8b4f into release/16.0 May 9, 2025
23 checks passed
@nielslyngsoe nielslyngsoe deleted the v16/hotfix/configure-empty-collection-text branch May 9, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments