Allow to toggle between allow-list and block-list

Created on 3 July 2023, 12 months ago
Updated 4 July 2023, 12 months ago

Problem/Motivation

Paragraphs has that great features where you can block all of the selected bundles (block-list) OR allow only the selected bundle (allow-list). This feature is extremly helpful because the configuration burden grows for this module exponentially with layouts * regions * paragraphs.

In my projects I often have frequently have both opposing use cases:

  1. On special layout A region alpha I want to disallow everyting except X1 and X2
    (and when new paragraph bundles are added, I want them blocked by default, without having to update the layout paragraphs limit config - this is what I'm missing)
  2. On special layout B region beta I want to allow everything except Y1 and Y2
    (and when new paragraph bundles are added, I want them allowed by default, without having to update the layout paragraphs limit config - this is how it currently works)

Proposed resolution

Add a new boolean config setting negate per region to toggle between allow-list and block-list. Move the bundles selection one level below

layout_pagrapahs_limit.settings.yml

disallowed_types:
  layout_a:
    region_alpha:
      negate: 1
      paragraph_types:
        bundle_x1: bundle_x1
        bundle_x2: bundle_x2
  layout_b:
    region_beta:
      negate: 0
      paragraph_types:
        bundle_x1: bundle_x1
        bundle_x2: bundle_x2

By default (empty or false) it acts like an *"allow everything"* list (case 2).

The proposed config schema tries to minimize changes to the current dev branch, the name/schema negateis used by Paragraphs module in field settings. The naming might not be ideal due the double negative logic (disallowed types => negate), but I went along the road that meant the least friction to existing codebase and config.

User interface changes

Add a boolean toggle inside each region, above the bundle selection

Data structure changes

Yes, config schema requires changes, see proposed resolution

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇹Austria hudri Austria

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

Comments & Activities

Production build 0.69.0 2024