Add a UI for disabling custom blocks per content type

Created on 19 December 2022, almost 2 years ago
Updated 23 January 2024, 10 months ago

Problem/Motivation

A site might have multiple Gutenberg enabled content types. To keep the complexity low for the content producers, I want to limit the available custom blocks per content type.

Proposed resolution

There is already a UI to disable/enable blocks coming from Gutenberg core and Drupal. We could have the same kind of fieldset for custom blocks.

Feature request
Status

Needs work

Version

2.8

Component

Code

Created by

🇳🇴Norway perandre

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

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

  • Status changed to Needs work over 1 year ago
  • 🇵🇹Portugal marcofernandes

    There should be a condition to check if there are custom settings.

    --->
          foreach ($custom_settings['categories'] as $category) {
            $category['reference'] = str_replace('/', '-', $category['reference']);
            $form['gutenberg']['categories']['#default_value'][] = $category['reference'];
    
    
  • 🇵🇹Portugal marcofernandes

    Adding patch for 8.x-2.x-dev (works with 8.x-2.7).

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sundarraj.p

    this works for me kindly review it

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Build Successful
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • 🇮🇳India KalaiyarasiThangavel

    Hi,

    I have added a new patch here..This works for me. Kindly review it.

  • 🇺🇸United States alison

    I tried applying the changes in commit #a91193b to my site, running Gutenberg 2.7.0, and the patch applied fine, but I don't have any checkboxes for my custom Gutenberg blocks on the content type settings form.

    (Is it still in-progress, that's all, or?)

    Thank you!

  • Pipeline finished with Canceled
    about 1 year ago
    Total: 133s
    #26573
  • Pipeline finished with Canceled
    about 1 year ago
    Total: 57s
    #26575
  • Status changed to Fixed about 1 year ago
  • 🇵🇹Portugal marcofernandes

    Already working on dev and released on 2.8. Closing.

  • Status changed to Needs review about 1 year ago
  • 🇳🇴Norway vegardjo

    Hi guys, as with Alison I'm not quite getting this. I have upgraded on an existing site + a vanilla d10, and I have no UI for custom modules. On my vanilla I have installed this custom block which I would expect to find in the UI:

    const settings = {
      title: __('Factbox'),
      description: __('Block with title and content that can be aligned'),
      icon: 'info-outline',
      attributes: {
        title: {
          type: 'string',
        },
        alignment: {
          type: 'string',
          default: 'full'
        }
      },
    
      edit({ attributes, setAttributes }) { ... }
      save({ attributes, setAttributes }) { ... }
    }
    
    const category = {
      slug: 'text',
      title: __('Text'),
    };
    
    registerBlockType(`${category.slug}/gb-factbox`, { category: category.slug, ...settings });
     
    
    

  • Status changed to Needs work about 1 year ago
  • 🇵🇹Portugal marcofernandes

    We need documentation for this 😅

    Currently we don't have "auto-discovery" for custom blocks so in order to be able to manage custom blocks availability, at [theme].gutenberg.yml settings file, you need to add the custom-blocks section, for example:

    custom-blocks:
      categories:
        - reference: text
          name: Text
          blocks:
            - id: text/gb-factbox
              name: Factbox
        - reference: media
          name: Media
          blocks:
            - id: media/some-custom-media-block
              name: My Media
    
    

    Note about blocks auto-discovery: This needs to be done at server level and the idea is to use a json (or yaml) file to define block's metadata like WordPress does.

    Leaving this open (Needs work) until we get documentation.

  • 🇳🇴Norway vegardjo

    I updated the documentation for this at https://www.drupal.org/docs/contributed-modules/gutenberg/gutenberg-bloc...

    I also updated the title, but the navigation link in the sidebar to it needs to be updated accordingly, and seems a documentation maintainer would have to do that.

    However, adding this also results in a php warning per custom block you add, at /admin/structure/types/manage/[bundle], so I believe this should also be fixed before we can close this.

    Warning: Undefined array key "default" in {closure}() (line 303 of modules/contrib/gutenberg/gutenberg.module).
    {closure}(Array)
    array_map(Object, Array) (Line: 305)
    gutenberg_form_alter(Array, Object, 'node_type_edit_form') (Line: 545)
    Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_type_edit_form') (Line: 840)
    Drupal\Core\Form\FormBuilder->prepareForm('node_type_edit_form', Array, Object) (Line: 284)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
  • Merge request !99Issue #3328033: Add check → (Merged) created by marcofernandes
  • Pipeline finished with Success
    10 months ago
    #81497
  • Pipeline finished with Success
    10 months ago
    #81498
  • Pipeline finished with Success
    10 months ago
    #85080
  • Pipeline finished with Failed
    10 months ago
    #91154
  • Pipeline finished with Success
    10 months ago
    Total: 192s
    #91159
  • Pipeline finished with Success
    10 months ago
    #91336
  • Pipeline finished with Failed
    10 months ago
    #91349
  • Pipeline finished with Success
    10 months ago
    Total: 220s
    #91366
  • Pipeline finished with Success
    10 months ago
    #91374
  • Pipeline finished with Success
    10 months ago
    #91414
  • Pipeline finished with Success
    10 months ago
    Total: 161s
    #91440
  • Pipeline finished with Success
    10 months ago
    Total: 253s
    #91449
  • Pipeline finished with Failed
    9 months ago
    Total: 111s
    #99600
  • Pipeline finished with Failed
    9 months ago
    #100779
  • Pipeline finished with Failed
    9 months ago
    #103400
  • Pipeline finished with Failed
    9 months ago
    Total: 143s
    #106840
  • Pipeline finished with Failed
    6 months ago
    Total: 143s
    #183340
  • Pipeline finished with Success
    5 months ago
    Total: 760s
    #201387
  • Pipeline finished with Success
    5 months ago
    Total: 754s
    #201420
  • Pipeline finished with Success
    5 months ago
    Total: 247s
    #206076
  • Pipeline finished with Failed
    5 months ago
    Total: 145s
    #209822
  • Pipeline finished with Success
    5 months ago
    Total: 288s
    #211659
  • Pipeline finished with Canceled
    5 months ago
    Total: 69s
    #215667
  • Pipeline finished with Canceled
    4 months ago
    #225114
  • Pipeline finished with Success
    4 months ago
    Total: 148s
    #225492
  • Pipeline finished with Failed
    4 months ago
    #225927
  • Pipeline finished with Failed
    4 months ago
    Total: 247s
    #225939
  • Pipeline finished with Failed
    4 months ago
    Total: 316s
    #233604
  • Pipeline finished with Failed
    4 months ago
    Total: 136s
    #234686
  • Pipeline finished with Failed
    4 months ago
    #234689
  • Pipeline finished with Failed
    4 months ago
    Total: 274s
    #234729
  • Pipeline finished with Failed
    4 months ago
    Total: 137s
    #234774
  • Pipeline finished with Canceled
    4 months ago
    #234819
  • Pipeline finished with Success
    4 months ago
    Total: 140s
    #234827
  • Pipeline finished with Success
    4 months ago
    Total: 272s
    #236403
  • Pipeline finished with Failed
    4 months ago
    Total: 258s
    #236966
  • Pipeline finished with Failed
    4 months ago
    Total: 276s
    #236970
  • Pipeline finished with Canceled
    4 months ago
    Total: 137s
    #237028
  • Pipeline finished with Failed
    4 months ago
    Total: 266s
    #237032
  • Pipeline finished with Success
    4 months ago
    Total: 250s
    #237071
  • Pipeline finished with Success
    4 months ago
    Total: 192s
    #237572
  • Pipeline finished with Success
    4 months ago
    Total: 314s
    #238660
  • Pipeline finished with Success
    4 months ago
    Total: 301s
    #238667
  • Pipeline finished with Failed
    4 months ago
    Total: 291s
    #238757
  • Pipeline finished with Failed
    4 months ago
    Total: 661s
    #239870
  • Pipeline finished with Success
    4 months ago
    Total: 234s
    #240301
  • Pipeline finished with Success
    4 months ago
    Total: 205s
    #240342
  • Pipeline finished with Success
    4 months ago
    Total: 292s
    #240778
  • Pipeline finished with Failed
    4 months ago
    Total: 1269s
    #241904
  • Pipeline finished with Skipped
    4 months ago
    #242002
  • Pipeline finished with Failed
    4 months ago
    Total: 260s
    #244406
  • Pipeline finished with Success
    4 months ago
    Total: 357s
    #245816
  • Pipeline finished with Failed
    4 months ago
    Total: 141s
    #250194
  • Pipeline finished with Success
    4 months ago
    Total: 168s
    #250221
  • Pipeline finished with Success
    3 months ago
    Total: 208s
    #250949
  • Pipeline finished with Success
    3 months ago
    Total: 258s
    #255023
  • Pipeline finished with Failed
    3 months ago
    Total: 358s
    #267637
  • Pipeline finished with Failed
    3 months ago
    Total: 195s
    #267672
  • Pipeline finished with Failed
    3 months ago
    #267684
  • Pipeline finished with Failed
    3 months ago
    Total: 367s
    #268458
  • Pipeline finished with Failed
    3 months ago
    #268472
  • Pipeline finished with Failed
    3 months ago
    Total: 238s
    #268484
  • Pipeline finished with Failed
    3 months ago
    Total: 555s
    #274048
  • Pipeline finished with Failed
    3 months ago
    #274084
  • Pipeline finished with Failed
    3 months ago
    Total: 295s
    #275626
  • Pipeline finished with Failed
    3 months ago
    Total: 224s
    #276194
  • Pipeline finished with Success
    3 months ago
    Total: 227s
    #276258
  • Pipeline finished with Success
    3 months ago
    Total: 215s
    #276261
  • Pipeline finished with Success
    2 months ago
    Total: 330s
    #281677
  • Pipeline finished with Success
    2 months ago
    Total: 141s
    #286450
  • Pipeline finished with Failed
    2 months ago
    Total: 72s
    #287431
  • Pipeline finished with Failed
    2 months ago
    #287465
  • Pipeline finished with Success
    2 months ago
    Total: 176s
    #287467
  • Pipeline finished with Failed
    2 months ago
    Total: 640s
    #288457
  • Pipeline finished with Failed
    2 months ago
    Total: 142s
    #288476
  • Pipeline finished with Failed
    2 months ago
    Total: 594s
    #288479
  • Pipeline finished with Failed
    2 months ago
    Total: 271s
    #288525
  • Pipeline finished with Failed
    2 months ago
    Total: 602s
    #288531
  • Pipeline finished with Failed
    2 months ago
    Total: 535s
    #288536
  • Pipeline finished with Failed
    2 months ago
    Total: 364s
    #288544
  • Pipeline finished with Failed
    2 months ago
    Total: 846s
    #288553
  • Pipeline finished with Canceled
    2 months ago
    Total: 214s
    #288590
  • Pipeline finished with Canceled
    2 months ago
    Total: 627s
    #291627
  • Pipeline finished with Success
    2 months ago
    Total: 617s
    #291633
  • Pipeline finished with Success
    about 2 months ago
    Total: 265s
    #293238
  • Pipeline finished with Success
    about 1 month ago
    Total: 237s
    #313492
  • Pipeline finished with Failed
    about 1 month ago
    Total: 45s
    #314572
  • Pipeline finished with Failed
    about 1 month ago
    Total: 103s
    #314693
  • Pipeline finished with Success
    about 1 month ago
    Total: 181s
    #315167
  • Pipeline finished with Skipped
    about 1 month ago
    #317017
  • Pipeline finished with Success
    about 1 month ago
    Total: 299s
    #317931
  • Pipeline finished with Success
    about 1 month ago
    #321029
  • Pipeline finished with Canceled
    24 days ago
    Total: 67s
    #326242
  • Pipeline finished with Failed
    24 days ago
    Total: 574s
    #326243
  • Pipeline finished with Success
    24 days ago
    Total: 405s
    #326285
  • Pipeline finished with Failed
    22 days ago
    Total: 340s
    #327533
  • Pipeline finished with Failed
    6 days ago
    Total: 178s
    #342883
  • Pipeline finished with Failed
    6 days ago
    Total: 189s
    #342885
Production build 0.71.5 2024