Overview
#3498889: ComponentSource plugin for code components introduced GeneratedFieldExplicitInputUxComponentSourceBase. In order to make most of the logic in that class (which powers the input UX for the "SDC" and "JS aka code component" ComponentSource plugins) work, it needs an SDC plugin instance.
Changing it to not need that would've led to even more refactoring in #3498889 than it already did.
Additionally we're hard-coding Article nodes in the same file
// 💻️ app/modules/experience_builder/src/Plugin/ExperienceBuilder/ComponentSource/GeneratedFieldExplicitInputUxComponentSourceBase.php:447
$suggestions = $this instanceof SingleDirectoryComponent
? $this->fieldForComponentSuggester->suggest($component_plugin->getPluginId(), EntityDataDefinition::create('node', 'article')) // 👈️👈️👈️👈️
: [];
Proposed resolution
- Refactor all the XB-owned infrastructure to not expect an SDC plugin instance as an argument, but only a subset of that plugin instance: a
ComponentMetadataobject. - Start with
GeneratedFieldExplicitInputUxComponentSourceBase - Note: this may require in some places an ephemeral SDC plugin object (not tied to an actually installed SDC on disk) to be generated from that metadata object, for example to be able to call SDC's
\Drupal\Core\Theme\Component\ComponentValidator::validateProps(). - Then move on to
\Drupal\experience_builder\ShapeMatcher\FieldForComponentSuggester. - Expected end result:
SingleDirectoryComponentorJsComponent-specific checks/logic remain.
This will allow docs/components.md to be updated to state something like:
Any `Component Source Plugin` without a native (explicit) input UX can reuse the infrastructure that XB originally
built to provide an input UX for `SDC`-sourced `Component`s. To generate an input UX, the precise shape of each
input (and it being required or optional) must be expressed in a standardized way. To avoid inventing new infrastructure,
XB opted to rely on the SDC subsystem of Drupal core's abstraction for expressing this: the `ComponentMetadata` class.
While imperfect (because it contains _all_ metadata rather than only that relating to its explicit input shapes), it is
the pragmatic choice to get the job done. See [`XB Shape Matching
into Field Types` doc](shape-matching-into-field-types.md) for details on how that works.
In other words: _any_ `Component Source Plugin` can use the same Drupal Field-powered UX that XB provides for SDCs,
all it requires is generating a `ComponentMetadata` object that expresses its input schema.
@see \Drupal\Core\Theme\Component\ComponentMetadata
User interface changes
None.
Issue fork canvas-3503038
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:
Issue fork experience_builder-3503038
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
longwaveComment #3
larowlanComment #4
larowlanComment #6
longwaveMade a start on this.
Comment #7
wim leersI don't think this needs to be a stable blocker; XB at release won't yet allow additional
ComponentSourceInterfaceimplementations. Which means this would be an entirely internal refactor?Comment #8
wim leersComment #9
larowlanThe fact we had to pretend this exists in the fallback plugin makes me feel it is a stable blocker.
I know @mohit_aghera has a pinto component source plugin that is also grappling with this.
Comment #10
larowlanAdding back tag until the conversation above is resolved (we can always remove it again, just want to make sure it's not lost)
Comment #11
wim leersI think this is less urgent.
Comment #12
larowlanTagging for colleagues as this is a bug bear for the Pinto work Mohit has been doing
Comment #14
wim leersThanks, @mohit_aghera, for pushing this forward! 🥳🙏
Comment #15
effulgentsia commentedI read #10, but I don't think this is a stable blocker. We'd be happy to merge this once it's ready though, so by untagging it I have no desire to slow this issue down.
For XB, the definition of stable is different than core's. We'll be adding @internal to almost everything and relaxing that in 1.x minor releases. The main goal of an XB stable release is to unblock a Drupal CMS 2.0 stable release, allowing people/agencies to build and deploy real sites with that. But XB 1.0.0 won't yet have a proper PHP API surface for contrib projects to perform more advanced integrations than what DCMS 2 exercises, except to the extent that issues like this one just happen to get done ahead of a 1.0.0 release.
Comment #16
wim leersThis is going to block #3541000: [META] Content templates UI for 1.0: only nodes, no exposed slots, no replacement for the view mode/display UI, and #3510896: Add a new internal HTTP API for candidate `DynamicPropSource`s to enable a `ContentTemplate` UI made it very apparent 😅
Quoting
\Drupal\Tests\experience_builder\Functional\ApiUiContentTemplateControllersTest::testSuggestionsClientErrors():So, starting point:
Comment #17
f.mazeikis commentedComment #20
f.mazeikis commentedComment #23
wim leersGreat work, Felix! 😊
Docs added as suggested in the issue summary ~8 months ago, adjusted & merged 👍
This unblocks #3541000: [META] Content templates UI for 1.0: only nodes, no exposed slots, no replacement for the view mode/display UI.
Unpostponed #3513589: [upstream] Decouple GeneratedFieldExplicitInputUxComponentSourceBase from SDC plugins.