Closed (fixed)
Project:
Experience Builder
Component:
Page builder
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Jun 2024 at 09:36 UTC
Updated:
31 Jul 2024 at 13:44 UTC
Jump to comment: Most recent
we should probably make these special strings constants
const DYNAMIC_SOURCE_TYPE = 'dynamic'; const STATIC_SOURCE_TYPE_PREFIX = 'static:';
— https://git.drupalcode.org/project/experience_builder/-/merge_requests/2... @larowlan review for #3452497: [MR Only] Edit any component prop, powered by a new FieldForComponentSuggester service, which will power the JS UI.
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 #3
wim leersComment #5
wim leersBlocked on #3452497: [MR Only] Edit any component prop, powered by a new FieldForComponentSuggester service, which will power the JS UI landing first, but @larowlan can already review this — just only review the last commit 🙏
Comment #6
wim leers#3452497: [MR Only] Edit any component prop, powered by a new FieldForComponentSuggester service, which will power the JS UI is in, rebased, ready for review 👍
Comment #7
lauriiiThe MR pipeline is failing.
Comment #9
tedbowPipeline is passing
Comment #10
wim leers@larowlan or @tedbow, could you review? 🙏
Comment #11
wim leers@larowlan Thanks! Merging in all upstream commits first…
Only developers would maybe see the string representation of
(Static|Dynamic)PropSources. And they definitely won't be reading that representation in JSON-encoded-in-YAML form (although there we could do the work to not use\u<unicode code point>but just use the Unicode representation directly — we should do that, it's just not urgent, especially if we don't know we'll continue to use this approach).This is a data structure (
(Static|Dynamic|Adapted)PropSourceare strongly typed PHP objects), it's just one that has an equivalent string representation. That string representation allows both for a more compact representation, resulting in less (cognitive & space) overhead when looking at an entire component tree. I wanted a string representationbecause that makes searching (googling/ducking) for problems much simpler.
I respectfully disagree with you that only a data structure, without a string representation, would be better. You'd then at minimum still need an array representation to be able to express/store it in JSON/YAML, and I wanted to avoid a new Type Of Array of Doom 😅 — but it sounds like you think this is perhaps the first Type of String of Doom? 😅
All that being said: this seemed the best/simplest path to something that works that I could see. If you feel so strongly that there is a better way, then I'm absolutely open to an alternative. Whether you provide that in the form of a photo of drawings on a napkin, sample JSON blobs or an MR, is your choice :)
Comment #12
wim leersAssuming that the
\u<unicode code point>aspect was a significant part of what @larowlan was referring to in his MR comment, that's easily solved by using https://www.php.net/manual/en/function.json-encode.php.Note that
\Drupal\experience_builder\PropSource\StaticPropSource::__toString()already uses that … it's just that https://git.drupalcode.org/project/experience_builder/-/blame/0.x/config... was handcrafted and does not yet have validation constraints that would detect/prevent this particular encoding. Fixed with a simpleprint json_encode(json_decode($s), JSON_UNESCAPED_UNICODE);: https://git.drupalcode.org/project/experience_builder/-/merge_requests/4... :)Comment #13
wim leersAdd test coverage to A) reduce the concerns voiced by @larowlan, B) empower him/others to propose an alternative implementation. The test shows the range of needed capabilities —
EndToEndDemoIntegrationTestalready did that, but the newPropSourceTestdoes so in more detail, and in a kernel instead of functional test: https://git.drupalcode.org/project/experience_builder/-/merge_requests/4...Comment #14
wim leersComment #16
wim leers@larowlan wrote but did not click "approve" — so bypassed the explicit approval 🦹
Comment #17
larowlanRe #11 @wim - my driver is making sure we don't repeat mistakes like https://dbushell.com/2024/05/07/modern-wordpress-themes-yikes/
In last week's meeting longwave voiced similar concerns about this and asked if JSON path was considered as a non dtupalism approach
Comment #18
wim leers😄 I sent that exact link to @lauriii last week, voicing the exact same concern!
Comment #19
wim leersRelated: #3461490: Document the current JSON-based data model, and describe in an ADR