Add missing paragraphs behavior settings schema

Created on 19 March 2024, 8 months ago
Updated 27 March 2024, 8 months ago

Problem/Motivation

Hello, and thanks for this wonderful module!

We are in the midst of updating all of our "internal" modules, and one of them is heavily reliant on your module. We are using predefined configs to import on module installation, and through this process, we picked up the missing schema definition for your behavior plugin!

See how other modules provide a schema definition for their paragraphs behavior plugin settings here: https://git.drupalcode.org/project/layout_paragraphs/-/blame/2.0.x/confi...

Steps to reproduce

  • Use the paragraphs behavior plugin this module provides.
  • Get "config_inspector" to see the missing schema definition.

Proposed resolution

Add missing paragraphs behavior settings schema.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

1.1

Component

Code

Created by

🇩🇪Germany Grevil

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

Merge Requests

Comments & Activities

  • Issue created by @Grevil
  • Status changed to Needs work 8 months ago
  • 🇩🇪Germany Grevil

    I took a first stab at this, the only problem now is, that the deepest sequence should support multiple types, not only "string".

    For us, we are using both boolean and integer, which isn't currently supported by this schema definition:

    Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for paragraphs.paragraphs_type.attachments with the following errors: paragraphs.paragraphs_type.attachments:behavior_plugins.ui_style_options.enabled_styles.spacing.spacing_horizontal_centering variable type is integer but applied schema class is Drupal\Core\TypedData\Plugin\DataType\StringData

  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks @Grevil!

    I think the first and general question is, if there's already a general schema concept from the maintainers. Did schema compliance play a role already and if yes, how should it be handled?
    Are there concepts in https://www.drupal.org/project/ui_styles perhaps?

    Might also make sense that @thomas.frobieter explains the general ui_styles concept to you to understand the real-world use case better and how it might be customized in projects.

  • 🇩🇪Germany Grevil

    I just took a quick look at the UI again and talked internally with @thomas.frobieter. The schema definition here is ALMOST correct the most inner sequence should only support boolean, as there can only be simple checkboxes enabling / disabling the specific ui_style. For some reason, our paragraphs_type ymls were incorrectly exported.

    This might be an issue related to the missing schema, or might lie somewhere else. See this excerpt from our broken config export:

    behavior_plugins:
      ui_style_options:
        enabled: true
        enabled_styles:
          spacing:
            spacing_margin_start: spacing_margin_start
            spacing_margin_top: spacing_margin_top
            spacing_margin_end: spacing_margin_end
            spacing_margin_bottom: spacing_margin_bottom
            spacing_horizontal_centering: 0
            spacing_padding: spacing_padding
            spacing_padding_start: spacing_padding_start
            spacing_padding_top: spacing_padding_top
            spacing_padding_end: spacing_padding_end
            spacing_padding_bottom: spacing_padding_bottom
            spacing_margin: 0
          display:
            display_all: 0
            display_print: 0
            display_large: display_large
            display_medium: display_medium
            display_small: display_small
            display_x_large: display_x_large
            display_xx_large: display_xx_large
    

    If the style is disabled it will use "0" as the value. If the style is enabled, it will simply use the key name as the value name.
    Instead, it should use FALSE / TRUE when enabled / disabled.

    I'll provide the correct schema definition now.

  • Status changed to Needs review 8 months ago
  • 🇩🇪Germany Grevil

    Done, please review!

  • 🇩🇪Germany Grevil

    For the maintainers, a quick comparison:

    A config export of a custom paragraphs_type "behavior_plugins" section without the schema applied:

    A config export of the same custom paragraphs_type "behavior_plugins" section with the schema patch applied:

  • Status changed to Needs work 8 months ago
  • 🇩🇪Germany Grevil

    Just had a quick look at the code. Apparently, there can also be styles without a group (see https://git.drupalcode.org/issue/ui_styles_paragraphs-3432164/-/blame/34...), these are currently stored in the config on the ui style group level. This wouldn't be compliant with the current schema definition, as "UI Style Group" can either be a sequence or the uncategorized style ID.

    Instead, we should store these in their own "Uncategorized" group, making the schema definition apply once again. Unfortunately, this would require further code adjustments and would introduce a breaking change (if no update hook would be supplied).

    Setting this back to needs work, maybe a maintainer could give their thoughts on this?

  • 🇩🇪Germany Anybody Porta Westfalica

    I can confirm this issue exists for all our entity types, where we're using ui_styles_paragraphs.

    config_inspector complains:

    behavior_plugins.ui_style_options.enabled_styles 	Undefined 	undefined 	No<array>
    
Production build 0.71.5 2024