Refactor SdcController::preview() to use ComponentTreeHydrated, and update it to support nested components

Created on 26 July 2024, about 1 month ago
Updated 15 August 2024, 24 days ago

Overview

πŸ“Œ Introduce an example set of representative SDC components; transition from "component list" to "component tree" Fixed will add the remaining pieces for "tree" support, which πŸ“Œ FieldType: Support storing component *trees* instead of *lists* Fixed and πŸ“Œ Create validation constraint for ComponentTreeStructure Needs work laid the foundations for.

But \Drupal\experience_builder\Controller\SdcController::preview() already has:

    // @todo tree recursion β€” this only supports a flat list
    // @todo Refactor to use \Drupal\experience_builder\Plugin\DataType\ComponentTreeHydrated.

… because it currently uses custom logic to render these.

(// @todo support CSS + JS was handled in πŸ“Œ Load assets inside preview Active , we just forgot to delete that.)

Proposed resolution

  • Replace the render array with a call to \Drupal\experience_builder\Plugin\DataType\ComponentTreeHydrated::toRenderable()
  • … but that would lose the wrapping markup that allows the UI to identify each component. So make ::preview() recursively update the render array returned by ComponentTreeHydrated::toRenderable()
  • πŸŽ‰ Thanks to πŸ“Œ Create validation constraint for ComponentTreeStructure Needs work having landed, this can actually go ahead and update ComponentTreeHydrated to already explicitly supported components-in-slots πŸš€

User interface changes

None. The whole point is that everything continues to work exactly the same, but:

  1. with less special snowflake logic in SdcController::preview() β€” instead reusing the server-side foundations for rendering SDCs ⛄️πŸ”₯
  2. a solid portion of what πŸ“Œ Introduce an example set of representative SDC components; transition from "component list" to "component tree" Fixed would otherwise have to do to get previews of trees of components to render, is already taken care of πŸ‘
πŸ“Œ Task
Status

Fixed

Component

Page builder

Created by

πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024