diff --git a/core/modules/file/config/install/views.view.files.yml b/core/modules/file/config/install/views.view.files.yml index 41ebb4cee912..ead1fe8beaaf 100644 --- a/core/modules/file/config/install/views.view.files.yml +++ b/core/modules/file/config/install/views.view.files.yml @@ -669,7 +669,7 @@ display: type: tab title: Files description: '' - name: admin + menu_name: admin weight: 0 context: '' display_description: '' diff --git a/core/modules/node/config/install/views.view.content.yml b/core/modules/node/config/install/views.view.content.yml index 855b44a4742d..94cfb666ccf1 100644 --- a/core/modules/node/config/install/views.view.content.yml +++ b/core/modules/node/config/install/views.view.content.yml @@ -549,14 +549,14 @@ display: type: 'default tab' title: Content description: '' - name: admin + menu_name: admin weight: -10 context: '' tab_options: type: normal title: Content description: 'Find and manage content' - name: admin + menu_name: admin weight: -10 field_langcode: '***CURRENT_LANGUAGE***' field_langcode_add_to_query: null diff --git a/core/modules/user/config/install/views.view.user_admin_people.yml b/core/modules/user/config/install/views.view.user_admin_people.yml index 90a1a6588688..1951b74cdb24 100644 --- a/core/modules/user/config/install/views.view.user_admin_people.yml +++ b/core/modules/user/config/install/views.view.user_admin_people.yml @@ -880,14 +880,14 @@ display: type: 'default tab' title: List description: 'Find and manage people interacting with your site.' - name: admin + menu_name: admin weight: -10 context: '' tab_options: type: normal title: People description: 'Manage user accounts, roles, and permissions.' - name: admin + menu_name: admin weight: 0 defaults: show_admin_links: false diff --git a/core/modules/views/config/schema/views.display.schema.yml b/core/modules/views/config/schema/views.display.schema.yml index 5bd1ab35216d..626588b3b003 100644 --- a/core/modules/views/config/schema/views.display.schema.yml +++ b/core/modules/views/config/schema/views.display.schema.yml @@ -34,7 +34,7 @@ views.display.page: weight: type: integer label: 'Weight' - name: + menu_name: type: string label: 'Menu name' context: @@ -56,7 +56,7 @@ views.display.page: weight: type: integer label: 'Weight' - name: + menu_name: type: string label: 'Menu name' diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php index 4e164d739173..2d8cd903b407 100644 --- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php +++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php @@ -132,14 +132,16 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf */ public function updateLink(array $new_definition_values, $persist) { $overrides = array_intersect_key($new_definition_values, $this->overrideAllowed); + // Update the definition. + $this->pluginDefinition = $overrides + $this->pluginDefinition; if ($persist) { $view = $this->loadView(); $display = &$view->storage->getDisplay($view->current_display); // Just save the title to the original view. $changed = FALSE; - foreach (array('title' => 'title', 'weight' => 'weight', 'menu' => 'name', 'description' => 'description') as $definition_key => $views_key) { - if ($display['display_options']['menu'][$views_key] != $new_definition_values[$definition_key]) { - $display['display_options']['menu'][$views_key] = $new_definition_values[$definition_key]; + foreach ($new_definition_values as $key => $new_definition_value) { + if (isset($display['display_options']['menu'][$key]) && $display['display_options']['menu'][$key] != $new_definition_values[$key]) { + $display['display_options']['menu'][$key] = $new_definition_values[$key]; $changed = TRUE; } } @@ -149,8 +151,6 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf $view->storage->save(); } } - // Update the definition. - $this->pluginDefinition = $overrides + $this->pluginDefinition; return $this->pluginDefinition; } diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index a2fab2391eda..6db80c9ba87f 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -50,7 +50,7 @@ class Page extends PathPluginBase { 'title' => array('default' => '', 'translatable' => FALSE), 'description' => array('default' => '', 'translatable' => FALSE), 'weight' => array('default' => 0), - 'name' => array('default' => 'navigation'), + 'menu_name' => array('default' => 'navigation'), 'context' => array('default' => ''), ), ); @@ -61,7 +61,7 @@ class Page extends PathPluginBase { 'title' => array('default' => '', 'translatable' => FALSE), 'description' => array('default' => '', 'translatable' => FALSE), 'weight' => array('default' => 0), - 'name' => array('default' => 'navigation'), + 'menu_name' => array('default' => 'navigation'), ), ); @@ -219,11 +219,11 @@ class Page extends PathPluginBase { // Only display the menu selector if Menu UI module is enabled. if (\Drupal::moduleHandler()->moduleExists('menu_ui')) { - $form['menu']['name'] = array( + $form['menu']['menu_name'] = array( '#title' => t('Menu'), '#type' => 'select', '#options' => menu_ui_get_menus(), - '#default_value' => $menu['name'], + '#default_value' => $menu['menu_name'], '#states' => array( 'visible' => array( array( @@ -237,9 +237,9 @@ class Page extends PathPluginBase { ); } else { - $form['menu']['name'] = array( + $form['menu']['menu_name'] = array( '#type' => 'value', - '#value' => $menu['name'], + '#value' => $menu['menu_name'], ); $form['menu']['markup'] = array( '#markup' => t('Menu selection requires the activation of Menu UI module.'), @@ -350,9 +350,9 @@ class Page extends PathPluginBase { ); } else { - $form['tab_options']['name'] = array( + $form['tab_options']['menu_name'] = array( '#type' => 'value', - '#value' => $tab_options['name'], + '#value' => $tab_options['menu_name'], ); $form['tab_options']['markup'] = array( '#markup' => t('Menu selection requires the activation of Menu UI module.'), diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 0f64d36f51fc..f4f4700e39b9 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -314,7 +314,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter } // Insert item into the proper menu. - $links[$menu_link_id]['menu_name'] = $menu['name']; + $links[$menu_link_id]['menu_name'] = $menu['menu_name']; // Keep track of where we came from. $links[$menu_link_id]['metadata'] = array( 'view_id' => $view_id, diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index 4ea360efd512..6fe999b169ac 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -1018,7 +1018,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { if (!empty($page['link'])) { $display_options['menu']['type'] = 'normal'; $display_options['menu']['title'] = $page['link_properties']['title']; - $display_options['menu']['name'] = $page['link_properties']['menu_name']; + $display_options['menu']['menu_name'] = $page['link_properties']['menu_name']; } return $display_options; } diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php index a8bf8e6b0ef4..3750601ae6b5 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php @@ -21,6 +21,13 @@ class DisplayPageWebTest extends PluginTestBase { */ public static $testViews = array('test_page_display_arguments', 'test_page_display_menu'); + /** + * Modules to enable. + * + * @var array + */ + public static $modules = ['menu_ui', 'block']; + protected function setUp() { parent::setUp(); @@ -73,6 +80,7 @@ class DisplayPageWebTest extends PluginTestBase { * Tests menu settings of page displays. */ public function testPageDisplayMenu() { + // Check local tasks. $this->drupalGet('test_page_display_menu'); $this->assertResponse(200); $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array( @@ -93,6 +101,24 @@ class DisplayPageWebTest extends PluginTestBase { )); $this->assertEqual((string) $element[0], t('Test local tab')); $this->assertTitle(t('Test local page | Drupal')); + + // Check an ordinary menu link. + $admin_user = $this->drupalCreateUser(['administer menu']); + $this->drupalLogin($admin_user); + $this->drupalPlaceBlock('system_menu_block:tools'); + $this->drupalGet(''); + + $menu_link = $this->cssSelect('div.block-menu ul.menu a'); + $this->assertEqual((string) $menu_link[0], 'Test menu link'); + + // Update the menu link. + $this->drupalPostForm("admin/structure/menu/link/views_view:views.test_page_display_menu.page_3/edit", [ + 'title' => 'New title', + ], t('Save')); + + $this->drupalGet(''); + $menu_link = $this->cssSelect('div.block-menu ul.menu a'); + $this->assertEqual((string) $menu_link[0], 'New title'); } } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml index 1d1911bb70bc..a159b36365f5 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml @@ -30,14 +30,14 @@ display: type: 'default tab' title: 'Test default tab' description: '' - name: tools + menu_name: tools weight: '-10' context: '0' tab_options: type: normal title: 'Test parent path' description: '' - name: tools + menu_name: tools weight: '0' defaults: title: '0' @@ -53,7 +53,7 @@ display: type: tab title: 'Test local tab' description: '' - name: tools + menu_name: tools weight: '0' context: '0' defaults: @@ -62,6 +62,23 @@ display: display_title: Page id: page_2 position: 0 + page_3: + display_options: + path: test_page_display_menu_link + title: 'Test menu link' + menu: + type: normal + title: 'Test menu link' + description: '' + menu_name: tools + weight: '0' + context: '0' + defaults: + title: '0' + display_plugin: page + display_title: Page + id: page_3 + position: 0 label: 'Test page menu' id: test_page_display_menu tag: ''