diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 59f1332..407c7c0 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -58,6 +58,12 @@ a.block-demo-backlink:hover { #block-placed { background-color: #ffd; } +#edit-settings-admin-label label { + display: inline; +} +#edit-settings-admin-label label:after { + content: ':'; +} /* Wide screens */ @media diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index fa603d2..475b863 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -89,6 +89,11 @@ public function buildConfigurationForm(array $form, array &$form_state) { '#value' => $definition['module'], ); + $form['admin_label'] = array( + '#type' => 'item', + '#title' => t('Block description'), + '#markup' => $definition['admin_label'], + ); $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Title'), diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 92d3696..4124e15 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -264,6 +264,9 @@ public function form(array $form, array &$form_state) { '#prefix' => '
', '#suffix' => '
', ); + $form['#attached']['css'] = array( + drupal_get_path('module', 'block') . '/css/block.admin.css', + ); return $form; } diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 30d0afd..b82bc96 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -175,6 +175,7 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'table', '#header' => array( t('Block'), + t('Category'), t('Region'), t('Weight'), t('Operations'), @@ -188,10 +189,11 @@ public function buildForm(array $form, array &$form_state) { foreach ($entities as $entity_id => $entity) { $definition = $entity->getPlugin()->getPluginDefinition(); $blocks[$entity->get('region')][$entity_id] = array( - 'admin_label' => $definition['admin_label'], + 'label' => $entity->label(), 'entity_id' => $entity_id, 'weight' => $entity->get('weight'), 'entity' => $entity, + 'category' => $definition['category'], ); } @@ -255,16 +257,19 @@ public function buildForm(array $form, array &$form_state) { } $form['blocks'][$entity_id]['info'] = array( - '#markup' => check_plain($info['admin_label']), + '#markup' => check_plain($info['label']), '#wrapper_attributes' => array( 'class' => array('block'), ), ); + $form['blocks'][$entity_id]['type'] = array( + '#markup' => $info['category'], + ); $form['blocks'][$entity_id]['region-theme']['region'] = array( '#type' => 'select', '#default_value' => $region, '#empty_value' => BLOCK_REGION_NONE, - '#title' => t('Region for @block block', array('@block' => $info['admin_label'])), + '#title' => t('Region for @block block', array('@block' => $info['label'])), '#title_display' => 'invisible', '#options' => $this->regions, '#attributes' => array( @@ -281,7 +286,7 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'weight', '#default_value' => $info['weight'], '#delta' => $weight_delta, - '#title' => t('Weight for @block block', array('@block' => $info['admin_label'])), + '#title' => t('Weight for @block block', array('@block' => $info['label'])), '#title_display' => 'invisible', '#attributes' => array( 'class' => array('block-weight', 'block-weight-' . $region), diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php index 5405989..3f22caa 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php @@ -58,12 +58,18 @@ public function testBlockInterface() { $display_block->setConfigurationValue('display_message', 'My custom display message.'); $expected_configuration['display_message'] = 'My custom display message.'; $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.'); + $definition = $display_block->getPluginDefinition(); $expected_form = array( 'module' => array( '#type' => 'value', '#value' => 'block_test', ), + 'admin_label' => array( + '#type' => 'item', + '#title' => t('Block description'), + '#markup' => $definition['admin_label'], + ), 'label' => array( '#type' => 'textfield', '#title' => 'Title', diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php index 05921ed..356d480 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php @@ -24,6 +24,20 @@ class BlockUiTest extends WebTestBase { protected $regions; /** + * The submitted block values used by this test. + * + * @var array + */ + protected $blockValues; + + /** + * The block entities used by this test. + * + * @var \Drupal\block\BlockInterface[] + */ + protected $blocks; + + /** * An administrative user to configure the test environment. */ protected $adminUser; @@ -46,7 +60,7 @@ function setUp() { $this->drupalLogin($this->adminUser); // Enable some test blocks. - $this->testBlocks = array( + $this->blockValues = array( array( 'label' => 'Tools', 'tr' => '5', @@ -62,8 +76,9 @@ function setUp() { 'test_weight' => '0', ), ); - foreach ($this->testBlocks as $values) { - $this->drupalPlaceBlock($values['plugin_id'], $values['settings']); + $this->blocks = array(); + foreach ($this->blockValues as $values) { + $this->blocks[] = $this->drupalPlaceBlock($values['plugin_id'], $values['settings']); } } @@ -88,9 +103,11 @@ function testBlockAdminUiPage() { $blocks_table = $this->xpath("//table[@id='blocks']"); $this->assertTrue(!empty($blocks_table), 'The blocks table is being rendered.'); // Look for test blocks in the table. - foreach ($this->testBlocks as $values) { + foreach ($this->blockValues as $delta => $values) { + $block = $this->blocks[$delta]; + $label = $block->label(); $element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()'); - $this->assertTrue((string)$element[0] == $values['label'], 'The "' . $values['label'] . '" block title is set inside the ' . $values['settings']['region'] . ' region.'); + $this->assertTrue((string) $element[0] == $label, 'The "' . $label . '" block title is set inside the ' . $values['settings']['region'] . ' region.'); // Look for a test block region select form element. $this->assertField('blocks[' . $values['settings']['id'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.'); // Move the test block to the header region. @@ -101,17 +118,17 @@ function testBlockAdminUiPage() { $edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight']; } $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks')); - foreach ($this->testBlocks as $values) { + foreach ($this->blockValues as $values) { // Check if the region and weight settings changes have persisted. $this->assertOptionSelected( 'edit-blocks-' . $values['settings']['id'] . '-region', 'header', - 'The block "' . $values['label'] . '" has the correct region assignment (header).' + 'The block "' . $label . '" has the correct region assignment (header).' ); $this->assertOptionSelected( 'edit-blocks-' . $values['settings']['id'] . '-weight', $values['test_weight'], - 'The block "' . $values['label'] . '" has the correct weight assignment (' . $values['test_weight'] . ').' + 'The block "' . $label . '" has the correct weight assignment (' . $values['test_weight'] . ').' ); } }