- Issue created by @pdureau
Pattern Presets conditions of availability in the "Pattern library" panel have not been properly implemented yet, so we see in this panel presets we are not supposed to have access.
We need to make patterns available if the contexts of the sources stored in the pattern are compatible with the contexts of the current display builder.
For example, a pattern with 'field:node:article:title'
must not be avaialble if the entity context is missing.
A pattern with view_rows
source, must not be avaialble outside of a View context. And so on...
There is a "theme" property in the config:
id: 68679ab4e1797
label: "My button with a title"
description: ""
group: ""
theme: usb_sub
sources: [...]
Is it used somewhere? If we want to make the preset available only if the theme used when creating the pattern preset is activated, do we replace this "theme" condition by the standard config dependency mechanism of Drupal?
Maybe we don't want to check against the active theme when created, but according to the SDC plugin providers?
For example, from this:
sources:
source_id: component
source:
component:
component_id: 'ui_suite_bootstrap:button'
variant_id:
source_id: select
source:
value: primary__sm
props: { }
slots: {}
We get this:
dependencies:
theme:
- ui_suite_bootstrap
Source plugins are already implementing DependentPluginInterface::calculateDependencies
so if the component provider is not calculated like that, it may be en UI Patterns 2 issue.
While you are working on this subject, can you also fix the "source" storage which is a string instead of a list.
Current:
id: 68679ab4e1797
label: 'My button with a title'
sources: "source_id: component\r\nsource:\r\n component:\r\n component_id: 'ui_suite_bootstrap:button'\r\n variant_id:\r\n source_id: select\r\n source:\r\n value: primary__sm\r\n props: { }\r\n slots:\r\n label:\r\n sources:\r\n -\r\n source_id: entity_field\r\n source:\r\n derivable_context: 'field:node:article:title'\r\n 'field:node:article:title':\r\n value:\r\n sources:\r\n -\r\n source_id: 'field_formatter:node:article:title'\r\n source:\r\n type: string\r\n settings:\r\n link_to_entity: 0\r\n _weight: '0'\r\n"
Target:
id: 68679ab4e1797
label: 'My button with a title'
sources:
source_id: component
source:
component:
component_id: 'ui_suite_bootstrap:button'
variant_id:
source_id: select
source:
value: primary__sm
props: { }
slots:
label:
sources:
- source_id: entity_field
source:
derivable_context: 'field:node:article:title'
'field:node:article:title':
value:
sources:
- source_id: 'field_formatter:node:article:title'
source:
type: string
settings:
link_to_entity: 0
_weight: '0'
Active
1.0
Pattern presets