Commit 866f7eb9 authored by webchick's avatar webchick

Issue #1970208 by tim.plunkett: Fixed Views blocks are missing contextual links.

parent 99fa48d9
......@@ -352,6 +352,12 @@ function _block_get_renderable_region($list = array()) {
// draw attention on it.
if (isset($build[$key]) && !in_array($block->get('plugin'), array('system_help_block', 'system_main_block'))) {
$build[$key]['#contextual_links']['block'] = array('admin/structure/block/manage', array($key));
// If there are any nested contextual links, move them to the top level.
if (isset($build[$key]['content']['#contextual_links'])) {
$build[$key]['#contextual_links'] += $build[$key]['content']['#contextual_links'];
unset($build[$key]['content']['#contextual_links']);
}
}
}
return $build;
......
......@@ -288,15 +288,3 @@ function custom_block_admin_paths() {
);
return $paths;
}
/**
* Implements hook_block_view_alter().
*/
function custom_block_block_view_alter(array &$build, Block $block) {
// Add contextual links for custom blocks.
if ($block->getPlugin() instanceof CustomBlockBlock) {
// Move contextual links from inner content to outer wrapper.
$build['#contextual_links']['custom_block'] = $build['content']['#contextual_links']['custom_block'];
unset($build['content']['#contextual_links']['custom_block']);
}
}
......@@ -23,7 +23,7 @@ class DisplayBlockTest extends ViewTestBase {
*
* @var array
*/
public static $modules = array('block_test_views', 'test_page_test');
public static $modules = array('block_test_views', 'test_page_test', 'contextual', 'views_ui');
/**
* Views used by this test.
......@@ -148,4 +148,14 @@ public function testViewsBlockForm() {
$this->assertTrue(empty($elements), 'The label field is not found for Views blocks.');
}
/**
* Tests the contextual links on a Views block.
*/
public function testBlockContextualLinks() {
$this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links')));
$this->drupalPlaceBlock('views_block:test_view_block-block_1', array(), array('title' => 'test_view_block-block_1:1'));
$this->drupalGet('test-page');
$this->assertLinkByHref("admin/structure/views/view/test_view_block/edit");
}
}
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