Problem/Motivation
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.
This task will be done #3540610: Context management for Pattern presets but we need to do a few clean-ups before.
Proposed resolution
Theme dependency
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.
Also: fix the source storage
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'
Issue fork display_builder-3534190
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
pdureau commentedComment #3
pdureau commentedMoved to alpha4 because we need #3534579: Align source contexts before
Comment #4
pdureau commented2 little other tasks:
ConfigFormBuilderInterface::SOURCES_PROPERTYComment #5
pdureau commentedI will also remove the unused Form\DisplayBuilderDeleteForm
Comment #6
pdureau commentedWork in progress.
Current status:
Finally, we don't do "Use ConfigFormBuilderInterface::SOURCES_PROPERTY" because this is not the same as
WithDisplayBuilderInterface::getSources(): the root level is a single nestable source plugin instead of a list.Not directly related to PatternPreset:
Comment #8
pdureau commentedComment #9
pdureau commentedReady for review.
Warnings:
Comment #10
pdureau commentedOops, something more to check :)
Comment #11
pdureau commentedOK for review.
Now we have a proper dependencies management, when we uninstall a theme which is a dependency of a PatternPreset, the PatternPreset config entity is deleted.
Is it what we want? Do we prefer to block theme uninstallation instead?
Comment #13
mogtofu33 commentedComment #15
pdureau commentedJean, it seems some commits have disappeared when you merged this issue.
For example:
What happened? How can we restore them? How can we prevent this for the future?
Comment #16
mogtofu33 commentedDon't know, seems they've been written hover by #3538440: Merge island_settings & island_configuration in profiles.
Could you create a new branch here to add theme to current 1.0.X?
Comment #17
pdureau commentedSure. i will do it ASAP
Comment #19
pdureau commentedPushed: https://git.drupalcode.org/project/display_builder/-/merge_requests/76
I check if everything is still OK and i send to review
Comment #20
pdureau commentedOK for review
Comment #22
mogtofu33 commented