Problem/Motivation

The action link 'Add custom block' on the Block layout page takes the user to empty page when there are no custom block types available, for example when using the minimal install profile.

Proposed resolution

When no custom block types are available, present an 'empty text' with a link to the block creation page.

Remaining tasks

  1. Write a patch
  2. Review

User interface changes

The page on /block/add shows an empty text and link to the custom block type creation page when no custom block types are available.

API changes

None

Original report by @sachbearbeiter

Referring to https://www.drupal.org/node/2350265

We both have the problem, that in our D8 installations "Add Custom Block" functionality is not working like desired.
The page http://foo.com/block/add is loaded empty.

Comparing with another test page (where it is working properly):

The log of the non working installation is listing really often:

Type filter
Message Missing filter plugin: filter_null.
Severity Alert

+ i did a minimal install here initially ...

does somebody has an idea?

regards sb

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it does not resolve any bugs or add any new features
Issue priority Normal because it does not affect any major systems
Unfrozen changes Unfrozen because it only changes markup
Prioritized changes The main goal of this issue is usability.
Disruption Not disruptive
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sachbearbeiter’s picture

Title: Add "Custom Block" it takes me to an empty Drupal page » "Add Custom Block" takes me to an empty Drupal page
dawehner’s picture

The problem is that you don't have any custom block types configured by default, see admin/structure/block/block-content/types

Afaik we should, similarily to the node types page (node/add) tell the user in case there are none defined.

sachbearbeiter’s picture

ahh - i see - stupid by me - sorry ...
please feel free to close or to modify the title and issue metadata as a task ...

thanks a lot for the fast reply

dawehner’s picture

@sachbearbeiter
Well I think you could provide such a fix for the block/add page ... having some short help text there is useful, no question.

larowlan’s picture

Issue tags: +Needs tests
mshaver’s picture

FileSize
898 bytes

Here is a patch to add the text to the twig file. I'll open an issue to have this added to seven as well.

larowlan’s picture

Please do it here too, no need for two issues

larowlan’s picture

Status: Active » Needs review
Issue tags: -Needs tests
FileSize
2.83 KB
3.98 KB

Hi, the fix belongs in the controller, themes should need to worry about this kind of logic.
New patch, no interdiff - new approach.

The last submitted patch, 8: block-add.fail_.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 8: block-add.pass_.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
1.79 KB
5.14 KB
larowlan’s picture

FileSize
3.43 KB
5.08 KB

some things berdir pointed out

Berdir’s picture

  1. +++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php
    @@ -98,4 +105,13 @@ protected function createBlockContentType($label) {
    +  protected function createInitialBlockType() {
    

    Instead of initial, I'm wondering if "default" or "basic" (because that is how the block type is named) would be a better name.

    Also, note that drupalCreateContentType() creates the body field by default, wondering if we'd want that here as well, then we would not even need the helper method?

  2. +++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php
    @@ -98,4 +105,13 @@ protected function createBlockContentType($label) {
    +    // Ensure the basic bundle exists. This is provided by the standard profile.
    

    As discussed, the standard profile reference seems not helpful to me, I don't know what that is trying to say me.

  3. +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php
    @@ -33,18 +33,31 @@ class BlockContentTypeTest extends BlockContentTestBase {
    +    $this->assertText('You have not created any block types yet');
    

    I'm not sure anymore when we should use t() exactly and when not. Usually, I think we still use it when testing strings that were passed through t(), but it doesn't really matter as it's not the same string anyway.

webchick’s picture

Component: custom_block.module » block_content.module
larowlan’s picture

FileSize
3.54 KB
6.02 KB

Fixes #13

Status: Needs review » Needs work

The last submitted patch, 15: block-add.15.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
5.88 KB

reroll

Status: Needs review » Needs work

The last submitted patch, 17: block-add.17.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
5.88 KB

Not sure what I'm doing wrong here

Status: Needs review » Needs work

The last submitted patch, 19: block-add.19.patch, failed testing.

larowlan’s picture

Version: 8.0.0-beta4 » 8.0.x-dev
Status: Needs work » Needs review

neclimdul+1000

larowlan queued 19: block-add.19.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 19: block-add.19.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
584 bytes
5.89 KB

doh

Status: Needs review » Needs work

The last submitted patch, 24: block-add.21.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
599 bytes
5.9 KB

doh^2

larowlan queued 26: block-add.23.patch for re-testing.

idebr’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
4.74 KB
67.38 KB
5.9 KB

Thanks @larowlan, I did a manual test to confirm the message is displayed when no custom block types are available.

I have split the patch with a tests-only edition; the patch file has no changes compared to #25.

Annotated screenshot to show the new behavior:

idebr’s picture

Title: "Add Custom Block" takes me to an empty Drupal page » Add an empty text on "Add Custom Block" page when no custom block types are available
Issue summary: View changes

I updated the issue summary to reflect the changes in the patch and included a beta evaluation.

The last submitted patch, 28: 2403105-28.fail_.patch, failed testing.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 834c5a2 and pushed to 8.0.x. Thanks!

Thank you for adding the beta evaluation to the issue summary.

  • alexpott committed 834c5a2 on 8.0.x
    Issue #2403105 by larowlan, idebr, mshaver: Add an empty text on "Add...

Status: Fixed » Closed (fixed)

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