Overview

  1. @tedbow was forced to introduce PropSourceEndpointTest in #3455975: HTTP API: update /xb-component/{component_id} to list possible prop sources for current entity context, because no functional tests existed for that internal HTTP API response yet.

    That was merged August 29, 2024.

    ApiConfigControllers and its corresponding functional test coverage at XbConfigEntityHttpApiTest were both introduced in #3479982: HTTP API to read+write PageTemplate and Pattern config entities by yours truly on October 22, 2024, in an attempt to curb the explosion in number of (routing) controllers.
    Months later, that attempt has proven succesful 👍

    However, the one outlier now is PropSourceEndpointTest.

  2. Add a new explicit HTTP API (per #3510896-10: Add a new internal HTTP API for candidate `DynamicPropSource`s to enable a `ContentTemplate` UI) to unblock the UI for #3455629: [PP-1] [META] 7. Content Templates — aka "default layouts" — affects the tree+props data model. This was removed in #3532130: `/xb/api/v0/config/component` crashes when `article` node type does not exist due to hardcoded assumption in `GeneratedFieldExplicitInputUxComponentSourceBase::getClientSideInfo()` to unblock more urgent functionality. The original implementation provided all candidate DynamicPropSources: across ALL content entity types. That's not necessary for the content template UI, because that'll always be scoped to some given content entity type + bundle.

Proposed resolution

  1. ✅ The PropSourceEndpointTest test coverage that since #3532130 no longer contains dynamic_prop_source_candidates ought to be moved into XbConfigEntityHttpApiTest, and match the existing naming scheme, so it should be in a test method named ::testComponent().
    → MR 1379
  2. ✅ Provide a new HTTP API to supersede what was removed in #3532130, and better fit the needs of the content template editing UI. Use the results from \Drupal\experience_builder\ShapeMatcher\FieldForComponentSuggester::suggest() (related: #3523446: Rename `FieldForComponentSuggester` to `PropSourceSuggester`), which is what #3532130 removed.
    → MR 1391

User interface changes

None.

CommentFileSizeAuthor
#39 Screenshot 2025-08-13 at 6.39.34 PM.png202.61 KBwim leers
Command icon 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

wim leers created an issue. See original summary.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Issue tags: -Novice

I would say this isn't so Novice, the tests are quite complicated. I had to:

1. Swap to standard profile
2. Modify cache tags in existing tests to match
3. Enable some new modules
4. Port over helper functions

Locally these tests are throwing a bunch of warnings but I'm testing out the ddev XB setup so it might be related to that.

acbramley’s picture

Status: Active » Needs work

Not too sure what's causing those unrelated test failures!

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Needs work » Needs review
wim leers’s picture

Not too sure what's causing those unrelated test failures!

Hm … me neither, but this seems like yet another case of https://www.drupal.org/project/gitlab_templates being wrong and running contrib module's test suites differently for non-maintainer-pushed commits than for maintainer-pushed commits 😬 (I wish I was kidding!)


Also: you're right, I misjudged, this is not a trivial move. 🙈 Thanks for removing the Novice tag.

But … this issue is novice-like in the sense that you were able to do this without deep XB knowledge! 😄 What do you think would be a more appropriate tag? 😊

wim leers’s picture

Title: Move `PropSourceEndpointTest` into new `XbConfigEntityHttpApiTest::testComponent()` » Move candidate `DynamicPropSource`s to a new internal HTTP API for `ContentTemplate`s
Priority: Minor » Normal
Issue tags: +Performance
Parent issue: » #3521002: [META] Maintainable client-side data model + internal HTTP API
Related issues: +#3530907: Optimize DynamicPropSource candidate suggestion logic: improves performance of /xb/api/v0/config/component by 80%
wim leers’s picture

Title: Move candidate `DynamicPropSource`s to a new internal HTTP API for `ContentTemplate`s » Remove candidate `DynamicPropSource`s from `/xb/api/v0/config/component` to a new internal HTTP API for `ContentTemplate`s instead of
Assigned: wim leers » Unassigned
Status: Needs review » Needs work
Issue tags: +openapi

Suggested API route:

experience_builder.api.info.candidate_dynamic_prop_sources:
  path: '/xb/api/v0/info/candidate_dynamic_prop_sources/{entity_data_definition}'
  methods: [GET]
  …

So: /xb/api/v0/info/candidate_dynamic_prop_sources/entity:node:article etc.

larowlan’s picture

Title: Remove candidate `DynamicPropSource`s from `/xb/api/v0/config/component` to a new internal HTTP API for `ContentTemplate`s instead of » Add Add a new internal HTTP API for candidate `DynamicPropSource`s from `/xb/api/v0/config/component` to be used by for `ContentTemplate`s
Related issues: +#3532130: `/xb/api/v0/config/component` crashes when `article` node type does not exist due to hardcoded assumption in `GeneratedFieldExplicitInputUxComponentSourceBase::getClientSideInfo()`
wim leers’s picture

Title: Add Add a new internal HTTP API for candidate `DynamicPropSource`s from `/xb/api/v0/config/component` to be used by for `ContentTemplate`s » Add a new internal HTTP API for candidate `DynamicPropSource`s from `/xb/api/v0/config/component` to be used by for `ContentTemplate`s
Priority: Normal » Major
Issue tags: +stable blocker, +blocker
Related issues: +#3455629: [PP-1] [META] 7. Content Templates — aka "default layouts" — affects the tree+props data model
wim leers’s picture

Title: Add a new internal HTTP API for candidate `DynamicPropSource`s from `/xb/api/v0/config/component` to be used by for `ContentTemplate`s » Add a new internal HTTP API for candidate `DynamicPropSource`s to enable a `ContentTemplate` UI

isholgueras made their first commit to this issue’s fork.

isholgueras’s picture

Assigned: Unassigned » isholgueras
isholgueras’s picture

Rebase done and tests moved fixed, but a $this->drupalLogout() from a previous tests is failing because Mink can't find "op" button.

https://git.drupalcode.org/project/experience_builder/-/jobs/5801240#L976

After inspecting the HTML right there, the user is logged in and there is a link for logout.

        <ul>
          <li>
            <a href="/user" data-drupal-link-system-path="user">My account</a>
          </li>
          <li>
            <a href="/user/logout?token=INyOF8qdzpnT1xzUapL9vdyU4YKpjP1WM6X-JZOG-VM"
               data-drupal-link-system-path="user/logout">Log out</a>
          </li>
        </ul>

I also added a $this->drupalLogin($this->httpApiUser) and it also fails.

isholgueras’s picture

Version: 0.x-dev » 1.x-dev

isholgueras’s picture

Assigned: isholgueras » wim leers
Status: Needs work » Needs review

isholgueras changed the visibility of the branch 3510896-move-propsourceendpointtest-into to hidden.

isholgueras changed the visibility of the branch 3510896-move-propsourceendpointtest-into to hidden.

isholgueras changed the visibility of the branch 0.x to hidden.

isholgueras’s picture

After talking to @wim, I've realized that #10 is adding a new task, so it's not ready.

The current MR1379 is only moving the test

wim leers’s picture

Issue summary: View changes

MR 1379 doesn't address the full issue scope, but I understand how that came to be.

That doesn't mean MR 1379 is wrong — we still need it, but it's only the original side of the coin, since #10 the coin gained another sight (metaphor falling apart — it's been a long day 😅.

wim leers’s picture

Issue summary: View changes
wim leers’s picture

wim leers’s picture

Issue summary: View changes

Having worked on many of the pieces powering FieldForComponentSuggester and the historical creation (#3455975: HTTP API: update /xb-component/{component_id} to list possible prop sources for current entity context) of the test we're refactoring away here, it seemed only reasonable that it was up to me to perform the git+d.o archeology work to bring clarity to the rationale behind what is being tested, and clean it up.

It can be improved further, but it is now sufficiently clear and commented for others to be able to iterate on it further. Merged @isholgueras' MR with my refinements. 👍

Next up: what this issue was rescoped to in #10. I'll get an outline of an MR going.

wim leers changed the visibility of the branch 1.x to hidden.

wim leers’s picture

🏓 Initial review posted :)

isholgueras’s picture

Assigned: isholgueras » Unassigned
Status: Needs work » Needs review
wim leers’s picture

Assigned: Unassigned » hooroomoo

This needs input from #3518248: [PP-1] Content templates, part 4 (boss battle): create a UI for editing templates and especially #3538861: Spike: UI for content templates, to determine what the ideal API response shape would be for the client side.

lauriii’s picture

Issue tags: -stable blocker

Content Templates is still a priority for stable, but we're tracking it separately.

wim leers’s picture

wim leers’s picture

Assigned: hooroomoo » wim leers
Status: Needs review » Needs work

Perfect, I have everything I need now to finish this up :)

wim leers’s picture

StatusFileSize
new202.61 KB

I won’t have time to finish this MR today — there’s still a bunch of loose ends to clean up, but it works.

@hooroomoo, please test, and confirm that this is what you want/need! 🙏 😇

You'll get something like:

wim leers’s picture

Thanks to @hooroomoo's test of this together with their PoC, I can now land this with confidence 🥳

Out of scope:

  1. making these API responses cacheable — if the need ever arises, we'll do that then
  2. code component support is out of scope — we have had #3503038: Enable candidate `DynamicPropSource` suggestions for code components: refactor `GeneratedFieldExplicitInputUxComponentSourceBase` and `FieldForComponentSuggester` to need only SDC's ComponentMetadata, not SDC plugin instances for >6 months now to do exactly that
  3. fixing a shape matching bug that the test coverage I added unearthed: #3541361: Find optional field instance matches for `type: object` props (images + videos), including for optional fields on bundleless entity types (e.g. `User`'s `user_picture`).
  4. while updating the OpenAPI spec, I noticed that for all 4xx responses, the generated docs say
    {
      "errors": [
        {}
      ]
    }
    

    is an example value. Which makes no sense, because it should be something like

    {
      "errors": [
        "The 'bla bla' permission is required."
      ]
    }

    But … this is using the ClientErrorResponse already in HEAD, which clearly is wrong for many (not all, but many) routes 😅 It's somewhat right for validation errors for data sent in various API request bodies, but it's wrong for (most?) other cases.

    Created #3541366: OpenAPI spec's `ClientErrorResponse` and `AuthenticationErrorResponse` are incorrect for most API routes for this.

wim leers’s picture

The very last obstacle is supremely silly:

FILE: tests/src/Functional/ApiUiContentTemplateControllersTest.php
------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------
 20 | ERROR | [x] Doc comment star missing (Drupal.Commenting.DocCommentStar.StarMissing)

… but that all is there and it DOES comply! 🙃

Just removing the comment, don't want this to be held up by that — created supported request upstream: #3541384: False `Drupal.Commenting.DocCommentStar.StarMissing` report?.

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.