Overview

Right now if a Content exists for a view mode and the bundle has a Component Tree field the content template will take effect.

This will be problem in #3541000: [META] Content templates UI for 1.0: only nodes, no exposed slots, no replacement for the view mode/display UI as soon as the UI adds a new ContentTemplate but before it is published it will take effect

Proposed resolution

In `\Drupal\experience_builder\EntityHandlers\ContentTemplateAwareViewBuilder::buildComponents` after the component is loaded it should only be used if the status is true.
So something like

$template = ContentTemplate::loadForEntity($entity, $view_mode);
      if ($template && $template->status()) {
        $displays[$bundle] = $template;
      }

\Drupal\Tests\experience_builder\Kernel\NodeTemplatesTest::testOptContentTypeIntoXb should be updated to test a with the status of the template first false, it should not take effect and then once set to true it should take effect.

Bonus
Additionally it would be great if even though ApiLayoutController won't work with ContentTemplate entities until #3541021: Refactor `ApiLayoutController` to support `ContentTemplate`s in this issue we can still update \Drupal\experience_builder\Controller\ApiAutoSaveController::post to set the status to true on publish. \Drupal\Tests\experience_builder\Kernel\ApiAutoSaveControllerTest::testPost will need to be updated to assert that a ContentTemplate actually has it's status updated.We can't use `ApiLayoutController` in this test but we can still add a ContentTemplate entity using \Drupal\experience_builder\AutoSave\AutoSaveManager::saveEntity

User interface changes

None

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

tedbow created an issue. See original summary.

tedbow’s picture

Assigned: Unassigned » thoward216

thoward216 made their first commit to this issue’s fork.

thoward216’s picture

Status: Active » Needs work
tedbow’s picture

@thoward216 I think this is looking good, just need to add the test coverage I just mentioned in the MR comment. thanks!

wim leers’s picture

Title: ContentTemplate status should be used to determine if it should be used. » `ContentTemplate`'s `status` should determine if it is active
Component: Page builder » Auto-save
Assigned: thoward216 » tedbow
Status: Needs work » Reviewed & tested by the community
Issue tags: +Configuration Management
tedbow’s picture

Status: Reviewed & tested by the community » Needs work

@thoward216 and @wimlees a got further in the test but the relieved some other, problems, not with your code, but some things I hadn't thought of.

Working on it

tedbow’s picture

Assigned: tedbow » wim leers
Status: Needs work » Needs review

@wimleers see my last MR comment

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

RTBC — with a caveat: please confirm that my understanding at https://git.drupalcode.org/project/experience_builder/-/merge_requests/1... is correct 🙏

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Perfect, thanks, @thoward216! 😊

Status: Fixed » Closed (fixed)

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