Problem/Motivation

Once #3541151: Content display overrides: Form widgets and #3531523: Migration from Layout Builder (config only) are done, we will be able to execute the migration also for content overrides.

Proposed resolution

When an Display Builder override is initialized, there are 4 possible sources of data and we load the first in this order of priority:

  1. Field settings default value: the first, not because we want but because it seems Field API is forcing it. It may be the opportunity to challenge that.
  2. Existing Layout Builder override (only for default display): priority because we keep existing content
  3. Display Builder entity view display config: the most usual and expected situation. the scope of this ticket
  4. Existing Layout builder config (if we do #3540048: Allow override of displays not build with display builder)
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

pdureau created an issue. See original summary.

pdureau’s picture

The migration is located in BuilderDataConverter::convertFromLayoutBuilder()

We are triggering it only from config right now, from the implementation of DisplayBuildableInterface::getInitialSources():

  public function getInitialSources(): array {
    // Get the sources stored in config.
    $sources = $this->getSources();

    if (empty($sources)) {
      // initialImport() has two implementations:
      // - EntityViewDisplay::initialImport()
      // - LayoutBuilderEntityViewDisplay::initialImport()
      $sources = $this->initialImport();
    }

    return $sources;
  }

https://git.drupalcode.org/project/display_builder/-/blob/1.0.x/modules/...

It seems the migration logic would stay the same, we lmay just need to trigger it from content too: DisplayBuildableInterface::getInitialSources() is also implemented in https://git.drupalcode.org/project/display_builder/-/blob/1.0.x/modules/...

pdureau’s picture

pdureau’s picture

pdureau’s picture

Assigned: Unassigned » pdureau

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Active » Needs review
grimreaper’s picture

Assigned: Unassigned » grimreaper
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Needs work

I think the issue needs steps for testing.

I put some review comments.

I have tested the following scenario:
- create a content type
- enabled LB and LB overrides (default view mode)
- configure LB on this entity view display (add a 2 columns section and place field blocks in it)
- create one content
- create another content and override its LB but adding a block content.
- add a UI source field on the content type
- enable DB and DB overrides on the default view mode
- save entity view display DB configuration
- both contents have the same display, the default DB. When trying to override the DB on one of the content it is the default DB that is used not its previous LB overrides.

Is it what is expected?

pdureau’s picture

Assigned: Unassigned » pdureau
pdureau’s picture

Hi Florent,

You are right, it must be clarified and documented.

Current state of the MR

Before talking about import and conversion, we notice Display Builder takes the lead over Layout Builder to render a content (even when there is a Layout Builder override in content).

However, the import (& conversion) when we open a DB override for the first time (ie, when there is no data in stored in the field already), is not following this priority order:

For display For import in DB override
Higher priority Display Builder override
P2 Display Builder config Layout Builder override
P3 Layout Builder override Display Builder config
Lower priority Layout Builder config (Not applicable)

This difference is confusing, we must align the mechanisms. How?

Proposal 1: Display Builder always win

Same priority order for display and import:

For display For import in DB override
Higher priority Display Builder override
P2 Display Builder config Display Builder config
P3 Layout Builder override Layout Builder override
Lower priority Layout Builder config (Not applicable)

Proposal 2: Overrides always win

Maybe it is confusing to lose all LB overrides once Display Builder is activated in a display, it changes the display of existing content. It breaks the content in a way.

Same priority order for display and import:

For display For import in DB override
Higher priority Display Builder override
P2 Layout Builder override Layout Builder override
P3 Display Builder config Display Builder config
Lower priority Layout Builder config (Not applicable)
grimreaper’s picture

Yes, I thought current MR state was proposal 2.

grimreaper’s picture

Discussed, we agreed on the following behavior, but current implementation is incorrect then.

For display
For import in DB override
Higher priority Display Builder override
P2 Display Builder config Layout Builder override
P3 Layout Builder override Display Builder config
Lower priority Layout Builder config (Not applicable)
pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs work » Needs review

Work as expected. Kernel tests added.

Still a playwright fail in pipeline, but doesn't seem related to the current work.

grimreaper’s picture

Status: Needs review » Needs work

Still not working as expected for me.

Will need to see that in meet.

pdureau’s picture

Assigned: Unassigned » pdureau

ok let's talk

grimreaper’s picture

Assigned: pdureau » Unassigned

Seen with @pdureau, manual test ok, I missed a step in the tests.

Minor changes to do on the MR.

pdureau’s picture

Assigned: Unassigned » pdureau

Changes asked by Florent: done

Remaining: playwright fail:

     - waiting for locator('[data-target="library"]')
       at objects/DisplayBuilder.ts:27
      25 |       await expect(sidebarFirst).toBeHidden()
      26 |     } else {
    > 27 |       await toolbarButton.click()
         |                           ^
      28 |       await expect(sidebarFirst).toBeVisible()
      29 |     }
      30 |   }
        at Displaybuilder.toggleSidebarView (/builds/project/display_builder/tests/src/Playwright/objects/DisplayBuilder.ts:27:27)
        at Displaybuilder.openLibrariesTab (/builds/project/display_builder/tests/src/Playwright/objects/DisplayBuilder.ts:41:7)
        at Displaybuilder.dragElementFromLibraryById (/builds/project/display_builder/tests/src/Playwright/objects/DisplayBuilder.ts:68:5)
pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs work » Reviewed & tested by the community

Hi Jean

I am sorry to send the issue to you with a playwright fail but i am not reproducing it locally. Switching back to RTBC because checked by Florent.

However, it is very important to merge #3549266: Move DisplayBuildableInterface to a new plugin type before this one because they may conflict. I am OK to do the rebase my self if conflicting.

mogtofu33’s picture

Assigned: mogtofu33 » pdureau
Status: Reviewed & tested by the community » Needs work

Looks like a real problem with Entity View Override:

pdureau’s picture

Ok thanks, i am having a look.

pdureau’s picture

Aside the playwright fail, there is something else to check before sending to review:

  • there is always a single Layout Builder Override per bundle: the default display stored in OverridesSectionStorage::FIELD_NAME
  • there could be many Display Builder Override per bundle, one for each display stored in whatever ui_patterns_source field

Now, we are importing from Layout Builder Override when we are initializing data for any Display Builder Overrides. Maybe we need to check the display entity ID is the same in both (so it will work only for default).

pdureau’s picture

only playwright left :)

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs work » Needs review
grimreaper’s picture

Status: Needs review » Reviewed & tested by the community

Hello,

I reviewed the last changes, ok for me

pdureau’s picture

Assigned: Unassigned » mogtofu33
mogtofu33’s picture

Status: Reviewed & tested by the community » Needs work

Need to work on the tests, they look a lot like Functional tests candidate and not Kernel.
These are testing a process through multiple methods, Kernel should cover only one class.

Will update them.

mogtofu33’s picture

Status: Needs work » Needs review

Created functional tests for simplicity.

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

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.

  • mogtofu33 committed 38749e64 on 1.0.x authored by pdureau
    fix: #3542859 Migration from Layout Builder (content overrides)
    
    By:...

Status: Fixed » Closed (fixed)

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