summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-10-04 22:45:06 -0700
committerwebchick2015-10-04 22:45:06 -0700
commit680ef1c774504707f6f7def1724f1fc635073088 (patch)
tree786e2754f483021e36a767b7bb6d19d0a042ed14
parent1a70fc1292898cb6b2d19017ddbc4afd5120af13 (diff)
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
-rw-r--r--core/modules/block/src/Tests/BlockAdminThemeTest.php38
-rw-r--r--core/themes/seven/seven.theme14
2 files changed, 51 insertions, 1 deletions
diff --git a/core/modules/block/src/Tests/BlockAdminThemeTest.php b/core/modules/block/src/Tests/BlockAdminThemeTest.php
index e2f44a3..7d34c3b 100644
--- a/core/modules/block/src/Tests/BlockAdminThemeTest.php
+++ b/core/modules/block/src/Tests/BlockAdminThemeTest.php
@@ -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 @@ class BlockAdminThemeTest extends WebTestBase {
$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');
+ }
+
}
diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme
index 7bd56e0..4f7946c 100644
--- a/core/themes/seven/seven.theme
+++ b/core/themes/seven/seven.theme
@@ -84,6 +84,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.
*/
function seven_preprocess_admin_block_content(&$variables) {