Add a UI for disabling custom blocks per content type

Created on 19 December 2022, about 2 years ago
Updated 23 January 2024, 12 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 almost 2 years 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 almost 2 years 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 Success
    over 1 year ago
    Total: 460s
    #26581
  • 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
    12 months ago
    #81494
  • Pipeline finished with Success
    12 months ago
    #81500
  • Pipeline finished with Success
    12 months ago
    Total: 3176s
    #84458
  • Pipeline finished with Canceled
    12 months ago
    Total: 184s
    #85520
  • Pipeline finished with Success
    12 months ago
    Total: 651s
    #85523
  • Pipeline finished with Skipped
    12 months ago
    #86466
  • Pipeline finished with Success
    11 months ago
    Total: 192s
    #91159
  • Pipeline finished with Success
    11 months ago
    Total: 855s
    #93233
  • Pipeline finished with Skipped
    11 months ago
    #93300
  • Pipeline finished with Success
    11 months ago
    Total: 211s
    #93978
  • Pipeline finished with Success
    11 months ago
    Total: 233s
    #94015
  • Pipeline finished with Success
    11 months ago
    Total: 184s
    #98532
  • Pipeline finished with Failed
    11 months ago
    Total: 176s
    #101410
  • Pipeline finished with Failed
    11 months ago
    #103405
  • Pipeline finished with Failed
    11 months ago
    Total: 129s
    #110906
  • Pipeline finished with Failed
    11 months ago
    Total: 209s
    #113739
  • Pipeline finished with Success
    10 months ago
    Total: 148s
    #138591
  • Pipeline finished with Success
    10 months ago
    Total: 211s
    #138630
  • Pipeline finished with Success
    9 months ago
    Total: 409s
    #142188
  • Pipeline finished with Failed
    9 months ago
    Total: 174s
    #143003
  • Pipeline finished with Failed
    9 months ago
    Total: 146s
    #144015
  • Pipeline finished with Failed
    8 months ago
    Total: 276s
    #171903
  • Pipeline finished with Failed
    8 months ago
    Total: 172s
    #171906
  • Pipeline finished with Failed
    7 months ago
    Total: 141s
    #210473
  • Pipeline finished with Success
    7 months ago
    Total: 239s
    #215689
  • Pipeline finished with Success
    6 months ago
    Total: 341s
    #221375
  • Pipeline finished with Failed
    6 months ago
    Total: 327s
    #227198
  • Pipeline finished with Failed
    6 months ago
    Total: 256s
    #228731
  • Pipeline finished with Failed
    6 months ago
    Total: 320s
    #228894
  • Pipeline finished with Failed
    6 months ago
    Total: 222s
    #233619
  • Pipeline finished with Failed
    6 months ago
    Total: 279s
    #234576
  • Pipeline finished with Failed
    6 months ago
    Total: 131s
    #234688
  • Pipeline finished with Failed
    6 months ago
    #234694
  • Pipeline finished with Failed
    6 months ago
    Total: 151s
    #234768
  • Pipeline finished with Failed
    6 months ago
    #234790
  • Pipeline finished with Success
    6 months ago
    Total: 136s
    #234813
  • Pipeline finished with Success
    6 months ago
    Total: 137s
    #234823
  • Pipeline finished with Success
    6 months ago
    Total: 196s
    #234829
  • Pipeline finished with Canceled
    6 months ago
    Total: 68s
    #236965
  • Pipeline finished with Success
    6 months ago
    Total: 254s
    #237056
  • Pipeline finished with Success
    6 months ago
    Total: 350s
    #237298
  • Pipeline finished with Failed
    6 months ago
    Total: 273s
    #238655
  • Pipeline finished with Failed
    6 months ago
    Total: 415s
    #238920
  • Pipeline finished with Success
    6 months ago
    Total: 254s
    #239857
  • Pipeline finished with Success
    6 months ago
    Total: 977s
    #239913
  • Pipeline finished with Success
    6 months ago
    Total: 253s
    #240851
  • Pipeline finished with Failed
    6 months ago
    Total: 268s
    #241817
  • Pipeline finished with Success
    6 months ago
    Total: 422s
    #241816
  • Pipeline finished with Success
    6 months ago
    Total: 203s
    #241876
  • Pipeline finished with Failed
    6 months ago
    Total: 280s
    #241880
  • Pipeline finished with Success
    6 months ago
    Total: 295s
    #241999
  • Pipeline finished with Success
    6 months ago
    Total: 274s
    #242184
  • Pipeline finished with Failed
    5 months ago
    Total: 364s
    #244451
  • Pipeline finished with Success
    5 months ago
    #250219
  • Pipeline finished with Success
    5 months ago
    Total: 141s
    #250225
  • Pipeline finished with Canceled
    5 months ago
    Total: 381s
    #256251
  • Pipeline finished with Success
    5 months ago
    Total: 1517s
    #256254
  • Pipeline finished with Failed
    5 months ago
    Total: 389s
    #267625
  • Pipeline finished with Canceled
    5 months ago
    Total: 91s
    #267636
  • Pipeline finished with Failed
    5 months ago
    Total: 358s
    #267637
  • Pipeline finished with Success
    5 months ago
    Total: 387s
    #267683
  • Pipeline finished with Failed
    4 months ago
    Total: 529s
    #274072
  • Pipeline finished with Failed
    4 months ago
    Total: 196s
    #274104
  • Pipeline finished with Failed
    4 months ago
    Total: 1189s
    #276216
  • Pipeline finished with Failed
    4 months ago
    Total: 243s
    #276242
  • Pipeline finished with Failed
    4 months ago
    Total: 218s
    #281665
  • Pipeline finished with Success
    4 months ago
    Total: 1314s
    #281723
  • Pipeline finished with Success
    4 months ago
    Total: 170s
    #286564
  • Pipeline finished with Success
    4 months ago
    Total: 170s
    #287402
  • Pipeline finished with Failed
    4 months ago
    Total: 84s
    #287409
  • Pipeline finished with Failed
    4 months ago
    Total: 112s
    #287445
  • Pipeline finished with Failed
    4 months ago
    Total: 113s
    #287449
  • Pipeline finished with Success
    4 months ago
    Total: 176s
    #287467
  • Pipeline finished with Canceled
    4 months ago
    Total: 237s
    #288453
  • Pipeline finished with Failed
    4 months ago
    Total: 541s
    #288471
  • Pipeline finished with Failed
    4 months ago
    Total: 575s
    #288560
  • Pipeline finished with Failed
    4 months ago
    Total: 565s
    #288571
  • Pipeline finished with Canceled
    4 months ago
    Total: 163s
    #288579
  • Pipeline finished with Failed
    4 months ago
    Total: 597s
    #288581
  • Pipeline finished with Failed
    4 months ago
    Total: 646s
    #288592
  • Pipeline finished with Success
    4 months ago
    Total: 705s
    #288596
  • Pipeline finished with Canceled
    4 months ago
    Total: 479s
    #289912
  • Pipeline finished with Success
    4 months ago
    Total: 647s
    #289918
  • Pipeline finished with Canceled
    4 months ago
    Total: 627s
    #291627
  • Pipeline finished with Success
    4 months ago
    Total: 1367s
    #291652
  • Pipeline finished with Success
    4 months ago
    Total: 227s
    #300158
  • Pipeline finished with Skipped
    3 months ago
    #312629
  • Pipeline finished with Skipped
    3 months ago
    #312633
  • Pipeline finished with Success
    3 months ago
    Total: 353s
    #313526
  • Pipeline finished with Failed
    3 months ago
    Total: 263s
    #314039
  • Pipeline finished with Failed
    3 months ago
    Total: 311s
    #314057
  • Pipeline finished with Success
    3 months ago
    Total: 235s
    #314071
  • Pipeline finished with Success
    3 months ago
    Total: 361s
    #315105
  • Pipeline finished with Success
    3 months ago
    Total: 170s
    #315162
  • Pipeline finished with Success
    3 months ago
    Total: 273s
    #316350
  • Pipeline finished with Success
    3 months ago
    Total: 194s
    #317936
  • Pipeline finished with Canceled
    3 months ago
    Total: 117s
    #326284
  • Pipeline finished with Success
    about 1 month ago
    Total: 2254s
    #367942
  • Pipeline finished with Success
    about 1 month ago
    Total: 978s
    #370483
Production build 0.71.5 2024