LayoutBuilderRestriction\EntityViewModeRestriction::inlineBlocksAllowedinContext doesn't check if the section storage is a view_display

Created on 2 December 2024, 16 days ago

Problem/motivation

\Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityViewModeRestriction::inlineBlocksAllowedinContext is called with a null display view for any section storage that isn't a view mode.

Steps to reproduce

  1. Enable layout_builder_restrictions and configure for view modes
  2. Install dashboard module (thas provides a section storage)
  3. Try to add a block to a dashboard, it will fail

Proposed resolution

layout_builder_restrictions has a global config for Layout Builder Restriction plugins, but can't be configured per section storage.
We would need to:
* Provide a way to configure that per section storage (e.g. view modes, dashboard, you name it)
* Add an appliesTo(SectionStorage $section_storage) to the plugin definitions.
* Each plugin needs to check it's applying to the proper section storage that it could apply (e.g. if !isset(display_view) => return).

This module uses Gitlab CI for automated testing of proposed code changes. To contribute code changes, create a merge request. Patch files will not trigger automated testing and are not sufficient for review.
πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

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

Comments & Activities

  • Issue created by @penyaskito
  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    Thanks for reporting this, @penyaskito. We do have test coverage for integration with the Dashboards module (see DashboardsIntegrationTest.php), and I just tested this using the latest version of Drupal 10 with Dashboards 2.1.7, and was able to successfully add blocks to a Dashboard, so I'm probably doing different steps than you provided. Here's my annotated version of the steps to reproduce, as originally stated.

    1. Enable layout_builder_restrictions and configure for view modes. Enabled. On /admin/config/content/layout-builder-restrictions , the "Entity View Mode" plugin is enabled.
    2. Install dashboard module (thas provides a section storage). installed. On /admin/config/content/layout-builder-restrictions, now the "Dashboards View Mode" plugin is enabled (automatically).
    3. Try to add a block to a dashboard, it will fail. On /admin/structure/dashboards/add , I create a new dashboard, and use the Block restrictions to suppress Views blocks. I save. I click "Personalize". I see the Layout Builder interface. I successfully add a Section. I try to add a Block. I see that there are no Views blocks listed. I successfully add the Dashboard-provided "Add content" block.
  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson
Production build 0.71.5 2024