Overview
#3446722: Introduce an example set of representative SDC components; transition from "component list" to "component tree" will add the remaining pieces for "tree" support, which #3455728: FieldType: Support storing component *trees* instead of *lists* and #3460856: Create validation constraint for ComponentTreeStructure 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 #3462450: Load assets inside preview <iframe> when components are added, 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 byComponentTreeHydrated::toRenderable() - 🎉 Thanks to #3460856: Create validation constraint for ComponentTreeStructure having landed, this can actually go ahead and update
ComponentTreeHydratedto already explicitly supported components-in-slots 🚀
User interface changes
None. The whole point is that everything continues to work exactly the same, but:
- with less special snowflake logic in
SdcController::preview()— instead reusing the server-side foundations for rendering SDCs ⛄️🔥 - a solid portion of what #3446722: Introduce an example set of representative SDC components; transition from "component list" to "component tree" would otherwise have to do to get previews of trees of components to render, is already taken care of 👍
Issue fork experience_builder-3463986
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
Comment #2
wim leersComment #4
wim leers@tedbow This should be a big accelerator to your work in #3446722: Introduce an example set of representative SDC components; transition from "component list" to "component tree" — this will make your work there be visible in the UI.
IOW: this is the subset of #3446722 that interacts with the client directly, and requires server-side code to be updated for the client to be usable.
Review suggestion: review only
ComponentTreeHydratedTest. If that part makes sense to you, IMHO you can blindly approve this, because it'll represent a leap forward with strict test coverage. That would unblock you on #3446722, and is an important step towards finalizing the client's data model and the request/response flow.Comment #5
wim leersI just realized that the MR's scope goes a bit further than the originally described/intended scope. Updated issue summary to explain why.
Comment #8
tedbowThanks @Wim Leers
Comment #9
wim leersThis introduced a small regression: #3465129: First `preview` request fails to generate a response for empty layout.