Closed (fixed)
Project:
Experience Builder
Version:
0.x-dev
Component:
Page builder
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Nov 2024 at 17:30 UTC
Updated:
28 Jan 2025 at 17:39 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
hooroomooComment #3
wim leers👍 Thanks!
Yep, but the endpoints actually already exist, i.e. the following routes:
experience_builder.api.config.listexperience_builder.api.config.getexperience_builder.api.config.patchexperience_builder.api.config.postexperience_builder.api.config.delete… but they currently only support the
PageTemplateconfig entity, because that's the only XB-owned config entity type that implements\Drupal\experience_builder\Entity\XbHttpApiEligibleConfigEntityInterface— #3479643: Introduce a `Pattern` config entity will add thePatternconfig entity type that also implements that interface 👍Comment #4
wim leers#3479643: Introduce a `Pattern` config entity is in!
Comment #5
lauriiiIt seems that the FE is already connected but I'm getting an error when trying to use this. This probably needs someone on the backend to debug this.
The error with a backtrace:
Here's the request:
Comment #6
wim leersIt isn't? 🤔 That's what this issue is supposed to do!
AHHHHHHHH, I see now! @jessebaker added this in #3459229: Allow saving component compositions as sections (frontend only):
and assumed that that the current client-side data model for component trees would automatically and transparently work for
Patternconfig entities too. That's not the case though, because that data model is known to be in need of evolution: #3467954: META: Evolve XB UI's data model to allow non-SDC components' inputs, DynamicPropSource support, etc..Comment #7
wim leersProblems with the current front-end code cited in #6:
labelfor a section is missing. Or are we saying that they should not have labels? 🤔 If so, happy to remove that from the server-side logic 👍Now, I did anticipate that second point. That's why there's
… in
\Drupal\experience_builder\Controller\ApiConfigControllers::post()and::patch().It seems like the most pragmatic approach is to:
POSTandPATCHGETComment #8
wim leersMissing context: I expected #3467954: META: Evolve XB UI's data model to allow non-SDC components' inputs, DynamicPropSource support, etc. to have been completed weeks ago, and that'd have likely removed the need for bringing the same client-to-server-transformation-and-back functionality to this MR that we already have for editing content entities' component trees.
That's why I'm a bit hesitant, and why I'd like explicit confirmation from @lauriii.
Comment #9
lauriiiThe API should enforce a label. We should prevent saving sections without a label.
This is not necessarily urgent. I was hoping we could demo this at DrupalCon in case that this was really close to being done but it seems that it isn't the case. I'd be fine with us postponing this on #3467954: META: Evolve XB UI's data model to allow non-SDC components' inputs, DynamicPropSource support, etc. and re-evaluating closer to 0.2.0 if that hasn't been done.
I wonder if this is covered by the global error handling? When I tested this, I was getting a fairly graceful handling of errors within the modal.
Comment #10
wim leersOkay! Then the client must provide a label. We can't auto-guess a label. But for now I'll go with
Section N, with N auto-incrementing. That avoids being blocked on the client side.I'll do a time-boxed iteration on this to see if I can get the pragmatic solution I outlined in #7 done in an hour.
Comment #12
wim leers@f.mazeikis told me a few days ago he was working on it — I see that the issue metadata was out of date 😅
Comment #15
tedbowI talked with @f.mazeikis about this issue today
I wanted to see if the logic we added in
ClientDataToEntityConvertercould be used in this case also. When added in [##3489994] it hardcoded assumptions that we would be updating an entity with aComponentTreeItemwhich of course in sections we won't be. But we did have most of the logic for converting a `layout` and `model` from the client to a `tree` and `props` that server can save.I start with his branch
3486203-integrate-saving-sections, merged in 0.x and thenMoved most of this logic to a new
ClientServerConversionTrait::convertClientToServer. These leaves bothClientDataToEntityConverter::convertandApiConfigControllers::decodevery thin as they can both rely on the the newconvertClientToServerI talked with @f.mazeikis about we need to figure out if we can centralize the conversion from client to the server and then back. But this at least puts the logic for client to server in 1 place for converting a `layout` and `model` from the client to a `tree` and `props`. there really wasn't any new code in here just moving code around that already went through review
Comment #16
wim leersThanks for helping out here, @tedbow! What you did is exactly what I expected 😊👍
Perhaps we should land @tedbow's !444 MR first, because it simplifies the rest of the work in this issue and reduces the accumulation of conflicts with other MRs? 😊
For that reason, I am working to get the MR to green so I can approve it — at which point either of you feel free to merge it if you like that!
Comment #17
wim leersUsing this button on a two column component instance containing one component per column:
… and then reloading the page (needs follow-up: the UI needs to refresh the list after creating a section!), it actually works:
(Although you can see that the preview is not yet working.)
IMHO once this passes tests, this MR can be merged (for DrupalCon Singapore demo purposes), and the preview + refreshing of the list can happen in subsequent MRs in either this issue or a follow-up.
Still needs work for updating
XbConfigEntityHttpApiTest::testPattern()to send request bodies shaped like the client-side data model.Comment #18
tedbowgoing to work on this
Comment #19
wim leersThank, @f.mazeikis!
That made the preview look less broken, but not yet actually working:

Self-assigning because @tedbow hasn't been pushing anything. This feels close, and it overlaps significantly with work I helped land on both
ApiComponentsController(thedefault_markupstuff @f.mazeikis just added) andApiPreviewController.I am reviewing those bits specifically for their cacheability correctness, and hopefully to get the preview to fully work in a short amount of time :)
Comment #20
wim leersMarkup-only preview of Sections/
Patterns is now working, but looks off due to missing CSS+JS:Next: CSS + JS.
Comment #21
wim leersNow previews are fully operational:
Comment #22
wim leersI wrote
… but that's before I saw the extensive changes to
ApiConfigControllers, which explain whyXbConfigEntityHttpApiTest::testPattern()is not passing. This MR as-is is too incomplete to be mergeable; it'd leave XB in a very confusing state: parts of the UI start working, but the thorough HTTP API test coverage no longer passes because the refactor towards the client-side data model is good, but partial.Comment #23
wim leersRE #22 I did a hands-on review where I pushed commits to show the direction I'd like to see rather than describing it, which would've been far more ambiguous.
I've already ">roughly implemented the decode-vs-denormalize split, the same thing will be needed for
::encode()(a new::normalize()method etc, with a@todoto convert toNormalizerInterfacein a future MR).Now the MR has largely passing
\XbConfigEntityHttpApiTest::testPattern(), but thepost()method is not yet calling::normalize(),::patch()is not yet calling neither::denormalize()nor::normalize()and::get()and::list()still need to be updated to call::normalize().I think introducing all the
DenormalizerInterface+NormalizerInterfaceinfrastructure in this MR will lead us too far. IOW: I think we should write this using method names matching https://symfony.com/doc/current/serializer.html#the-serialization-proces..., per config entity type. That will make it easy to convert to that Symfony infrastructure in a subsequent MR :)Comment #24
tedbowChatted with @wim leers and created an issue to extract out just the changes for
ClientServerConversionTraitandClientDataToEntityConverter#3492312: Provide a utility method to convert client layout and model to server tree and propsComment #25
tedbowComment #26
wim leersGood to see this progressing towards a green CI pipeline!
Posted an intermediary review. 🏓 Would love to see this get to an RTBC'able state! 😄
Comment #27
wim leersThe bit that @f.mazeikis researched I confirmed and extracted into a separate issue+MR that make this MR slightly simpler :) — see #3493388: Remove pointless asset library dependencies/overrides on `core/once`.
Comment #28
wim leersThis cannot land until that other issue lands, but there's plenty of other remarks that are not yet addressed — by tackling those, this should become RTBC'able! :)
Comment #29
wim leers#3493388: Remove pointless asset library dependencies/overrides on `core/once` is in, this can be simplified now 👍
Comment #31
wim leersGreat to see this approaching the finish line! 😄🏁
Comment #32
f.mazeikis commentedI’ve added ednpoints to
openapi.yml, but I’ve intentionally stopped myself from adding all the methods and examples, as I am not even sure if that’s reasonable thing to do, if FE doesn’t use it yet. Happy to expand this, if that will be the in the review feedback.The other thing is !505 was merged in and resulted in conflict that forced me to make some changes to
ApiConfigControllersandXbConfigEntityHttpApiTest, so changes in MR are slightly beyond just addressing the previous review feedback.Comment #33
wim leersComment #34
wim leersI'd like explicit feedback from the
/openapi.ymlowner, @traviscarden, because I am concerned that it in the current state it will cause confusion, whereas it should be providing clarity and increasing team velocity. Travis, see write-up on the MR.Comment #35
wim leersWhile awaiting @traviscarden's OpenAPI feedback; there definitely are outstanding things @f.mazeikis can already fix until Travis wakes up :)
Comment #37
traviscarden commented@wim leers, there were actually some pretty significant problems with our
openapi.yml--most notably,schema-related specification violations. (It doesn't surprise me it hasn't been doing everything we want it to.) I've fixed them all, and Swagger Editor is happy now. I've also identified a few opportunities for improvement, but it took kind of a long time to get the existing file passing validation, so I haven't had time to actually implement any of them. Here's an overview:openapi.yml. I believe that's what OpenApiSpecValidationTest is supposed to be doing.minimum,maximum,default,minItems, andmaxItemswhere appropriate. See Data Types for more possibilities.allowEmptyValuewhere possible.enumbecause there are a definite, limited number of valid values.TODOvalues for now.That's what I've got for now. I don't know what you want to accomplish within this issue specifically, @wim leers. Anything that doesn't seem urgent could be moved to #3472617: Document where the cut-off lies of where OpenAPI validation ends and entity validation begins, if you like.
Comment #38
wim leers@traviscarden in #37: Thanks! 😊
Why didYou wrote that in your first point! 😄\Drupal\Tests\experience_builder\Unit\OpenApiSpecValidationTestnot catch those significant problems?Agreed on all counts. Bumped #3472617: Document where the cut-off lies of where OpenAPI validation ends and entity validation begins to , since it would've accelerated this MR by days!
Well, as you would probably expect: I want this issue to deal only with
Patternconfig entities, as the title describes. So actually, the commits you pushed are out-of-scope and should've landed in a separate MR, because this now complicates reviewing this MR.Fortunately, @f.mazeikis doesn't mind. So let's be pragmatic and keep the out-of-scope changes.
#3491021: Leverage HTML comment annotations, remove wrapping div elements landed yesterday, which this conflicted with. Plus, upstream broke our CI, so this needed #3499602: CI: DEVizzent/cebe-php-openapi 1.1.3 broke the build merged in, too.
I vow this MR will land today!
Comment #39
wim leersTurns out that
was caused by a
KeywordMismatch::fromKeywordexception forlangcodeon thePageTemplateconfig entity's auto-save entry returned byApiPendingChangesControllerbeingNULL, whereas the OpenAPI spec requires it to be a string.@traviscarden did not change that bit of the definition of
AutoSaveEntryin/openapi.yml, so it must've been a pre-existing bug, that was being masked by subtle problems in/openapi.yml; otherwise #3494114: Implement auto-save of the page template config entity would've run into this and would've been forced to fix it instead of this MR.Comment #40
wim leersI thought I was wrong in #39, because after making
langcodenullable: true, the error still occurred, identically! 🤪The error message is obviously … not very detailed, and hence quite hard to interpret. So … I dug deeper. 👷
Root cause for that turns out to be
\Drupal\experience_builder\EventSubscriber\ApiMessageValidatorBase::onMessage(), which does:… and while the
::logFailure()logs the detailed information, thethrow $emeans that\Drupal\experience_builder\EventSubscriber\ApiExceptionSubscriberhas to re-implement this.That changes the error message to be much more helpful:
Turns out #3470321: Surface verbose OpenAPI errors in the UI — for better bug reports and faster DX is the pre-existing issue for that … and it's already been critical for almost 4 months, but it's just never been worked on! 😬
Comment #41
wim leersSo, while @traviscarden's commits on this MR were well-intentioned, they were very out-of-scope. I tried keeping them, because it's still a much-needed improvement to
/openapi.yml. But unfortunately, they revealed hitherto unknown flaws in/openapi.yml, as explained in #39 and #40.I decided to still keep those because of how many are being negatively impacted productivity-wise by the absence of OpenAPI validation errors — see #3472617-3: Document where the cut-off lies of where OpenAPI validation ends and entity validation begins and -4.
I think both #3472617 and #3470321: Surface verbose OpenAPI errors in the UI — for better bug reports and faster DX are urgent to keep this team moving forward, and I've asked @effulgentsia to prioritize both issues. But meanwhile, at the cost of more chaos in this issue and a significant amount of time spent by me decyphering the situation, I merged 99% of what @traviscarden did here, because those are all net improvements! 🥳
The sole bit I reverted is the reordering, and for that I created the more cohesive #3499703: Make all XB HTTP API routes consistently prefixed, ensure they all have OpenAPI specs, and tests to keep it so, which @tedbow independently raised earlier today.
The test coverage in
\XbConfigEntityHttpApiTest::testPattern()needed to carefully balance testing OpenAPI validation (data shape only) against validation constraint violation (complete, detailed validation, including internal consistency beyond the data shape). I refined that.GIF of this in action added to the issue summary!
Comment #43
wim leers