From 0707a705e235ab1862050e07740b77e513a05770 Mon Sep 17 00:00:00 2001 From: Lauri Eskola <lauriii@1078742.no-reply.drupal.org> Date: Sat, 15 Apr 2017 13:19:10 +0300 Subject: [PATCH] Issue #2784567 by tedbow, 20th, dmsmidt, miteshmap, dbjpanda, bendev, crasx, tkoleary: List "Quick edit" before "Configure" in contextual links while in Edit mode --- core/modules/outside_in/outside_in.module | 5 +++++ .../OutsideInBlockFormTest.php | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/modules/outside_in/outside_in.module b/core/modules/outside_in/outside_in.module index a7fab7bd2cb9..315e97b95e4f 100644 --- a/core/modules/outside_in/outside_in.module +++ b/core/modules/outside_in/outside_in.module @@ -34,6 +34,11 @@ function outside_in_help($route_name, RouteMatchInterface $route_match) { */ function outside_in_contextual_links_view_alter(&$element, $items) { if (isset($element['#links']['outside-inblock-configure'])) { + // Place outside_in link first. + $outside_in_link = $element['#links']['outside-inblock-configure']; + unset($element['#links']['outside-inblock-configure']); + $element['#links'] = ['outside-inblock-configure' => $outside_in_link] + $element['#links']; + $element['#links']['outside-inblock-configure']['attributes'] = [ 'class' => ['use-ajax'], 'data-dialog-type' => 'dialog', diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index c62436ca165c..cd82026e52d4 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -62,8 +62,13 @@ protected function setUp() { public function testBlocks($block_id, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item) { $web_assert = $this->assertSession(); $page = $this->getSession()->getPage(); - $block_selector = '#' . $block_id; + $block_selector = '#block-' . $block_id; $this->drupalGet('user'); + + $link = $page->find('css', "$block_selector .contextual-links li a"); + $this->assertEquals('Quick edit', $link->getText(), "'Quick edit' is the first contextual link for the block."); + $this->assertContains("/admin/structure/block/manage/$block_id/offcanvas?destination=user/2", $link->getAttribute('href')); + if (isset($toolbar_item)) { // Check that you can open a toolbar tray and it will be closed after // entering edit mode. @@ -83,13 +88,13 @@ public function testBlocks($block_id, $new_page_text, $element_selector, $label_ $this->openBlockForm($block_selector); switch ($block_id) { - case 'block-powered': + case 'powered': // Fill out form, save the form. $page->fillField('settings[label]', $new_page_text); $page->checkField('settings[label_display]'); break; - case 'block-branding': + case 'branding': // Fill out form, save the form. $page->fillField('settings[site_information][site_name]', $new_page_text); break; @@ -137,7 +142,7 @@ public function testBlocks($block_id, $new_page_text, $element_selector, $label_ public function providerTestBlocks() { $blocks = [ 'block-powered' => [ - 'id' => 'block-powered', + 'id' => 'powered', 'new_page_text' => 'Can you imagine anyone showing the label on this block?', 'element_selector' => '.content a', 'label_selector' => 'h2', @@ -145,7 +150,7 @@ public function providerTestBlocks() { 'toolbar_item' => '#toolbar-item-user', ], 'block-branding' => [ - 'id' => 'block-branding', + 'id' => 'branding', 'new_page_text' => 'The site that will live a very short life.', 'element_selector' => 'a[rel="home"]:nth-child(2)', 'label_selector' => '.site-branding__name a', @@ -153,7 +158,7 @@ public function providerTestBlocks() { 'toolbar_item' => '#toolbar-item-administration', ], 'block-search' => [ - 'id' => 'block-search', + 'id' => 'search', 'new_page_text' => NULL, 'element_selector' => '#edit-submit', 'label_selector' => 'h2', -- GitLab