Commit 680ef1c7 authored by webchick's avatar webchick

Issue #2487025 by shellshocked59, harings_rob, rteijeiro, subhojit777,...

Issue #2487025 by shellshocked59, harings_rob, rteijeiro, subhojit777, vijaycs85, ashutoshsngh, aburrows, swetashahi, mradcliffe, Wim Leers, lauriii, LewisNyman, Bojhan, DeeLay, B_man, davidhernandez, lizzjoy, lweinmeister, wizonesolutions, arh1, GenerUmali, tstoeckler: Remove contextual links in Seven
parent 1a70fc12
......@@ -21,7 +21,7 @@ class BlockAdminThemeTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('block');
public static $modules = array('block', 'contextual');
/**
* Check for the accessibility of the admin theme on the block admin page.
......@@ -43,4 +43,40 @@ function testAdminTheme() {
$this->drupalGet('admin/structure/block/list/bartik');
$this->assertResponse(200);
}
/**
* Ensure contextual links are disabled in Seven theme.
*/
function testSevenAdminTheme() {
// Create administrative user.
$admin_user = $this->drupalCreateUser([
'access administration pages',
'administer themes',
'access contextual links',
'view the administration theme',
]);
$this->drupalLogin($admin_user);
// Install admin theme and confirm that tab is accessible.
\Drupal::service('theme_handler')->install(['seven']);
$edit['admin_theme'] = 'seven';
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
// Define our block settings.
$settings = [
'theme' => 'seven',
'region' => 'header',
];
// Place a block.
$block = $this->drupalPlaceBlock('local_tasks_block', $settings);
// Open admin page.
$this->drupalGet('admin');
// Check if contextual link classes are unavailable.
$this->assertNoRaw('<div data-contextual-id="block:block=' . $block->id() . ':langcode=en"></div>');
$this->assertNoRaw('contextual-region');
}
}
......@@ -83,6 +83,20 @@ function seven_preprocess_block_content_add_list(&$variables) {
}
}
/**
* Implements hook_preprocess_block() for block content.
*
* Disables contextual links for all blocks.
*/
function seven_preprocess_block(&$variables) {
if (isset($variables['title_suffix']['contextual_links'])) {
unset($variables['title_suffix']['contextual_links']);
unset($variables['elements']['#contextual_links']);
$variables['attributes']['class'] = array_diff($variables['attributes']['class'], ['contextual-region']);
}
}
/**
* Implements hook_preprocess_HOOK() for block admin page templates.
*/
......
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