Overview

When I started onboarding with Experience Builder, I found the terminology of "component source" quite confusing. I asked the rest of the XB team if they had ever considered "component type" as the term of choice for this concept.

As it happens, they very much had. The discussion happened in #3475584: Add support for Blocks as Components and #3454519-10: [META] Support component types other than SDC, block, and code components, where @larowlan came up with the name of "component source" (even earlier discussion in #3454519: [META] Support component types other than SDC, block, and code components leaned towards "component type"). But coming to it fresh, these folks said (in Slack) that they don't feel strongly about "component source" vs. "component type".

To be clear, this isn't critical; I don't feel strongly enough about it either to push too hard on this. But ComponentSource calls MediaSource to mind, which is a dramatically different concept (in my mind, media comes from somewhere...components are just there but have different abilities and powers). XB chose the term "source" because of the idea that, to XB, all components are treated basically the same way; the only thing that differs is what happens to power them in the backend. That does make sense.

And yet, ComponentSource plugins don't just provide components for XB to play with (although they do do that). They are also heavily referred to in the backend so that XB knows how to validate and interact with these components, and what their capabilities are. That feels more like a "type" -- i.e., what can this component do?

Opinions seem somewhat varied. @effulgentsia summed it up nicely:

My summary of the perspective difference between the words:

Source = how does the component come to exist within the site?

  • Block = provided by module via a PHP class with a Block PHP attribute
  • SDC = provided my module or theme via a YAML file
  • JS component = config entity

Type = what can the component do?

  • Block = run PHP code
  • SDC = not much (but that's not necessarily a bad thing for pure presentation components)
  • JS = leverage JS ecosystem (Tailwind, Radix, etc.)

Proposed resolution

  1. Decide on whether we want to stick with "component source" to describe this concept, or change to "component type".
  2. Consider all aspects that such a plugin is responsible for, and including them in the plugin API. For example, currently they do not include discovery, and they likely should (see #7, +1'd in #8, and came up again in #3547579-27: Introduce a new cache tags aware prop shape repository, so changes affecting prop shape calculation can force the re-invoke of hook_canvas_storable_shape_prop_alter).

User interface changes

None either way. This would be strictly an API change, if it happens.

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Issue summary: View changes
phenaproxima’s picture

I would like to mention one thing about ComponentSource sounding roughly like MediaSource: the reason MediaType plugins aren't a thing is because MediaType is a bundle config entity -- same idea as NodeType. I think that, if the media system didn't have bundle entities, MediaSource plugins would be named MediaType plugins.

XB, however, has nothing analogous to MediaType entities. So it should not necessarily be echoing Media's naming decisions here.

wim leers’s picture

danielveza’s picture

I don't feel strongly about this one. I'm a soft +1 for ComponentType. In a ComponentSource (using it's current name), nothing is actually being sourced from anywhere. At this point it's handling the render and data transformation layers for use inside XB. This makes it feel more like a type to me, and I think @effulgentsia points at the bottom of the IS outline this in a really clean way that makes sense to me.

At the moment we decocate cores plugin providers (BlockManager & ComponentPluginManager) to create/update XB component entities from existing plugins. We don't currently use any particular term or interface for these, but to me this is what should be considered a Component Source. Components are being sourced from another system like block or SDC currently, and LB and paragraphs in the future.

Naming is hard!

wim leers’s picture

Yep, Daniel hits the nail on the head: the sourcing does happen, and that’s why the name conceptually makes sense, but it happens outside the source plugin itself, which makes the name a bit off.

The thing is though, that depending on where the components are being sourced from (currently: 2 different plugin types, 1 config entity type, and later: anything), different implementations are needed. So truly having everything self-contained in the source plugin is AFAICT impossible.

But perhaps one of you has a genius insight for how to change that? 🤓

wim leers’s picture

Taking my last comment further: what if a component source plugin could declare the (forgive me) type of source discovery?

Similar to how an entity type plugin declares its access

And that that would then result in either

discovery = FromPluginManager::class,

Or from

discovery = FromConfigEntityStorage::class,

That’d help tie things together?

mohit_aghera’s picture

I don't have strong opinion on `ComponentType` vs `ComponentSource`.
However as non-native english speaker, I felt `ComponentSource` more convenient to realise that there are so x number of source plugin that allows XB component config entities to be created.

Regarding declaring source discovery:
Strong +1 from me.
I faced the issue while working on Pinto integration.
Since pinto object are standalone object, there was no easy way to identify and create Component config entities.
I'm relying on hook_cache_flush to refresh the list and generate new `Component` config entities.

So, having a separate class for discovery makes things easier for creating new ComponentSource plugins.

lauriii’s picture

wim leers’s picture

Note that stabilizing ComponentSource plugins as a public PHP API has been decided to be out of scope for 1.0, which is why #10 makes sense 👍

Project: Experience Builder » Drupal Canvas
Version: 0.x-dev » 1.x-dev

Experience Builder has been renamed to Drupal Canvas in preparation for its beta release. You can now track issues on the new project page.

wim leers’s picture

Title: Consider renaming ComponentSource plugins to ComponentType » Settle on final name for `ComponentSource` plugins (`ComponentType`?) + expand their scope (discovery, maybe more?)
Priority: Normal » Major
wim leers’s picture

wim leers’s picture

#3556327: Don't save `Component` config entities unnecessarily is in! That is a big step in the right direction. But much remains to be done.