diff --git a/core/modules/block/block.links.action.yml b/core/modules/block/block.links.action.yml deleted file mode 100644 index 2340747..0000000 --- a/core/modules/block/block.links.action.yml +++ /dev/null @@ -1,10 +0,0 @@ -block_layout_add_action: - route_name: block.admin_library - title: 'Add block to layout' - appears_on: - - block.admin_display -block_layout_add_action_for_theme: - route_name: block.admin_library_theme - title: 'Add block to layout' - appears_on: - - block.admin_display_theme diff --git a/core/modules/block/block.links.task.yml b/core/modules/block/block.links.task.yml index 123dd4c..bc72260 100644 --- a/core/modules/block/block.links.task.yml +++ b/core/modules/block/block.links.task.yml @@ -13,12 +13,3 @@ block.admin_display_theme: route_name: block.admin_display_theme parent_id: block.admin_display deriver: 'Drupal\block\Plugin\Derivative\ThemeLocalTask' - -# Per theme block placement pages. -block.admin_library: - route_name: block.admin_library - base_route: block.admin_library -block.admin_library_theme: - route_name: block.admin_library_theme - parent_id: block.admin_library - deriver: 'Drupal\block\Plugin\Derivative\ThemeLocalTask' diff --git a/core/modules/block/block.module b/core/modules/block/block.module index a17c89e..9ce0ac2 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -27,7 +27,7 @@ function block_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. To add a block to this theme\'s layout, click the Add block to layout button. After moving blocks, remember that your changes will not be saved until you click the Save blocks button at the bottom of the page.') . '
'; + $output = '' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. To add a block to a region, or to configure its specific title and visibility settings, click the block title under Place blocks. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the Save blocks button at the bottom of the page.') . '
'; $output .= '' . \Drupal::l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), new Url('block.admin_demo', array('theme' => $demo_theme))) . '
'; return $output; } diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index 0ccab2b..396bf0d 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -43,18 +43,10 @@ block.admin_display_theme: _permission: 'administer blocks' block.admin_library: - path: 'admin/structure/block/library' - defaults: - _controller: '\Drupal\block\Controller\BlockLibraryController::listBlocks' - _title: 'Add block to layout' - requirements: - _permission: 'administer blocks' - -block.admin_library_theme: path: 'admin/structure/block/library/{theme}' defaults: _controller: '\Drupal\block\Controller\BlockLibraryController::listBlocks' - _title: 'Add block to layout' + _title: 'Place block' requirements: _access_theme: 'TRUE' _permission: 'administer blocks' diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index de71682..2b9eb45 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -1,3 +1,12 @@ +/* Block listing page */ +.region-title .button { + margin-left: 1em; /* LTR */ +} +[dir="rtl"] .region-title .button { + margin-left: 0; + margin-right: 1em; +} + /* Block demo mode */ .block-region { background-color: #ff6; @@ -22,6 +31,7 @@ a.block-demo-backlink:visited { a.block-demo-backlink:hover { text-decoration: underline; } + /* Configure block form - Block description */ .block-form .form-item-settings-admin-label label { display: inline; diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index eac4d51..8c13bbb 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -170,11 +170,13 @@ public function form(array $form, FormStateInterface $form_state) { } // Region settings. + $entity_region = $entity->getRegion(); + $region = $entity->isNew() ? $this->getRequest()->query->get('region', $entity_region) : $entity_region; $form['region'] = array( '#type' => 'select', '#title' => $this->t('Region'), '#description' => $this->t('Select the region where this block should be displayed.'), - '#default_value' => $entity->getRegion(), + '#default_value' => $region, '#empty_value' => BlockInterface::BLOCK_REGION_NONE, '#options' => system_region_list($theme, REGIONS_VISIBLE), '#prefix' => '' . t('The Custom Block module allows you to create custom block types and content-containing blocks based on those types. A list of all custom blocks is available at the Custom blocks page. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', array('!block-listing' => \Drupal::url('entity.block_content.collection'), '!block-content' => \Drupal::url('entity.block_content.collection'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '
'; + $output .= '' . t('The Custom Block module allows you to create custom block types and content-containing blocks, and provides a Custom block library listing all of them. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', array('!block-library' => \Drupal::url('entity.block_content.collection'), '!block-content' => \Drupal::url('entity.block_content.collection'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '
'; $output .= '' . t('Every custom block is based on a block type, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!blocks' => \Drupal::url('block.admin_display'))) . '
'; + $output = '' . t('Blocks in the block library belong to block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!blocks' => \Drupal::url('block.admin_display'))) . '
'; return $output; case 'entity.block_content_type.collection': - $output = '' . t('After creating a type, you can then create a block based on it from the custom blocks page.', array('!block-listing' => \Drupal::url('entity.block_content.collection'))) . '
'; + $output = '' . t('Each block type has its own fields and display settings. Create blocks of each type on the Block library page.', array('!block-library' => \Drupal::url('entity.block_content.collection'))) . '
'; return $output; + } } diff --git a/core/modules/block_content/block_content.routing.yml b/core/modules/block_content/block_content.routing.yml index fc48fb1..3542ca8 100644 --- a/core/modules/block_content/block_content.routing.yml +++ b/core/modules/block_content/block_content.routing.yml @@ -2,7 +2,7 @@ entity.block_content_type.collection: path: '/admin/structure/block/block-content/types' defaults: _entity_list: 'block_content_type' - _title: 'Custom blocks' + _title: 'Custom block library' requirements: _permission: 'administer blocks' @@ -83,7 +83,7 @@ entity.block_content_type.edit_form: entity.block_content.collection: path: '/admin/structure/block/block-content' defaults: - _title: 'Custom blocks' + _title: 'Custom block library' _entity_list: 'block_content' requirements: _permission: 'administer blocks' diff --git a/core/modules/block_content/config/optional/views.view.block_content.yml b/core/modules/block_content/config/optional/views.view.block_content.yml index 8efe9df..ad5e1f9 100644 --- a/core/modules/block_content/config/optional/views.view.block_content.yml +++ b/core/modules/block_content/config/optional/views.view.block_content.yml @@ -5,7 +5,7 @@ dependencies: - block_content - user id: block_content -label: 'Custom blocks' +label: 'Custom block library' module: views description: 'Find and manage custom blocks.' tag: '' @@ -430,7 +430,7 @@ display: entity_field: type plugin_id: bundle sorts: { } - title: 'Custom blocks' + title: 'Custom block library' header: { } footer: { } empty: @@ -475,7 +475,7 @@ display: path: admin/structure/block/block-content menu: type: tab - title: 'Custom blocks' + title: 'Custom block library' description: '' parent: block.admin_display weight: 0 diff --git a/core/modules/block_content/src/BlockContentInterface.php b/core/modules/block_content/src/BlockContentInterface.php index 47c9c93..50f4d35 100644 --- a/core/modules/block_content/src/BlockContentInterface.php +++ b/core/modules/block_content/src/BlockContentInterface.php @@ -48,7 +48,7 @@ public function setRevisionLog($revision_log); /** * Sets the theme value. * - * When creating a new block content block from the block listing, the user is + * When creating a new block content block from the block library, the user is * redirected to the configure form for that block in the given theme. The * theme is stored against the block when the block content add form is shown. * @@ -63,7 +63,7 @@ public function setTheme($theme); /** * Gets the theme value. * - * When creating a new block content block from the block listing, the user is + * When creating a new block content block from the block library, the user is * redirected to the configure form for that block in the given theme. The * theme is stored against the block when the block content add form is shown. * diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php index 410d4a9..abb2cb2 100644 --- a/core/modules/block_content/src/BlockContentViewsData.php +++ b/core/modules/block_content/src/BlockContentViewsData.php @@ -29,7 +29,7 @@ public function getViewsData() { $data['block_content_field_data']['type']['field']['id'] = 'field'; $data['block_content']['block_content_listing_empty'] = array( - 'title' => t('Empty block listing behavior'), + 'title' => t('Empty block library behavior'), 'help' => t('Provides a link to add a new block.'), 'area' => array( 'id' => 'block_content_listing_empty', diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index 6e3ae86..f712367 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -111,9 +111,9 @@ public function addForm(BlockContentTypeInterface $block_content_type, Request $ 'type' => $block_content_type->id() )); if (($theme = $request->query->get('theme')) && in_array($theme, array_keys($this->themeHandler->listInfo()))) { - // We have navigated to this page from the block listing and will keep - // track of the theme for redirecting the user to the configuration page - // for the newly created block in the given theme. + // We have navigated to this page from the block library and will keep track + // of the theme for redirecting the user to the configuration page for the + // newly created block in the given theme. $block->setTheme($theme); } return $this->entityFormBuilder()->getForm($block); diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 359515a..4e186b9 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -71,7 +71,7 @@ class BlockContent extends ContentEntityBase implements BlockContentInterface { /** * The theme the block is being created in. * - * When creating a new custom block from the block listing, the user is + * When creating a new custom block from the block library, the user is * redirected to the configure form for that block in the given theme. The * theme is stored against the block when the custom block add form is shown. * diff --git a/core/modules/block_content/src/Tests/BlockContentListTest.php b/core/modules/block_content/src/Tests/BlockContentListTest.php index 30d1585..aeed4dc 100644 --- a/core/modules/block_content/src/Tests/BlockContentListTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListTest.php @@ -33,7 +33,7 @@ public function testListing() { $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. - $this->assertTitle(t('Custom blocks') . ' | Drupal'); + $this->assertTitle(t('Custom block library') . ' | Drupal'); // Test for the table. $element = $this->xpath('//div[@class="layout-content"]//table'); diff --git a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php index 6c273c6..ba84f2b 100644 --- a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php @@ -31,7 +31,7 @@ public function testListing() { $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. - $this->assertTitle(t('Custom blocks') . ' | Drupal'); + $this->assertTitle(t('Custom block library') . ' | Drupal'); // Test for the table. $element = $this->xpath('//div[@class="layout-content"]//table'); diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index 33fcfed..4270538 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -185,10 +185,20 @@ public function testsBlockContentAddTypes() { // For each installed theme, go to its block page and test the redirects. $themes = array('bartik', 'classy', 'seven'); foreach ($themes as $theme) { - // Test that adding a block from a 'custom block' link sends you to the + // Test that adding a block from the 'place blocks' form sends you to the // block configure form. - $this->drupalGet('block/add', ['query' => ['theme' => $theme]]); - $this->clickLink('foo'); + $path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme"; + $this->drupalGet($path); + $this->clickLink(t('Add custom block')); + // The seven theme has markup inside the link, we cannot use clickLink(). + if ($default_theme == 'seven') { + $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array(); + $this->assertLinkByHref(\Drupal::url('block_content.add_form', array('block_content_type' => 'foo'), $options)); + $this->drupalGet('block/add/foo', $options); + } + else { + $this->clickLink('foo'); + } // Create a new block. $edit = array('info[0][value]' => $this->randomMachineName(8)); $this->drupalPostForm(NULL, $edit, t('Save')); diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php index e2a85fb..3c00e92 100644 --- a/core/modules/menu_ui/src/Tests/MenuTest.php +++ b/core/modules/menu_ui/src/Tests/MenuTest.php @@ -10,6 +10,7 @@ use Drupal\block\Entity\Block; use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Cache\Cache; use Drupal\Core\Menu\MenuLinkInterface; use Drupal\Core\Url; use Drupal\menu_link_content\Entity\MenuLinkContent; @@ -180,7 +181,7 @@ function addCustomMenuCRUD() { * @return \Drupal\system\Entity\Menu * The custom menu that has been created. */ - protected function addCustomMenu() { + function addCustomMenu() { // Try adding a menu using a menu_name that is too long. $this->drupalGet('admin/structure/menu/add'); $menu_name = substr(hash('sha256', $this->randomMachineName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI + 1); @@ -217,7 +218,8 @@ protected function addCustomMenu() { $this->assertText($label, 'Menu created'); // Confirm that the custom menu block is available. - $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); + $this->clickLink('Place block'); $this->assertText($label); // Enable the block. @@ -530,7 +532,8 @@ function testSystemMenuRename() { // Make sure menu shows up with new name in block addition. $default_theme = $this->config('system.theme')->get('default'); - $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $default_theme])); + $this->drupalget('admin/structure/block/list/' . $default_theme); + $this->clickLink('Place block'); $this->assertText($edit['label']); } diff --git a/core/modules/search/src/Tests/SearchBlockTest.php b/core/modules/search/src/Tests/SearchBlockTest.php index e742d91..2348ae0 100644 --- a/core/modules/search/src/Tests/SearchBlockTest.php +++ b/core/modules/search/src/Tests/SearchBlockTest.php @@ -6,7 +6,6 @@ */ namespace Drupal\search\Tests; -use Drupal\Core\Url; /** * Tests if the search form block is available. @@ -36,7 +35,8 @@ protected function setUp() { public function testSearchFormBlock() { // Test availability of the search block in the admin "Place blocks" list. - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet('admin/structure/block'); + $this->clickLink('Place block'); $this->assertLinkByHref('/admin/structure/block/add/search_form_block/classy', 0, 'Did not find the search block in block candidate list.'); diff --git a/core/modules/views/src/Tests/Wizard/BasicTest.php b/core/modules/views/src/Tests/Wizard/BasicTest.php index 88c767b..2ba0dac 100644 --- a/core/modules/views/src/Tests/Wizard/BasicTest.php +++ b/core/modules/views/src/Tests/Wizard/BasicTest.php @@ -132,7 +132,8 @@ function testViewsWizardAndListing() { $this->assertNoText('REST export', 'If only the page and block options were enabled in the wizard, the resulting view does not have a REST export display.'); // Confirm that the block is available in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); + $this->clickLink('Place block'); $this->assertText($view3['label']); // Place the block. diff --git a/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php index ea46eb0..7fd06d0 100644 --- a/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Wizard; -use Drupal\Core\Url; - /** * Tests the ability of the views wizard to specify the number of items per * page. @@ -72,7 +70,8 @@ function testItemsPerPage() { $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, 'The nodes appear in the expected order in the page display.'); // Confirm that the block is listed in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); + $this->clickLink('Place block'); $this->assertText($view['label']); // Place the block, visit a page that displays the block, and check that the diff --git a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php b/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php index 145542a..15b6c88 100644 --- a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php +++ b/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\Core\Url; - /** * Tests that displays can be correctly overridden via the user interface. * @@ -51,7 +49,8 @@ function testOverrideDisplays() { $this->assertText($original_title); // Confirm that the view block is available in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); + $this->clickLink('Place block'); $this->assertText($view['label']); // Place the block. @@ -110,7 +109,8 @@ function testWizardMixedDefaultOverriddenDisplays() { $this->assertNoText($view['block[title]']); // Confirm that the block is available in the block administration UI. - $this->drupalGet(Url::fromRoute('block.admin_library_theme', ['theme' => $this->config('system.theme')->get('default')])); + $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); + $this->clickLink('Place block'); $this->assertText($view['label']); // Put the block into the first sidebar region, and make sure it will not