Auto-create/update Component config entities for all discovered SDCs that meet XB's minimum criteria

Created on 26 July 2024, about 1 month ago
Updated 30 August 2024, 9 days ago

Overview

Proposed in #3461499-17: Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings โ†’ , +1'd by @lauriii in #19 of that issue.

๐Ÿ›‘ Blocked on ๐Ÿ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed .

For a while now, @lauriii had expressed concerns about the whole "opting components in" UX (even though this was what we decided early on). Only now we're sufficiently confident that we can do without this, based on:

  1. what ๐Ÿ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed proved to be possible
  2. ๐Ÿ“Œ [SPIKE] Comprehensive plan for integrating with SDC Needs work becoming gradually more clear, and especially @lauriii specifying that it's okay for XB to only allow SDCs that define >=1 example for every required prop, and accepting that this has consequences for per-site default values ๐Ÿ“Œ [SPIKE] Comprehensive plan for integrating with SDC Needs work

Combining the ability to compute field type + widget (point 1 above) and default value (point 2 above) means that the crucial information that the Component config entity used to gather, no longer needs to be gathered.

Proposed resolution

  1. Automatically generate Component config entities for all SDCs that meet the requirements, upon:
    1. Module installation
    2. Theme installation
    3. Clearing all caches
    4. Bonus/optionally: on every request if is enabled at /admin/config/development/settings
  2. For now those criteria are simple:
    1. every required prop must have >=1 example.
    2. every prop (optional or required) must have a title โ†’ surfaced by ๐Ÿ“Œ Follow-up for #3461422: display SDC prop's human-readable name (`title`), not its machine name Needs review

    (Future criteria: SDC's status must/must not be a certain value, enum values must have labels, etc.)

  3. Use the exact same Component config entity that exists today, so including populating the following:
    defaults:
      props:
        <prop name>:
          field_type: โ€ฆ
          field_widget: โ€ฆ
          default_value: โ€ฆ
          expression: โ€ฆ
    

    (this enables ๐Ÿ“Œ [PP-2] Add ComponentAuditabilityTest Active )

  4. When: unfortunately, \Drupal\Core\Theme\ComponentPluginManager does not specify a cache tag. So, we have no way of knowing when it discovers new SDCs ๐Ÿ˜ฌ
  5. Work-around: decorate that service, pass everything through, but decorate getDefinitions(). Call the decorated method first, and compare the discovered definitions with those that have Component config entities already. Any that meet the requirements but do not yet have a Component config entity, get a Component config entity.
    (Q: Why ::getDefinitions() and not getAllComponents()? A: because then we avoid instantiating all SDC plugins. But if the latter is simpler for now, then just go for that. Actually, maybe that's acceptable because sdc_library_info_build() calls it too, and a module getting installed would rebuild libraries anyway.)
  6. Delete all experience_builder.component.*.yml files from the codebase โ€” these should be auto-generated now! (This might require some shenanigans/fiddling in tests, especially in kernel tests.)

User interface changes

None โ€” other than /admin/structure/component maybe having more things listed :)

๐Ÿ“Œ Task
Status

Fixed

Component

Config management

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024