Verified Commit 3fe287db authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3040348 by cboyden, tim.plunkett: Remove blocks that are not useful within Layout Builder

parent 3b44eb23
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -228,6 +228,13 @@ function layout_builder_cron() {
 * Implements hook_plugin_filter_TYPE__CONSUMER_alter().
 */
function layout_builder_plugin_filter_block__layout_builder_alter(array &$definitions, array $extra) {
  // Remove blocks that are not useful within Layout Builder.
  unset($definitions['system_messages_block']);
  unset($definitions['help_block']);
  unset($definitions['local_tasks_block']);
  unset($definitions['local_actions_block']);

  // Remove blocks that are non-functional within Layout Builder.
  unset($definitions['system_main_block']);
  // @todo Restore the page title block in https://www.drupal.org/node/2938129.
  unset($definitions['page_title_block']);
+4 −0
Original line number Diff line number Diff line
@@ -1004,6 +1004,10 @@ public function testLayoutBuilderChooseBlocksAlter() {
    $assert_session->linkNotExists('Sticky at top of lists');
    $assert_session->linkNotExists('Main page content');
    $assert_session->linkNotExists('Page title');
    $assert_session->linkNotExists('Messages');
    $assert_session->linkNotExists('Help');
    $assert_session->linkNotExists('Tabs');
    $assert_session->linkNotExists('Primary admin actions');

    // Verify that Changed block is not present on first section.
    $assert_session->linkNotExists('Changed');
+6 −6
Original line number Diff line number Diff line
@@ -89,9 +89,9 @@ public function testBlockFilter() {
    $fewer_blocks_message = ' blocks are available in the modified list';
    $this->assertAnnounceContains($fewer_blocks_message);
    $visible_rows = $this->filterVisibleElements($blocks);
    $this->assertCount(4, $visible_rows);
    $this->assertCount(3, $visible_rows);
    $visible_categories = $this->filterVisibleElements($categories);
    $this->assertCount(4, $visible_categories);
    $this->assertCount(3, $visible_categories);

    // Test Drupal.announce() message when multiple matches are present.
    $expected_message = count($visible_rows) . $fewer_blocks_message;
@@ -100,16 +100,16 @@ public function testBlockFilter() {
    // Test 3 letter search.
    $filter->setValue('adm');
    $visible_rows = $this->filterVisibleElements($blocks);
    $this->assertCount(3, $visible_rows);
    $this->assertCount(2, $visible_rows);
    $visible_categories = $this->filterVisibleElements($categories);
    $this->assertCount(3, $visible_categories);
    $this->assertCount(2, $visible_categories);

    // Retest that blocks appear when reducing letters.
    $filter->setValue('ad');
    $visible_rows = $this->filterVisibleElements($blocks);
    $this->assertCount(4, $visible_rows);
    $this->assertCount(3, $visible_rows);
    $visible_categories = $this->filterVisibleElements($categories);
    $this->assertCount(4, $visible_categories);
    $this->assertCount(3, $visible_categories);

    // Test blocks reappear after being filtered by repeating search for "a"
    $filter->setValue('a');