Overview

#3548322: Improve how list of field suggestions is displayed in the UI for `ContentTemplates` and remove `ContentTemplates` from feature flag got in which presents a list of field suggestions to the user. But maybe there are some suggestions that we don't need to show to the user as an option to link to a prop such as "Revision log message".

Proposed resolution

Always omit from shape matching:

  • Node entity type => promote
  • Node entity type => sticky
  • File entity type => User ID
  • Generic:
    1. revision_log_message
    2. revision_default
    3. default_langcode

IOW: update the shape matching heuristics.

User interface changes

No more irrelevant suggestions when building content templates:

type: boolean

Before
After

type: string, format: uri-reference

Before
After

Issue fork canvas-3551339

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hooroomoo created an issue. See original summary.

hooroomoo’s picture

Issue summary: View changes
wim leers’s picture

Title: Consider removing some suggestions as a possible DynamicPropSource to show in the `ContentTemplates` UI » Triage shape-matched DynamicPropSources: remove irrelevant ones such as any revision information
Component: … to be triaged » Shape matching
Assigned: Unassigned » lauriii
Issue summary: View changes

I think we should gather a list of things we think that should NEVER be available to map.

I think a clear example is all revision information, because thats' basically internal information. Or perhaps "author-only" information, if you will.

wim leers’s picture

Pinged @lauriii to confirm 😊

lauriii’s picture

Assigned: lauriii » Unassigned
Issue summary: View changes
Issue tags: -Needs product manager review

Let's just omit revision_log_message. The two other examples have valid use cases i.e. displaying the author who had edited the node and when it was edited. I checked again and didn't see any other values we would have to omit.

wim leers’s picture

Assigned: Unassigned » wim leers

Thanks!

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Active » Needs review
wim leers’s picture

Title: Triage shape-matched DynamicPropSources: remove irrelevant ones such as any revision information » Suggest only relevant DynamicPropSources: `revision_log_message` is considered irrelevant
Assigned: Unassigned » phenaproxima
Status: Needs review » Reviewed & tested by the community

I think @phenaproxima is well-positioned to review this given his recent involvement and his strong opinions on #3555300: Distinguish between prop source matchers (comprehensive, objective) and suggesters (ordered by importance, filtered by relevance: subjective) 👍

wim leers’s picture

Status: Reviewed & tested by the community » Needs review

Oops!

phenaproxima’s picture

Assigned: phenaproxima » Unassigned

The nature of the change here is straightforward but the code could maybe use a touch of a documentation and a small refactor for clarity.

phenaproxima’s picture

Status: Needs review » Needs work
wim leers’s picture

Assigned: Unassigned » lauriii
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs product manager review

Responded to @phenaproxima's feedback.

But more importantly: @lauriii promised me he'll check tomorrow for other cases, such as "Default translation" for a user, and "User status" for a user (or a revision user):

            "Revision user → User → Default translation" => 'ℹ︎␜entity:node:foo␝revision_uid␞␟entity␜␜entity:user␝default_langcode␞␟value',
            "Revision user → User → User status" => 'ℹ︎␜entity:node:foo␝revision_uid␞␟entity␜␜entity:user␝status␞␟value',

(Those are type: boolean matches. "Default translation" is a boolean field on ALL translatable content entity types. "User status" is to convey whether the user is active or blocked.)

lauriii’s picture

Title: Suggest only relevant DynamicPropSources: `revision_log_message` is considered irrelevant » Suggest only relevant DynamicPropSources
Assigned: lauriii » Unassigned
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs product manager review

I've added couple more fields that we should consider as irrelevant.

User Status field you may want to use if you're building a content template for the user entity – so let's not get rid of that.

wim leers’s picture

Assigned: Unassigned » wim leers
phenaproxima’s picture

We could use the existing DataDefinition::setSetting(). Despite not being an interface method, core relies on it in many, many places.

wim leers’s picture

#17: but only for actual settings for the given field type?

wim leers’s picture

Assigned: wim leers » Unassigned
Issue summary: View changes
Status: Active » Reviewed & tested by the community

Implemented everything proposed by @lauriii 👍

Pivoting the implementation towards metadata-in-Typed-Data (asked by @lauriiii, explained by me on the MR why not feasible, disputed by @phenaproxima in #17, and that itself disputed by me in #18, for which I created a core feature request in #16) can happen in a follow-up issue.

This solves the problem at hand without presuming that we have sufficient data to bake in a formal API. I think we should first gain more real-world experience. IOW: hardcoded heuristics now, evolve to metadata-in-Typed Data later. With or without #3557353.

wim leers’s picture

phenaproxima’s picture

+1 RTBC. The changes make sense to me and it's wise that these subjective decisions are confined to PropSourceSuggester.

wim leers’s picture

Category: Task » Feature request
Issue summary: View changes
StatusFileSize
new30.74 KB
new21.61 KB
new33.33 KB
new30.44 KB

  • wim leers committed 33fa596d on 1.x
    feat(Shape matching): #3551339 Suggest only relevant DynamicPropSources...
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Cypress job #1 is a known failure, see #3539693-24: inputBehaviorsCommon mutates the passed props, breaking the rules of React. So went ahead and merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.