Commit c3dbc269 authored by Dries's avatar Dries

Issue #2078341 by tim.plunkett: Restructure Block UI and custom block pages.

parent dac7e246
......@@ -115,10 +115,14 @@ function block_permission() {
function block_menu() {
$default_theme = Drupal::config('system.theme')->get('default');
$items['admin/structure/block'] = array(
'title' => 'Blocks',
'title' => 'Block layout',
'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',
'route_name' => 'block_admin_display',
);
$items['admin/structure/block/list'] = array(
'title' => 'Block layout',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/structure/block/manage/%block'] = array(
'title' => 'Configure block',
'route_name' => 'block_admin_edit',
......
......@@ -7,4 +7,4 @@ core: 8.x
dependencies:
- block
- text
configure: admin/structure/custom-blocks
configure: admin/structure/block/custom-blocks
......@@ -16,11 +16,11 @@ function custom_block_help($path, $arg) {
case 'admin/help#custom_block':
return t('Allows the creation of custom blocks through the user interface.');
case 'admin/structure/custom-blocks':
case 'admin/structure/block/custom-blocks':
$output = '<p>' . t('This page lists user-created blocks. These blocks are derived from block types. A block type can consist of different fields and display settings. From the block types tab you can manage these fields as well as create new block types.') . '</p>';
return $output;
case 'admin/structure/custom-blocks/types':
case 'admin/structure/block/custom-blocks/types':
$output = '<p>' . t('This page lists block types. A block type can consist of different fields and display settings. From here you can manage these fields as well as create new block types.') . '</p>';
return $output;
......@@ -37,7 +37,7 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
$item = menu_get_item('block/add');
if ($item['access']) {
// Add a destination parameter.
$item['localized_options']['query']['destination'] = 'admin/structure/custom-blocks';
$item['localized_options']['query']['destination'] = 'admin/structure/block/custom-blocks';
$data['actions']['block/add'] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
......@@ -63,37 +63,38 @@ function custom_block_menu_local_actions_alter(&$actions) {
* Implements hook_menu().
*/
function custom_block_menu() {
$items['admin/structure/custom-blocks'] = array(
'title' => 'Custom blocks',
$items['admin/structure/block/custom-blocks'] = array(
'title' => 'Custom block library',
'description' => 'Manage custom blocks.',
'route_name' => 'custom_block_list',
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
);
$items['admin/structure/custom-blocks/list'] = array(
$items['admin/structure/block/custom-blocks/list'] = array(
'title' => 'Blocks',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/structure/custom-blocks/types'] = array(
$items['admin/structure/block/custom-blocks/types'] = array(
'title' => 'Types',
'route_name' => 'custom_block_type_list',
'type' => MENU_LOCAL_TASK,
);
$items['admin/structure/custom-blocks/types/add'] = array(
$items['admin/structure/block/custom-blocks/types/add'] = array(
'route_name' => 'custom_block_type_add',
'type' => MENU_SIBLING_LOCAL_TASK,
'weight' => 1,
);
$items['admin/structure/custom-blocks/manage/%custom_block_type'] = array(
$items['admin/structure/block/custom-blocks/manage/%custom_block_type'] = array(
'title' => 'Edit custom block type',
'title callback' => 'entity_page_label',
'title arguments' => array(4),
'title arguments' => array(5),
'route_name' => 'custom_block_type_edit',
);
$items['admin/structure/custom-blocks/manage/%custom_block_type/edit'] = array(
$items['admin/structure/block/custom-blocks/manage/%custom_block_type/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/structure/custom-blocks/manage/%custom_block_type/delete'] = array(
$items['admin/structure/block/custom-blocks/manage/%custom_block_type/delete'] = array(
'title' => 'Delete',
'type' => MENU_LOCAL_TASK,
'weight' => 10,
......@@ -251,7 +252,7 @@ function custom_block_admin_paths() {
'block/add/*' => TRUE,
'block/*' => TRUE,
'block/*/delete' => TRUE,
'admin/structure/custom-blocks/*' => TRUE,
'admin/structure/block/custom-blocks/*' => TRUE,
);
return $paths;
}
custom_block_type_list:
pattern: '/admin/structure/custom-blocks/types'
pattern: '/admin/structure/block/custom-blocks/types'
defaults:
_entity_list: 'custom_block_type'
requirements:
......@@ -20,7 +20,7 @@ custom_block_add_form:
_permission: 'administer blocks'
custom_block_type_delete:
pattern: '/admin/structure/custom-blocks/manage/{custom_block_type}/delete'
pattern: '/admin/structure/block/custom-blocks/manage/{custom_block_type}/delete'
defaults:
_entity_form: 'custom_block_type.delete'
requirements:
......@@ -42,22 +42,23 @@ custom_block_delete:
_entity_access: 'custom_block.delete'
custom_block_type_add:
pattern: '/admin/structure/custom-blocks/types/add'
pattern: '/admin/structure/block/custom-blocks/types/add'
defaults:
_entity_form: 'custom_block_type.add'
requirements:
_permission: 'administer blocks'
custom_block_type_edit:
pattern: '/admin/structure/custom-blocks/manage/{custom_block_type}'
pattern: '/admin/structure/block/custom-blocks/manage/{custom_block_type}'
defaults:
_entity_form: 'custom_block_type.edit'
requirements:
_entity_access: 'custom_block_type.update'
custom_block_list:
pattern: '/admin/structure/custom-blocks'
pattern: '/admin/structure/block/custom-blocks'
defaults:
_title: 'Custom block library'
_entity_list: 'custom_block'
requirements:
_permission: 'administer blocks'
......@@ -191,7 +191,7 @@ public function save(array $form, array &$form_state) {
}
}
else {
$form_state['redirect'] = 'admin/structure/custom-blocks';
$form_state['redirect'] = 'admin/structure/block/custom-blocks';
}
}
else {
......
......@@ -40,7 +40,7 @@ public function getOperations(EntityInterface $entity) {
if (isset($operations['edit'])) {
$uri = $entity->uri();
$operations['edit']['href'] = $uri['path'];
$operations['edit']['query']['destination'] = 'admin/structure/custom-blocks';
$operations['edit']['query']['destination'] = 'admin/structure/block/custom-blocks';
}
return $operations;
}
......
......@@ -101,7 +101,7 @@ public function save(array $form, array &$form_state) {
watchdog('custom_block', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit'));
}
$form_state['redirect'] = 'admin/structure/custom-blocks/types';
$form_state['redirect'] = 'admin/structure/block/custom-blocks/types';
}
/**
......@@ -109,7 +109,7 @@ public function save(array $form, array &$form_state) {
*/
public function delete(array $form, array &$form_state) {
$block_type = $this->entity;
$form_state['redirect'] = 'admin/structure/custom-blocks/manage/' . $block_type->id() . '/delete';
$form_state['redirect'] = 'admin/structure/block/custom-blocks/manage/' . $block_type->id() . '/delete';
}
}
......@@ -36,7 +36,7 @@
* },
* base_table = "custom_block",
* revision_table = "custom_block_revision",
* route_base_path = "admin/structure/custom-blocks/manage/{bundle}",
* route_base_path = "admin/structure/block/custom-blocks/manage/{bundle}",
* menu_base_path = "block/%custom_block",
* menu_edit_path = "block/%custom_block",
* fieldable = TRUE,
......
......@@ -82,7 +82,7 @@ class CustomBlockType extends ConfigEntityBase implements CustomBlockTypeInterfa
*/
public function uri() {
return array(
'path' => 'admin/structure/custom-blocks/manage/' . $this->id(),
'path' => 'admin/structure/block/custom-blocks/manage/' . $this->id(),
'options' => array(
'entity_type' => $this->entityType,
'entity' => $this,
......
......@@ -59,7 +59,7 @@ public function submit(array $form, array &$form_state) {
$this->entity->delete();
drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('custom_block', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
$form_state['redirect'] = 'admin/structure/custom-blocks';
$form_state['redirect'] = 'admin/structure/block/custom-blocks';
}
}
......@@ -53,7 +53,7 @@ public function getQuestion() {
* {@inheritdoc}
*/
public function getCancelPath() {
return 'admin/structure/custom-blocks/types';
return 'admin/structure/block/custom-blocks/types';
}
/**
......@@ -83,7 +83,7 @@ public function buildForm(array $form, array &$form_state) {
*/
public function submit(array $form, array &$form_state) {
$this->entity->delete();
$form_state['redirect'] = 'admin/structure/custom-blocks/types';
$form_state['redirect'] = 'admin/structure/block/custom-blocks/types';
drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('custom_block', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
}
......
......@@ -37,10 +37,10 @@ public static function getInfo() {
*/
public function testListing() {
$this->drupalLogin($this->drupalCreateUser(array('administer blocks')));
$this->drupalGet('admin/structure/custom-blocks');
$this->drupalGet('admin/structure/block/custom-blocks');
// 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="l-content"]//table');
......
......@@ -61,7 +61,7 @@ public function testCustomBlockTypeCreation() {
'id' => 'foo',
'label' => 'title for foo',
);
$this->drupalPost('admin/structure/custom-blocks/types/add', $edit, t('Save'));
$this->drupalPost('admin/structure/block/custom-blocks/types/add', $edit, t('Save'));
$block_type = entity_load('custom_block_type', 'foo');
$this->assertTrue($block_type, 'The new block type has been created.');
......@@ -90,7 +90,7 @@ public function testCustomBlockTypeEditing() {
$edit = array(
'label' => 'Bar',
);
$this->drupalPost('admin/structure/custom-blocks/manage/basic', $edit, t('Save'));
$this->drupalPost('admin/structure/block/custom-blocks/manage/basic', $edit, t('Save'));
field_info_cache_clear();
$this->drupalGet('block/add');
......@@ -99,9 +99,9 @@ public function testCustomBlockTypeEditing() {
$this->assertEqual(url('block/add/basic', array('absolute' => TRUE)), $this->getUrl(), 'Original machine name was used in URL.');
// Remove the body field.
$this->drupalPost('admin/structure/custom-blocks/manage/basic/fields/custom_block.basic.block_body/delete', array(), t('Delete'));
$this->drupalPost('admin/structure/block/custom-blocks/manage/basic/fields/custom_block.basic.block_body/delete', array(), t('Delete'));
// Resave the settings for this type.
$this->drupalPost('admin/structure/custom-blocks/manage/basic', array(), t('Save'));
$this->drupalPost('admin/structure/block/custom-blocks/manage/basic', array(), t('Save'));
// Check that the body field doesn't exist.
$this->drupalGet('block/add/basic');
$this->assertNoRaw('Block body', 'Body field was not found.');
......@@ -119,7 +119,7 @@ public function testCustomBlockTypeDeletion() {
// Add a new block of this type.
$block = $this->createCustomBlock(FALSE, 'foo');
// Attempt to delete the block type, which should not be allowed.
$this->drupalGet('admin/structure/custom-blocks/manage/' . $type->id() . '/delete');
$this->drupalGet('admin/structure/block/custom-blocks/manage/' . $type->id() . '/delete');
$this->assertRaw(
t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', array('%label' => $type->label())),
'The block type will not be deleted until all blocks of that type are removed.'
......@@ -129,7 +129,7 @@ public function testCustomBlockTypeDeletion() {
// Delete the block.
$block->delete();
// Attempt to delete the block type, which should now be allowed.
$this->drupalGet('admin/structure/custom-blocks/manage/' . $type->id() . '/delete');
$this->drupalGet('admin/structure/block/custom-blocks/manage/' . $type->id() . '/delete');
$this->assertRaw(
t('Are you sure you want to delete %type?', array('%type' => $type->id())),
'The block type is available for deletion.'
......@@ -173,7 +173,7 @@ public function testsCustomBlockAddTypes() {
// Test that adding a block from the 'custom blocks list' doesn't send you
// to the block configure form.
$this->drupalGet('admin/structure/custom-blocks');
$this->drupalGet('admin/structure/block/custom-blocks');
$this->clickLink(t('Add custom block'));
$this->clickLink('foo');
$edit = array('info' => $this->randomName(8));
......@@ -182,7 +182,7 @@ public function testsCustomBlockAddTypes() {
if (!empty($blocks)) {
$block = reset($blocks);
$destination = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . $theme;
$this->assertUrl(url('admin/structure/custom-blocks', array(
$this->assertUrl(url('admin/structure/block/custom-blocks', array(
'absolute' => TRUE
)));
}
......
......@@ -273,7 +273,7 @@ function testBlockModuleDisable() {
$this->drupalGet('admin/structure/block');
$this->assertResponse(200);
// A 200 response is possible with a fatal error, so check the title too.
$this->assertTitle(t('Blocks | Drupal'));
$this->assertTitle(t('Block layout') . ' | Drupal');
// Ensure that the disabled module's block instance is not listed.
foreach ($regions as $region) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment