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'
Command icon 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

pdureau created an issue. See original summary.

pdureau’s picture

pdureau’s picture

pdureau’s picture

Assigned: Unassigned » pdureau

2 little other tasks:

  • Use ConfigFormBuilderInterface::SOURCES_PROPERTY
  • Remove "Machine name" from /admin/structure/display-builder
pdureau’s picture

I will also remove the unused Form\DisplayBuilderDeleteForm

pdureau’s picture

Status: Active » Needs work

Work in progress.

Current status:

  • Context awareness: Moved to #3540610: Context management for Pattern presets
  • Replace theme by proper dependency management : ✅ DONE
  • Fix the source storage: ✅ DONE
  • Remove "Machine name" from /admin/structure/display-builder: ✅ DONE
  • Reorganize a bit the entity form: ✅ DONE

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:

  • Restore annotated_name because we are multi provider again
  • Remove the unused Form\DisplayBuilderDeleteForm: ✅ DONE

pdureau’s picture

Title: Context & dependency management for Pattern presets » Pattern presets storage and dependencies
Issue summary: View changes
pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs work » Needs review

Ready for review.

Warnings:

pdureau’s picture

Assigned: mogtofu33 » pdureau
Status: Needs review » Needs work

Oops, something more to check :)

pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs work » Needs review

OK 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?

mogtofu33 made their first commit to this issue’s fork.

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

  • mogtofu33 committed 19e6f7dc on 1.0.x authored by pdureau
    Issue #3534190 by pdureau: Pattern presets storage and dependencies
    
pdureau’s picture

Assigned: Unassigned » mogtofu33
Status: Fixed » Needs work

Jean, it seems some commits have disappeared when you merged this issue.

For example:

  • 22cb6215 - Restore annotated_name because we are multi provider again
  • 2a7d9827 - Some adjustments related to theme and 3rd party settings management

What happened? How can we restore them? How can we prevent this for the future?

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned

Don'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?

pdureau’s picture

Assigned: Unassigned » pdureau

Sure. i will do it ASAP

pdureau’s picture

Status: Needs work » Needs review

Pushed: https://git.drupalcode.org/project/display_builder/-/merge_requests/76

I check if everything is still OK and i send to review

pdureau’s picture

Assigned: pdureau » mogtofu33

OK for review

  • mogtofu33 committed 5de3ceb9 on 1.0.x authored by pdureau
    Issue #3534190 by pdureau: Pattern presets storage and dependencies
    
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.