Add a UI for disabling custom blocks per content type

Created on 19 December 2022, over 1 year ago
Updated 23 January 2024, 5 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 about 1 year ago
    Build Successful
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 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
    9 months ago
    Total: 133s
    #26573
  • Pipeline finished with Canceled
    9 months ago
    Total: 57s
    #26575
  • Pipeline finished with Canceled
    9 months ago
    Total: 52s
    #26580
  • Pipeline finished with Success
    9 months ago
    Total: 460s
    #26581
  • Status changed to Fixed 8 months ago
  • 🇵🇹Portugal marcofernandes

    Already working on dev and released on 2.8. Closing.

  • Status changed to Needs review 8 months 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 8 months 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
    5 months ago
    #81494
  • Pipeline finished with Success
    5 months ago
    #81497
  • Pipeline finished with Success
    5 months ago
    #81498
  • Pipeline finished with Success
    5 months ago
    #81500
  • Pipeline finished with Success
    5 months ago
    Total: 3176s
    #84458
  • Pipeline finished with Success
    5 months ago
    #85080
  • Pipeline finished with Canceled
    5 months ago
    Total: 184s
    #85520
  • Pipeline finished with Success
    5 months ago
    Total: 651s
    #85523
  • Pipeline finished with Skipped
    5 months ago
    #86466
  • Pipeline finished with Failed
    5 months ago
    #91154
  • Pipeline finished with Success
    5 months ago
    Total: 192s
    #91159
  • Pipeline finished with Success
    5 months ago
    #91336
  • Pipeline finished with Failed
    5 months ago
    #91349
  • Pipeline finished with Success
    5 months ago
    Total: 220s
    #91366
  • Pipeline finished with Success
    5 months ago
    #91374
  • Pipeline finished with Success
    5 months ago
    #91385
  • Pipeline finished with Success
    5 months ago
    #91414
  • Pipeline finished with Success
    5 months ago
    Total: 161s
    #91440
  • Pipeline finished with Success
    5 months ago
    Total: 253s
    #91449
  • Pipeline finished with Success
    4 months ago
    Total: 855s
    #93233
  • Pipeline finished with Success
    4 months ago
    #93267
  • Pipeline finished with Skipped
    4 months ago
    #93300
  • Pipeline finished with Success
    4 months ago
    Total: 211s
    #93978
  • Pipeline finished with Success
    4 months ago
    Total: 184s
    #94007
  • Pipeline finished with Success
    4 months ago
    Total: 233s
    #94015
  • Pipeline finished with Success
    4 months ago
    Total: 184s
    #98532
  • Pipeline finished with Success
    4 months ago
    Total: 191s
    #98539
  • Pipeline finished with Failed
    4 months ago
    Total: 111s
    #99600
  • Pipeline finished with Failed
    4 months ago
    #100779
  • Pipeline finished with Failed
    4 months ago
    Total: 176s
    #101410
  • Pipeline finished with Failed
    4 months ago
    #103400
  • Pipeline finished with Failed
    4 months ago
    #103405
  • Pipeline finished with Failed
    4 months ago
    #103495
  • Pipeline finished with Failed
    4 months ago
    Total: 143s
    #106840
  • Pipeline finished with Failed
    4 months ago
    Total: 129s
    #110906
  • Pipeline finished with Failed
    4 months ago
    Total: 209s
    #113739
  • Pipeline finished with Success
    3 months ago
    Total: 148s
    #138591
  • Pipeline finished with Success
    3 months ago
    Total: 211s
    #138630
  • Pipeline finished with Success
    3 months ago
    Total: 409s
    #142188
  • Pipeline finished with Failed
    3 months ago
    Total: 174s
    #143003
  • Pipeline finished with Failed
    3 months ago
    Total: 146s
    #144015
  • Pipeline finished with Failed
    about 1 month ago
    Total: 276s
    #171903
  • Pipeline finished with Failed
    about 1 month ago
    Total: 172s
    #171906
  • Pipeline finished with Failed
    30 days ago
    Total: 143s
    #183340
  • Pipeline finished with Success
    8 days ago
    Total: 760s
    #201387
  • Pipeline finished with Success
    8 days ago
    #201404
  • Pipeline finished with Success
    8 days ago
    Total: 754s
    #201420
Production build 0.69.0 2024