Overview
For the first time, this config schema type now relies on
type: sequence. For DX purposes (debugging, config diffing, etc.), it's important that the sequence keys are ordered A) consistently, B) sensibly.IMHO the most sensible ordering would be:
- first by level in the tree, starting with the top of the tree
- within a level, in sibling order
- when there's multiple slots, by slot machine name order
That could be achieved by generating keys for each sequence item that represent the path to that component instance:
- Conceptually:
root-instance.slot_name.level1-instance.slot_name.level2-instance- Concretely: all those instances would be UUIDs — that'd be insanely long very quickly
- So instead: don't use the UUID of a component instance, but the sibling index within each level, so that'd be
0.foo.1.bar.3as the key for the (starting at the deepest level) 4th component instance in thebarslot of the second component instance in thefooslot of the first component instance in the root.If we did that, then all we'd need to do is add
orderby: keyto config schema, and the config save/export functionality would automatically sort the tree exactly in that sensible ordering!Before this MR, that didn't matter a great deal. But after this MR, it's trivially possible to run a DB query that either lists the entire tree, or a subtree, and manipulate the ordering with a simple
ORDER BY. It's important that the DX for a developer (or site builder) inspecting big component trees in config is not painful.That's not a blocker for this issue/MR though; but it should be a
stable blocker. Let's create a follow-up issue for that.
— https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...This is that follow-up.
Proposed resolution
User interface changes
Issue fork experience_builder-3526127
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 leersThis would be the next big DX boost after #3521137: XB's storing JSON blobs should not be visible in exported config nor to test authors! 😊
Comment #3
wim leersComment #4
larowlanWe have to be wary here because order is important.
With content entity versions of these trees, there is a delta field that keeps track of the order.
Here there is not, and perhaps we should introduce it.
The delta keeps track of what order sibling components (those with the same parent/slot) appear in.
Comment #5
wim leersHere it is indeed the sequence order (which implicitly has "deltas" as keys: a PHP "list" array, so
0,1etc.) that ensures the correct ordering.I'm contemplating whether this should be a beta blocker or not. It feels like it'd be safer to make this a beta blocker. Do you agree?
Comment #6
larowlanIt feels like it should be simple enough - the main impacts here are on page regions and patterns. Add content templates if that ends up being in beta.
Tagging as such
Comment #7
nagwani commentedAs beta blocker tag is added, I am removing stable blocker tag
Comment #8
nagwani commentedComment #9
larowlan🏗️ picking this up
Comment #11
larowlanThis should be ready for review 🤞
Comment #12
wim leersComment #13
wim leersYou made this look simple! 🤩
Only comment nits! Automated tests were crystal clear; no remarks. Also manually tested, just to make sure we didn't miss anything in the automated tests: works great 👍
Comment #14
wim leersPer @larowlan at #3501708: Prove that it *will* be possible to apply block settings update paths (assuming #3521221 in core) to stored XB component trees in config/content, this MR blocks that one.
Comment #15
wim leersComment #17
wim leersComment #19
wim leersFYI: we missed an edge case: #3548165: Components in `ContentTemplate`s and `PageRegion`s are not always rendered in correct order.