Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
33066b7e
Commit
33066b7e
authored
10 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2314985
by idebr, dawehner: Always add contextual links to menu blocks
parent
71502cc0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/menu_ui/menu_ui.module
+2
-4
2 additions, 4 deletions
core/modules/menu_ui/menu_ui.module
core/modules/menu_ui/src/Tests/MenuTest.php
+6
-5
6 additions, 5 deletions
core/modules/menu_ui/src/Tests/MenuTest.php
with
8 additions
and
9 deletions
core/modules/menu_ui/menu_ui.module
+
2
−
4
View file @
33066b7e
...
@@ -117,10 +117,8 @@ function menu_ui_menu_delete(Menu $menu) {
...
@@ -117,10 +117,8 @@ function menu_ui_menu_delete(Menu $menu) {
* Implements hook_block_view_BASE_BLOCK_ID_alter() for 'system_menu_block'.
* Implements hook_block_view_BASE_BLOCK_ID_alter() for 'system_menu_block'.
*/
*/
function
menu_ui_block_view_system_menu_block_alter
(
array
&
$build
,
BlockPluginInterface
$block
)
{
function
menu_ui_block_view_system_menu_block_alter
(
array
&
$build
,
BlockPluginInterface
$block
)
{
// Add contextual links for system menu blocks.
if
(
$block
->
getBaseId
()
==
'system_menu_block'
)
{
$menus
=
menu_list_system_menus
();
$menu_name
=
$block
->
getDerivativeId
();
$menu_name
=
$block
->
getDerivativeId
();
if
(
isset
(
$menus
[
$menu_name
]))
{
$build
[
'#contextual_links'
][
'menu'
]
=
array
(
$build
[
'#contextual_links'
][
'menu'
]
=
array
(
'route_parameters'
=>
array
(
'menu'
=>
$menu_name
),
'route_parameters'
=>
array
(
'menu'
=>
$menu_name
),
);
);
...
...
This diff is collapsed.
Click to expand it.
core/modules/menu_ui/src/Tests/MenuTest.php
+
6
−
5
View file @
33066b7e
...
@@ -540,11 +540,12 @@ function testUnpublishedNodeMenuItem() {
...
@@ -540,11 +540,12 @@ function testUnpublishedNodeMenuItem() {
*/
*/
public
function
testBlockContextualLinks
()
{
public
function
testBlockContextualLinks
()
{
$this
->
drupalLogin
(
$this
->
drupalCreateUser
(
array
(
'administer menu'
,
'access contextual links'
,
'administer blocks'
)));
$this
->
drupalLogin
(
$this
->
drupalCreateUser
(
array
(
'administer menu'
,
'access contextual links'
,
'administer blocks'
)));
$this
->
addMenuLink
();
$custom_menu
=
$this
->
addCustomMenu
();
$block
=
$this
->
drupalPlaceBlock
(
'system_menu_block:tools'
,
array
(
'label'
=>
'Tools'
,
'provider'
=>
'system'
));
$this
->
addMenuLink
(
''
,
'<front>'
,
$custom_menu
->
id
());
$block
=
$this
->
drupalPlaceBlock
(
'system_menu_block:'
.
$custom_menu
->
id
(),
array
(
'label'
=>
'Custom menu'
,
'provider'
=>
'system'
));
$this
->
drupalGet
(
'test-page'
);
$this
->
drupalGet
(
'test-page'
);
$id
=
'block:block='
.
$block
->
id
()
.
':|menu:menu=
tools
:'
;
$id
=
'block:block='
.
$block
->
id
()
.
':|menu:menu=
'
.
$custom_menu
->
id
()
.
'
:'
;
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
$this
->
assertRaw
(
'<div data-contextual-id="'
.
$id
.
'"></div>'
,
format_string
(
'Contextual link placeholder with id @id exists.'
,
array
(
'@id'
=>
$id
)));
$this
->
assertRaw
(
'<div data-contextual-id="'
.
$id
.
'"></div>'
,
format_string
(
'Contextual link placeholder with id @id exists.'
,
array
(
'@id'
=>
$id
)));
...
@@ -554,12 +555,12 @@ public function testBlockContextualLinks() {
...
@@ -554,12 +555,12 @@ public function testBlockContextualLinks() {
$response
=
$this
->
drupalPost
(
'contextual/render'
,
'application/json'
,
$post
,
array
(
'query'
=>
array
(
'destination'
=>
'test-page'
)));
$response
=
$this
->
drupalPost
(
'contextual/render'
,
'application/json'
,
$post
,
array
(
'query'
=>
array
(
'destination'
=>
'test-page'
)));
$this
->
assertResponse
(
200
);
$this
->
assertResponse
(
200
);
$json
=
Json
::
decode
(
$response
);
$json
=
Json
::
decode
(
$response
);
$this
->
assertIdentical
(
$json
[
$id
],
'<ul class="contextual-links"><li class="block-configure"><a href="'
.
base_path
()
.
'admin/structure/block/manage/'
.
$block
->
id
()
.
'">Configure block</a></li><li class="entitymenuedit-form"><a href="'
.
base_path
()
.
'admin/structure/menu/manage/
tools
">Edit menu</a></li></ul>'
);
$this
->
assertIdentical
(
$json
[
$id
],
'<ul class="contextual-links"><li class="block-configure"><a href="'
.
base_path
()
.
'admin/structure/block/manage/'
.
$block
->
id
()
.
'">Configure block</a></li><li class="entitymenuedit-form"><a href="'
.
base_path
()
.
'admin/structure/menu/manage/
'
.
$custom_menu
->
id
()
.
'
">Edit menu</a></li></ul>'
);
// Test the contextual links are available when block caching is enabled.
// Test the contextual links are available when block caching is enabled.
$this
->
drupalPostForm
(
'admin/structure/block/manage/'
.
$block
->
id
(),
[
'settings[cache][max_age]'
=>
Cache
::
PERMANENT
],
t
(
'Save block'
));
$this
->
drupalPostForm
(
'admin/structure/block/manage/'
.
$block
->
id
(),
[
'settings[cache][max_age]'
=>
Cache
::
PERMANENT
],
t
(
'Save block'
));
$this
->
drupalGet
(
'test-page'
);
$this
->
drupalGet
(
'test-page'
);
$id
=
'block:block='
.
$block
->
id
()
.
':|menu:menu=
tools
:'
;
$id
=
'block:block='
.
$block
->
id
()
.
':|menu:menu=
'
.
$custom_menu
->
id
()
.
'
:'
;
$this
->
assertRaw
(
'<div data-contextual-id="'
.
$id
.
'"></div>'
,
format_string
(
'Contextual link placeholder with id @id exists.'
,
array
(
'@id'
=>
$id
)));
$this
->
assertRaw
(
'<div data-contextual-id="'
.
$id
.
'"></div>'
,
format_string
(
'Contextual link placeholder with id @id exists.'
,
array
(
'@id'
=>
$id
)));
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment