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('Uses') . '

'; $output .= '
'; $output .= '
' . t('Placing and moving blocks') . '
'; - $output .= '
' . t('You can place a new block by clicking on the Add block to layout button on the Block layout page and then choosing a region to place it in. Once a block is placed, it can be moved to a different region by dragging or using the drop-down Region list, and then clicking Save blocks.', array('!blocks' => \Drupal::url('block.admin_display'))) . '
'; + $output .= '
' . t('You can place a new block by clicking on its title in the Place blocks list on the Block layout page and choosing a region to place it in. Once a block is placed, it can be moved to a different region by dragging or using the drop-down Region list, and then clicking Save blocks.', array('!blocks' => \Drupal::url('block.admin_display'))) . '
'; $output .= '
' . t('Toggling between different themes') . '
'; $output .= '
' . t('Blocks are placed and configured specifically for each theme. The Block layout page opens with the default theme, but you can toggle to other installed themes.') . '
'; $output .= '
' . t('Demonstrating block regions for a theme') . '
'; @@ -37,14 +37,14 @@ function block_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Controlling visibility') . '
'; $output .= '
' . t('You can control the visibility of a block by restricting it to specific pages, content types, and/or roles by setting the appropriate options under Visibility settings of the block configuration.') . '
'; $output .= '
' . t('Adding custom blocks') . '
'; - $output .= '
' . t('If the Custom Block module is installed, you can create and add your own blocks using fields and customizable display settings. For more information, see the Custom Block help page.', array('!blockcontent-help' => $block_content)) . '
'; + $output .= '
' . t('You can add custom blocks, if the Custom Block module is installed. For more information, see the Custom Block help page.', array('!blockcontent-help' => $block_content)) . '
'; $output .= '
'; return $output; } if ($route_name == 'block.admin_display' || $route_name == 'block.admin_display_theme') { $demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default'); $themes = \Drupal::service('theme_handler')->listInfo(); - $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' => '
', diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 52f4e99..6288824 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -8,6 +8,7 @@ namespace Drupal\block; use Drupal\Component\Utility\Html; +use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Entity\EntityInterface; @@ -17,6 +18,7 @@ use Drupal\Core\Form\FormInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Theme\ThemeManagerInterface; +use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -213,10 +215,20 @@ protected function buildBlocksForm() { ), ); $form['region-' . $region]['title'] = array( - '#markup' => $region != BlockInterface::BLOCK_REGION_NONE ? $title : $this->t('Disabled', array(), array('context' => 'Plural')), + '#prefix' => $region != BlockInterface::BLOCK_REGION_NONE ? $title : $this->t('Disabled', array(), array('context' => 'Plural')), + '#type' => 'link', + '#title' => $this->t('Place block'), + '#url' => Url::fromRoute('block.admin_library', ['theme' => $this->getThemeName()], ['query' => ['region' => $region]]), '#wrapper_attributes' => array( 'colspan' => 5, ), + '#attributes' => [ + 'class' => ['use-ajax', 'button', 'button--small'], + 'data-dialog-type' => 'modal', + 'data-dialog-options' => Json::encode([ + 'width' => 700, + ]), + ], ); $form['region-' . $region . '-message'] = array( diff --git a/core/modules/block/src/Controller/BlockLibraryController.php b/core/modules/block/src/Controller/BlockLibraryController.php index 703089c..b2a6602 100644 --- a/core/modules/block/src/Controller/BlockLibraryController.php +++ b/core/modules/block/src/Controller/BlockLibraryController.php @@ -7,11 +7,13 @@ namespace Drupal\block\Controller; +use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Provides a list of block plugins to be added to the layout. @@ -53,9 +55,7 @@ public static function create(ContainerInterface $container) { * @return array * A render array as expected by the renderer. */ - public function listBlocks($theme = NULL) { - $theme = $theme ?: $this->config('system.theme')->get('default'); - + public function listBlocks(Request $request ,$theme) { $headers = [ ['data' => $this->t('Block')], ['data' => $this->t('Category')], @@ -67,6 +67,7 @@ public function listBlocks($theme = NULL) { // Order by category, and then by admin label. $definitions = $this->blockManager->getSortedDefinitions($definitions); + $region = $request->query->get('region'); $rows = array(); foreach ($definitions as $plugin_id => $plugin_definition) { $row = []; @@ -77,9 +78,19 @@ public function listBlocks($theme = NULL) { ]; $row['category']['data'] = SafeMarkup::checkPlain($plugin_definition['category']); $links['add'] = [ - 'title' => $this->t('Add block'), + 'title' => $this->t('Place block'), 'url' => Url::fromRoute('block.admin_add', ['plugin_id' => $plugin_id, 'theme' => $theme]), + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-dialog-type' => 'modal', + 'data-dialog-options' => Json::encode([ + 'width' => 700, + ]), + ), ]; + if ($region) { + $links['add']['query']['region'] = $region; + } $row['operations']['data'] = [ '#type' => 'operations', '#links' => $links, diff --git a/core/modules/block/src/Tests/BlockLanguageCacheTest.php b/core/modules/block/src/Tests/BlockLanguageCacheTest.php index c07731d..543e65e 100644 --- a/core/modules/block/src/Tests/BlockLanguageCacheTest.php +++ b/core/modules/block/src/Tests/BlockLanguageCacheTest.php @@ -8,7 +8,6 @@ namespace Drupal\block\Tests; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\simpletest\WebTestBase; @@ -60,10 +59,10 @@ public function testBlockLinks() { )); $this->drupalLogin($admin_user); - $url = Url::fromRoute('block.admin_library'); // Create the block cache for all languages. foreach ($this->langcodes as $langcode) { - $this->drupalGet($url, array('language' => $langcode)); + $this->drupalGet('admin/structure/block', array('language' => $langcode)); + $this->clickLink('Place block'); } // Create a menu in the default language. @@ -74,7 +73,8 @@ public function testBlockLinks() { // Check that the block is listed for all languages. foreach ($this->langcodes as $langcode) { - $this->drupalGet($url, array('language' => $langcode)); + $this->drupalGet('admin/structure/block', array('language' => $langcode)); + $this->clickLink('Place block'); $this->assertText($edit['label']); } } diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index 28426f6..1f26739 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -8,7 +8,6 @@ namespace Drupal\block\Tests; use Drupal\Component\Utility\Html; -use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; /** @@ -146,8 +145,8 @@ public function testCandidateBlockList() { ); $pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]'; - // Check if the block is listed. - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet('admin/structure/block'); + $this->clickLink('Place block'); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the category for its module.'); @@ -155,9 +154,9 @@ public function testCandidateBlockList() { $this->container->get('state')->set('block_test_info_alter', TRUE); $this->container->get('plugin.manager.block')->clearCachedDefinitions(); - // Check if the block is listed with a custom category. - $this->drupalGet(Url::fromRoute('block.admin_library')); - $arguments[':category'] = "Custom category"; + $this->drupalGet('admin/structure/block'); + $this->clickLink('Place block'); + $arguments[':category'] = 'Custom category'; $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in a custom category controlled by block_test_block_alter().'); } diff --git a/core/modules/block/src/Tests/BlockXssTest.php b/core/modules/block/src/Tests/BlockXssTest.php index 97a4559..5cd6477 100644 --- a/core/modules/block/src/Tests/BlockXssTest.php +++ b/core/modules/block/src/Tests/BlockXssTest.php @@ -31,7 +31,7 @@ class BlockXssTest extends WebTestBase { /** * Test XSS in title. */ - public function testXSSInTitle() { + public function testXssInTitle() { $this->drupalPlaceBlock('test_xss_title', array('label' => '')); \Drupal::state()->set('block_test.content', $this->randomMachineName()); @@ -45,12 +45,13 @@ public function testXSSInTitle() { } /** - * Test XSS in title. + * Tests XSS in category. */ - public function testXSSInCategory() { + public function testXssInCategory() { $this->drupalPlaceBlock('test_xss_title'); $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages'])); - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet(Url::fromRoute('block.admin_display')); + $this->clickLink('Place block'); $this->assertNoRaw(""); } @@ -76,7 +77,8 @@ protected function doViewTest() { $view->addDisplay('block'); $view->save(); - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet(Url::fromRoute('block.admin_display')); + $this->clickLink('Place block'); // The block admin label is automatically XSS admin filtered. $this->assertRaw('alert("view");'); $this->assertNoRaw(''); @@ -91,7 +93,8 @@ protected function doMenuTest() { 'label' => '', ])->save(); - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet(Url::fromRoute('block.admin_display')); + $this->clickLink('Place block'); // The block admin label is automatically XSS admin filtered. $this->assertRaw('alert("menu");'); $this->assertNoRaw(''); @@ -111,7 +114,8 @@ protected function doBlockContentTest() { 'info' => '', ])->save(); - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet(Url::fromRoute('block.admin_display')); + $this->clickLink('Place block'); // The block admin label is automatically XSS admin filtered. $this->assertRaw('alert("block_content");'); $this->assertNoRaw(''); diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php index 24dc5c1..d9f9196 100644 --- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php @@ -8,7 +8,6 @@ namespace Drupal\block\Tests\Views; use Drupal\Component\Serialization\Json; -use Drupal\Core\Url; use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -70,7 +69,8 @@ public function testBlockCategory() { )), ':category' => t('Lists (Views)'), ); - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet('admin/structure/block'); + $this->clickLink('Place block'); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the category for its base table.'); @@ -94,7 +94,8 @@ public function testBlockCategory() { // Test that the blocks are listed under the correct categories. $arguments[':category'] = $category; - $this->drupalGet(Url::fromRoute('block.admin_library')); + $this->drupalGet('admin/structure/block'); + $this->clickLink('Place block'); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the custom category.'); diff --git a/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig new file mode 100644 index 0000000..854d3ce --- /dev/null +++ b/core/modules/block/templates/block-list.html.twig @@ -0,0 +1,23 @@ +{# +/** + * @file + * Two column template for the block add/edit form. + * + * This template will be used when a block edit form specifies 'block_edit_form' + * as its #theme callback. Otherwise, by default, block add/edit forms will be + * themed by form.html.twig. + * + * Available variables: + * - form: The block add/edit form. + * + * @ingroup themeable + */ +#} +
+
+ {{ form|without('place_blocks') }} +
+
+ {{ form.place_blocks }} +
+
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php index 1f028c3..3146b59 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestXSSTitleBlock.php @@ -8,11 +8,10 @@ namespace Drupal\block_test\Plugin\Block; /** - * Provides a block to test XSS in the title and category. + * Provides a block to test XSS in title. * * @Block( * id = "test_xss_title", - * category = @Translation(""), * admin_label = "" * ) */ diff --git a/core/modules/block_content/block_content.links.action.yml b/core/modules/block_content/block_content.links.action.yml index b55361a..4772a6f 100644 --- a/core/modules/block_content/block_content.links.action.yml +++ b/core/modules/block_content/block_content.links.action.yml @@ -8,5 +8,6 @@ block_content_add_action: route_name: block_content.add_page title: 'Add custom block' appears_on: + - block.admin_library - entity.block_content.collection class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction diff --git a/core/modules/block_content/block_content.links.task.yml b/core/modules/block_content/block_content.links.task.yml index e6b0545..2b88171 100644 --- a/core/modules/block_content/block_content.links.task.yml +++ b/core/modules/block_content/block_content.links.task.yml @@ -1,5 +1,5 @@ entity.block_content.collection: - title: 'Custom blocks' + title: 'Custom block library' route_name: entity.block_content.collection base_route: block.admin_display block_content.list_sub: diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index bc00d7a..04a1e6c 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -18,23 +18,24 @@ function block_content_help($route_name, RouteMatchInterface $route_match) { $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#'; $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . 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('Uses') . '

'; $output .= '
'; $output .= '
' . t('Creating and managing custom block types') . '
'; - $output .= '
' . t('Users with the Administer blocks permission can create custom block types using fields and manage existing block types, from the Custom block types page. For more information about managing fields and display settings, see the Field UI module help.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!field-ui' => $field_ui)) . '
'; + $output .= '
' . t('Users with the Administer blocks permission can create and edit custom block types with fields and display settings, from the Custom block types page in the Custom block library. For more information about managing fields and display settings, see the Field UI module help.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!field-ui' => $field_ui)) . '
'; $output .= '
' . t('Creating custom blocks') . '
'; - $output .= '
' . t('Users with the Administer blocks permission can create, edit, and delete custom blocks from the Custom blocks page. Custom blocks can be added to a theme\'s layout on the Block layout page; see the Block module help for more information about placing blocks.', array('!blocks' => \Drupal::url('block.admin_display'), '!block-listing' => \Drupal::url('entity.block_content.collection'), '!block_help' => \Drupal::url('help.page', array('name' => 'block')))) . '
'; + $output .= '
' . t('Users with the Administer blocks permission can create, edit, and delete custom blocks of each custom block type you have defined, from the Custom block library page. Custom blocks are shown in the Place blocks list on the Block layout page; see the Block module help for more information about placing blocks.', array('!blocks' => \Drupal::url('block.admin_display'), '!block-library' => \Drupal::url('entity.block_content.collection'), '!block_help' => \Drupal::url('help.page', array('name' => 'block')))) . '
'; $output .= '
'; return $output; case 'entity.block_content.collection': - $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