Commit 777bc650 authored by webchick's avatar webchick

Issue #2327373 by dawehner: Standardize view entity route names.

parent c16c1c71
......@@ -275,8 +275,8 @@ public function testBlockContextualLinks() {
$cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('cache' => array('max_age' => 3600)));
$this->drupalGet('test-page');
$id = 'block:block=' . $block->id() . ':|views_ui_edit:view=test_view_block:location=block&name=test_view_block&display_id=block_1';
$cached_id = 'block:block=' . $cached_block->id() . ':|views_ui_edit:view=test_view_block:location=block&name=test_view_block&display_id=block_1';
$id = 'block:block=' . $block->id() . ':|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1';
$cached_id = 'block:block=' . $cached_block->id() . ':|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1';
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
$this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
$this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $cached_id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $cached_id)));
......@@ -287,8 +287,8 @@ public function testBlockContextualLinks() {
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-page')));
$this->assertResponse(200);
$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="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');
$this->assertIdentical($json[$cached_id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</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="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');
$this->assertIdentical($json[$cached_id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');
}
}
......@@ -232,7 +232,7 @@ public function getContextualLinkGroup() {
case 'block':
return $this->entityType;
case 'view':
return 'views_ui_edit';
return 'entity.view.edit_form';
default:
return NULL;
}
......
......@@ -508,7 +508,7 @@ public function testViewsTranslationUI() {
$this->drupalLogin($this->admin_user);
// Assert contextual link related to views.
$ids = array('views_ui_edit:view=frontpage:location=page&name=frontpage&display_id=page_1');
$ids = array('entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1');
$response = $this->renderContextualLinks($ids, 'node');
$this->assertResponse(200);
$json = Json::decode($response);
......
......@@ -60,7 +60,7 @@ function testDifferentPermissions() {
'node:node=' . $node1->id() . ':changed=' . $node1->getChangedTime(),
'node:node=' . $node2->id() . ':changed=' . $node2->getChangedTime(),
'node:node=' . $node3->id() . ':changed=' . $node3->getChangedTime(),
'views_ui_edit:view=frontpage:location=page&name=frontpage&display_id=page_1',
'entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1',
);
// Editor user: can access contextual links and can edit articles.
......
......@@ -152,7 +152,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
);
if ($this->view->storage->access('edit') && \Drupal::moduleHandler()->moduleExists('views_ui')) {
$form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore. (Try changing it directly in <a href="@url">@name</a>.)', array('@url' => \Drupal::url('views_ui.edit_display', array('view' => $this->view->storage->id(), 'display_id' => $this->displayID)), '@name' => $this->view->storage->label()));
$form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore. (Try changing it directly in <a href="@url">@name</a>.)', array('@url' => \Drupal::url('entity.view.edit_display_form', array('view' => $this->view->storage->id(), 'display_id' => $this->displayID)), '@name' => $this->view->storage->label()));
}
else {
$form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore.');
......
......@@ -61,7 +61,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$id = $view->storage->id();
$label = $view->storage->label();
if ($this->moduleHandler->moduleExists('views_ui')) {
$message = $this->t('This link is provided by the Views module. The path can be changed by editing the view <a href="@url">@label</a>', array('@url' => \Drupal::url('views_ui.edit', array('view' => $id)), '@label' => $label));
$message = $this->t('This link is provided by the Views module. The path can be changed by editing the view <a href="@url">@label</a>', array('@url' => \Drupal::url('entity.view.edit_form', array('view' => $id)), '@label' => $label));
}
else {
$message = $this->t('This link is provided by the Views module from view %label.', array('%label' => $label));
......
......@@ -3,8 +3,8 @@ module: views_ui
label: 'Views ui'
langcode: en
routes:
- route_name: views_ui.edit
- route_name: views_ui.edit_display
- route_name: entity.view.edit_form
- route_name: entity.view.edit_display_form
tips:
views-main:
id: views-main
......
......@@ -91,7 +91,7 @@ public function reportFields() {
foreach ($fields as $field_name => $views) {
$rows[$field_name]['data'][0] = String::checkPlain($field_name);
foreach ($views as $view) {
$rows[$field_name]['data'][1][] = $this->l($view, 'views_ui.edit', array('view' => $view));
$rows[$field_name]['data'][1][] = $this->l($view, 'entity.view.edit_form', array('view' => $view));
}
$rows[$field_name]['data'][1] = SafeMarkup::set(implode(', ', $rows[$field_name]['data'][1]));
}
......@@ -119,7 +119,7 @@ public function reportPlugins() {
foreach ($rows as &$row) {
// Link each view name to the view itself.
foreach ($row['views'] as $row_name => $view) {
$row['views'][$row_name] = $this->l($view, 'views_ui.edit', array('view' => $view));
$row['views'][$row_name] = $this->l($view, 'entity.view.edit_form', array('view' => $view));
}
$row['views'] = SafeMarkup::set(implode(', ', $row['views']));
}
......
......@@ -91,13 +91,13 @@ public function testDisplayPluginsAlter() {
$definitions = Views::pluginManager('display')->getDefinitions();
$expected = array(
'route_name' => 'views_ui.edit',
'route_name' => 'entity.view.edit_form',
'route_parameters_names' => array('view' => 'id'),
);
// Test the expected views_ui array exists on each definition.
foreach ($definitions as $definition) {
$this->assertIdentical($definition['contextual links']['views_ui_edit'], $expected, 'Expected views_ui array found in plugin definition.');
$this->assertIdentical($definition['contextual links']['entity.view.edit_form'], $expected, 'Expected views_ui array found in plugin definition.');
}
}
......@@ -175,7 +175,7 @@ public function testPageContextualLinks() {
$view->enable()->save();
$this->drupalGet('test-display');
$id = 'views_ui_edit:view=test_display:location=page&name=test_display&display_id=page_1';
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1';
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
$this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
......@@ -185,7 +185,7 @@ public function testPageContextualLinks() {
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-display')));
$this->assertResponse(200);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
}
/**
......
......@@ -141,7 +141,7 @@ public function form(array $form, FormStateInterface $form_state) {
$lock_message_substitutions = array(
'!user' => drupal_render($username),
'!age' => $this->dateFormatter->formatInterval(REQUEST_TIME - $view->lock->updated),
'!break' => $view->url('break-lock'),
'!break' => $view->url('break-lock-form'),
);
$form['locked'] = array(
'#type' => 'container',
......@@ -296,7 +296,7 @@ public function submit(array $form, FormStateInterface $form_state) {
unset($displays[$id]);
// Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $new_id,
));
......@@ -592,7 +592,7 @@ public function submitDisplayUndoDelete($form, FormStateInterface $form_state) {
$view->cacheSet();
// Redirect to the top-level edit page.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $id,
));
......@@ -611,7 +611,7 @@ public function submitDisplayEnable($form, FormStateInterface $form_state) {
$view->cacheSet();
// Redirect to the top-level edit page.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $id,
));
......@@ -629,7 +629,7 @@ public function submitDisplayDisable($form, FormStateInterface $form_state) {
$view->cacheSet();
// Redirect to the top-level edit page.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $id,
));
......@@ -708,7 +708,7 @@ public function renderDisplayTop(ViewUI $view) {
),
'duplicate' => array(
'title' => $this->t('Duplicate view'),
) + $view->urlInfo('duplicate')->toArray(),
) + $view->urlInfo('duplicate-form')->toArray(),
'reorder' => array(
'title' => $this->t('Reorder displays'),
'href' => "admin/structure/views/nojs/reorder-displays/{$view->id()}/$display_id",
......@@ -827,7 +827,7 @@ public function submitDisplayDuplicate($form, FormStateInterface $form_state) {
$view->cacheSet();
// Redirect to the new display's edit page.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $new_display_id,
));
......@@ -849,7 +849,7 @@ public function submitDisplayAdd($form, FormStateInterface $form_state) {
$view->cacheSet();
// Redirect to the new display's edit page.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $display_id,
));
......@@ -885,7 +885,7 @@ public function submitDuplicateDisplayAsType($form, FormStateInterface $form_sta
$view->cacheSet();
// Redirect to the new display's edit page.
$form_state->setRedirect('views_ui.edit_display', array(
$form_state->setRedirect('entity.view.edit_display_form', array(
'view' => $view->id(),
'display_id' => $new_display_id,
));
......
......@@ -145,17 +145,17 @@ public function buildHeader() {
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if ($entity->hasLinkTemplate('duplicate')) {
if ($entity->hasLinkTemplate('duplicate-form')) {
$operations['duplicate'] = array(
'title' => $this->t('Duplicate'),
'weight' => 15,
) + $entity->urlInfo('duplicate')->toArray();
) + $entity->urlInfo('duplicate-form')->toArray();
}
// Add AJAX functionality to enable/disable operations.
foreach (array('enable', 'disable') as $op) {
if (isset($operations[$op])) {
$operations[$op]['route_name'] = "views_ui.$op";
$operations[$op]['route_name'] = "entity.view.{$op}";
$operations[$op]['route_parameters'] = array('view' => $entity->id());
// Enable and disable operations should use AJAX.
......
......@@ -635,7 +635,7 @@ public function renderPreview($display_id, $args = array()) {
$show_additional_queries = $config->get('ui.show.additional_queries');
Timer::start('views_ui.preview');
Timer::start('entity.view.preview_form');
if ($show_additional_queries) {
$this->startQueryCapture();
......@@ -649,7 +649,7 @@ public function renderPreview($display_id, $args = array()) {
$this->endQueryCapture();
}
$this->render_time = Timer::stop('views_ui.preview');
$this->render_time = Timer::stop('entity.view.preview_form');
views_ui_contextual_links_suppress_pop();
......
views_ui.edit:
entity.view.edit_form:
title: 'Edit view'
route_name: views_ui.edit
group: views_ui_edit
route_name: entity.view.edit_form
group: entity.view.edit_form
views_ui.preview:
entity.view.preview_form:
title: 'Preview view'
route_name: views_ui.preview
group: views_ui_preview
route_name: entity.view.preview_form
group: entity.view.preview_form
......@@ -24,7 +24,7 @@ views_ui.reports_fields:
title: 'Used in views'
base_route: field_ui.list
views_ui.edit:
entity.view.edit_form:
title: 'Edit'
route_name: views_ui.edit
base_route: views_ui.edit
route_name: entity.view.edit_form
base_route: entity.view.edit_form
......@@ -51,14 +51,14 @@ function views_ui_entity_type_build(array &$entity_types) {
->setFormClass('delete', 'Drupal\views_ui\ViewDeleteForm')
->setFormClass('break_lock', 'Drupal\views_ui\Form\BreakLockForm')
->setListBuilderClass('Drupal\views_ui\ViewListBuilder')
->setLinkTemplate('edit-form', 'views_ui.edit')
->setLinkTemplate('edit-display-form', 'views_ui.edit_display')
->setLinkTemplate('preview-form', 'views_ui.preview')
->setLinkTemplate('duplicate', 'views_ui.duplicate')
->setLinkTemplate('delete-form', 'views_ui.delete')
->setLinkTemplate('enable', 'views_ui.enable')
->setLinkTemplate('disable', 'views_ui.disable')
->setLinkTemplate('break-lock', 'views_ui.break_lock');
->setLinkTemplate('edit-form', 'entity.view.edit_form')
->setLinkTemplate('edit-display-form', 'entity.view.edit_display_form')
->setLinkTemplate('preview-form', 'entity.view.preview_form')
->setLinkTemplate('duplicate-form', 'entity.view.duplicate_form')
->setLinkTemplate('delete-form', 'entity.view.delete_form')
->setLinkTemplate('enable', 'entity.view.enable')
->setLinkTemplate('disable', 'entity.view.disable')
->setLinkTemplate('break-lock-form', 'entity.view.break_lock_form');
}
/**
......@@ -223,8 +223,8 @@ function views_ui_views_plugins_display_alter(&$plugins) {
// paths underneath "admin/structure/views/view/{$view->id()}" (i.e., paths
// for editing and performing other contextual actions on the view).
foreach ($plugins as &$display) {
$display['contextual links']['views_ui_edit'] = array(
'route_name' => 'views_ui.edit',
$display['contextual links']['entity.view.edit_form'] = array(
'route_name' => 'entity.view.edit_form',
'route_parameters_names' => array('view' => 'id'),
);
}
......@@ -242,10 +242,10 @@ function views_ui_contextual_links_view_alter(&$element, $items) {
// Append the display ID to the Views UI edit links, so that clicking on the
// contextual link takes you directly to the correct display tab on the edit
// screen.
elseif (!empty($element['#links']['views-uiedit'])) {
$display_id = $items['views_ui.edit']['metadata']['display_id'];
$element['#links']['views-uiedit']['route_parameters']['display_id'] = $display_id;
$element['#links']['views-uiedit']['route_name'] = 'views_ui.edit_display';
elseif (!empty($element['#links']['entityviewedit-form'])) {
$display_id = $items['entity.view.edit_form']['metadata']['display_id'];
$element['#links']['entityviewedit-form']['route_parameters']['display_id'] = $display_id;
$element['#links']['entityviewedit-form']['route_name'] = 'entity.view.edit_display_form';
}
}
......
......@@ -46,7 +46,7 @@ views_ui.reports_plugins:
requirements:
_permission: 'administer views'
views_ui.enable:
entity.view.enable:
path: '/admin/structure/views/view/{view}/enable'
defaults:
_controller: '\Drupal\views_ui\Controller\ViewsUIController::ajaxOperation'
......@@ -55,7 +55,7 @@ views_ui.enable:
_entity_access: view.enable
_csrf_token: 'TRUE'
views_ui.disable:
entity.view.disable:
path: '/admin/structure/views/view/{view}/disable'
defaults:
_controller: '\Drupal\views_ui\Controller\ViewsUIController::ajaxOperation'
......@@ -64,7 +64,7 @@ views_ui.disable:
_entity_access: view.disable
_csrf_token: 'TRUE'
views_ui.duplicate:
entity.view.duplicate_form:
path: '/admin/structure/views/view/{view}/duplicate'
defaults:
_entity_form: 'view.duplicate'
......@@ -72,7 +72,7 @@ views_ui.duplicate:
requirements:
_entity_access: view.duplicate
views_ui.delete:
entity.view.delete_form:
path: '/admin/structure/views/view/{view}/delete'
defaults:
_entity_form: 'view.delete'
......@@ -87,7 +87,7 @@ views_ui.autocomplete:
requirements:
_permission: 'administer views'
views_ui.edit:
entity.view.edit_form:
path: '/admin/structure/views/view/{view}'
options:
parameters:
......@@ -99,7 +99,7 @@ views_ui.edit:
requirements:
_entity_access: view.update
views_ui.edit_display:
entity.view.edit_display_form:
path: '/admin/structure/views/view/{view}/edit/{display_id}'
options:
parameters:
......@@ -112,7 +112,7 @@ views_ui.edit_display:
requirements:
_entity_access: view.update
views_ui.preview:
entity.view.preview_form:
path: '/admin/structure/views/view/{view}/preview/{display_id}'
options:
parameters:
......@@ -125,7 +125,7 @@ views_ui.preview:
requirements:
_permission: 'administer views'
views_ui.break_lock:
entity.view.break_lock_form:
path: '/admin/structure/views/view/{view}/break-lock'
defaults:
_entity_form: 'view.break_lock'
......
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