Issue #2252743 by amitgoyal, er.pushpinderrana, jonreid, lexfunk: Rename 'clone' to 'duplicate' for displays in Views UI.
parent
7aacd4eae4
commit
4f086d1f7e
|
@ -78,8 +78,8 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
$elements = $this->xpath('//details[@id=:id]//li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
|
||||
$this->assertTrue(!empty($elements), 'The test block appears in the category for its base table.');
|
||||
|
||||
// Clone the block before changing the category.
|
||||
$this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', array(), t('Clone @display_title', array('@display_title' => 'Block')));
|
||||
// Duplicate the block before changing the category.
|
||||
$this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', array(), t('Duplicate @display_title', array('@display_title' => 'Block')));
|
||||
$this->assertUrl('admin/structure/views/view/' . $edit['id'] . '/edit/block_2');
|
||||
|
||||
// Change the block category to a random string.
|
||||
|
@ -91,8 +91,8 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
$category = $this->randomString();
|
||||
$this->drupalPostForm(NULL, array('block_category' => $category), t('Apply'));
|
||||
|
||||
// Clone the block after changing the category.
|
||||
$this->drupalPostForm(NULL, array(), t('Clone @display_title', array('@display_title' => 'Block')));
|
||||
// Duplicate the block after changing the category.
|
||||
$this->drupalPostForm(NULL, array(), t('Duplicate @display_title', array('@display_title' => 'Block')));
|
||||
$this->assertUrl('admin/structure/views/view/' . $edit['id'] . '/edit/block_3');
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
|
@ -111,7 +111,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
':text' => $edit['label'],
|
||||
);
|
||||
$elements = $this->xpath('//details[@id=:id]//li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
|
||||
$this->assertTrue(!empty($elements), 'The first cloned test block remains in the original category.');
|
||||
$this->assertTrue(!empty($elements), 'The first duplicated test block remains in the original category.');
|
||||
|
||||
$arguments = array(
|
||||
':id' => $category_id,
|
||||
|
@ -120,7 +120,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
':text' => $edit['label'],
|
||||
);
|
||||
$elements = $this->xpath('//details[@id=:id]//li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
|
||||
$this->assertTrue(!empty($elements), 'The second cloned test block appears in the custom category.');
|
||||
$this->assertTrue(!empty($elements), 'The second duplicated test block appears in the custom category.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ class BasicTest extends WizardTestBase {
|
|||
$this->assertText($view1['description']);
|
||||
$this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id']));
|
||||
$this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'] . '/delete'));
|
||||
$this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'] . '/clone'));
|
||||
$this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'] . '/duplicate'));
|
||||
|
||||
// This view should not have a block.
|
||||
$this->drupalGet('admin/structure/block');
|
||||
|
|
|
@ -102,7 +102,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$data['views_test_data']['job']['area']['id'] = 'text';
|
||||
$data['views_test_data']['job']['area']['sub_type'] = array('header', 'footer');
|
||||
|
||||
// Clone the example views test data for different weight, different title,
|
||||
// Duplicate the example views test data for different weight, different title,
|
||||
// and matching data.
|
||||
$data['views_test_data_2'] = $data['views_test_data'];
|
||||
$data['views_test_data_2']['table']['base']['weight'] = 50;
|
||||
|
|
|
@ -80,21 +80,21 @@ class DefaultViewsTest extends UITestBase {
|
|||
// $this->drupalGet('glossary');
|
||||
// $this->assertNoText($new_title);
|
||||
|
||||
// Clone the view and check that the normal schema of cloned views is used.
|
||||
// Duplicate the view and check that the normal schema of duplicated views is used.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Clone'), '/glossary');
|
||||
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
|
||||
$edit = array(
|
||||
'id' => 'clone_of_glossary',
|
||||
'id' => 'duplicate_of_glossary',
|
||||
);
|
||||
$this->assertTitle(t('Clone of @label | @site-name', array('@label' => 'Glossary', '@site-name' => \Drupal::config('system.site')->get('name'))));
|
||||
$this->drupalPostForm(NULL, $edit, t('Clone'));
|
||||
$this->assertUrl('admin/structure/views/view/clone_of_glossary', array(), 'The normal cloning name schema is applied.');
|
||||
$this->assertTitle(t('Duplicate of @label | @site-name', array('@label' => 'Glossary', '@site-name' => \Drupal::config('system.site')->get('name'))));
|
||||
$this->drupalPostForm(NULL, $edit, t('Duplicate'));
|
||||
$this->assertUrl('admin/structure/views/view/duplicate_of_glossary', array(), 'The normal duplicating name schema is applied.');
|
||||
|
||||
// Clone a view and set a custom name.
|
||||
// Duplicate a view and set a custom name.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Clone'), '/glossary');
|
||||
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
|
||||
$random_name = strtolower($this->randomName());
|
||||
$this->drupalPostForm(NULL, array('id' => $random_name), t('Clone'));
|
||||
$this->drupalPostForm(NULL, array('id' => $random_name), t('Duplicate'));
|
||||
$this->assertUrl("admin/structure/views/view/$random_name", array(), 'The custom view name got saved.');
|
||||
|
||||
// Now disable the view, and make sure it stops appearing on the main view
|
||||
|
|
|
@ -226,7 +226,7 @@ class DisplayTest extends UITestBase {
|
|||
|
||||
$placeholder = array('!display_title' => $display_title);
|
||||
// Ensure that the dropdown buttons are displayed correctly.
|
||||
$this->assertFieldByXpath('//input[@type="submit"]', t('Clone !display_title', $placeholder));
|
||||
$this->assertFieldByXpath('//input[@type="submit"]', t('Duplicate !display_title', $placeholder));
|
||||
$this->assertFieldByXpath('//input[@type="submit"]', t('Delete !display_title', $placeholder));
|
||||
$this->assertFieldByXpath('//input[@type="submit"]', t('Disable !display_title', $placeholder));
|
||||
$this->assertNoFieldByXpath('//input[@type="submit"]', t('Enable !display_title', $placeholder));
|
||||
|
|
|
@ -109,15 +109,15 @@ class DisplayTestCRUD extends UITestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests the cloning of a display.
|
||||
* Tests the duplicating of a display.
|
||||
*/
|
||||
public function testCloneDisplay() {
|
||||
public function testDuplicateDisplay() {
|
||||
$view = $this->randomView();
|
||||
$path_prefix = 'admin/structure/views/view/' . $view['id'] .'/edit';
|
||||
|
||||
$this->drupalGet($path_prefix);
|
||||
$this->drupalPostForm(NULL, array(), 'Clone Page');
|
||||
$this->assertLinkByHref($path_prefix . '/page_2', 0, 'Make sure after cloning the new display appears in the UI');
|
||||
$this->drupalPostForm(NULL, array(), 'Duplicate Page');
|
||||
$this->assertLinkByHref($path_prefix . '/page_2', 0, 'Make sure after duplicating the new display appears in the UI');
|
||||
$this->assertUrl($path_prefix . '/page_2', array(), 'The user got redirected to the new display.');
|
||||
|
||||
// Set the title and override the css classes.
|
||||
|
@ -126,9 +126,9 @@ class DisplayTestCRUD extends UITestBase {
|
|||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/title", array('title' => $random_title), t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/css_class", array('override[dropdown]' => 'page_2', 'css_class' => $random_css), t('Apply'));
|
||||
|
||||
// Clone as a different display type.
|
||||
$this->drupalPostForm(NULL, array(), 'Clone as Block');
|
||||
$this->assertLinkByHref($path_prefix . '/block_1', 0, 'Make sure after cloning the new display appears in the UI');
|
||||
// Duplicate as a different display type.
|
||||
$this->drupalPostForm(NULL, array(), 'Duplicate as Block');
|
||||
$this->assertLinkByHref($path_prefix . '/block_1', 0, 'Make sure after duplicating the new display appears in the UI');
|
||||
$this->assertUrl($path_prefix . '/block_1', array(), 'The user got redirected to the new display.');
|
||||
$this->assertText(t('Block settings'));
|
||||
$this->assertNoText(t('Page settings'));
|
||||
|
@ -144,8 +144,8 @@ class DisplayTestCRUD extends UITestBase {
|
|||
$this->assertTrue($block_1, 'The new block display got saved.');
|
||||
$this->assertEqual($block_1->display['display_plugin'], 'block');
|
||||
$this->assertEqual($block_1->display['display_title'], 'Block', 'The new display title got generated as expected.');
|
||||
$this->assertEqual($block_1->getOption('title'), $random_title, 'The overridden title option from the display got copied into the clone');
|
||||
$this->assertEqual($block_1->getOption('css_class'), $random_css, 'The overridden css_class option from the display got copied into the clone');
|
||||
$this->assertEqual($block_1->getOption('title'), $random_title, 'The overridden title option from the display got copied into the duplicate');
|
||||
$this->assertEqual($block_1->getOption('css_class'), $random_css, 'The overridden css_class option from the display got copied into the duplicate');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\views_ui\ViewCloneForm.
|
||||
* Contains \Drupal\views_ui\ViewDuplicateForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\views_ui;
|
||||
|
||||
/**
|
||||
* Form controller for the Views clone form.
|
||||
* Form controller for the Views duplicate form.
|
||||
*/
|
||||
class ViewCloneForm extends ViewFormBase {
|
||||
class ViewDuplicateForm extends ViewFormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -25,7 +25,7 @@ class ViewCloneForm extends ViewFormBase {
|
|||
public function form(array $form, array &$form_state) {
|
||||
parent::form($form, $form_state);
|
||||
|
||||
$form['#title'] = $this->t('Clone of @label', array('@label' => $this->entity->label()));
|
||||
$form['#title'] = $this->t('Duplicate of @label', array('@label' => $this->entity->label()));
|
||||
|
||||
$form['label'] = array(
|
||||
'#type' => 'textfield',
|
||||
|
@ -33,7 +33,7 @@ class ViewCloneForm extends ViewFormBase {
|
|||
'#required' => TRUE,
|
||||
'#size' => 32,
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => $this->t('Clone of @label', array('@label' => $this->entity->label())),
|
||||
'#default_value' => $this->t('Duplicate of @label', array('@label' => $this->entity->label())),
|
||||
);
|
||||
$form['id'] = array(
|
||||
'#type' => 'machine_name',
|
||||
|
@ -55,7 +55,7 @@ class ViewCloneForm extends ViewFormBase {
|
|||
protected function actions(array $form, array &$form_state) {
|
||||
$actions['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Clone'),
|
||||
'#value' => $this->t('Duplicate'),
|
||||
'#submit' => array(
|
||||
array($this, 'submit'),
|
||||
),
|
|
@ -375,7 +375,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
);
|
||||
|
||||
$is_display_deleted = !empty($display['deleted']);
|
||||
// The master display cannot be cloned.
|
||||
// The master display cannot be duplicated.
|
||||
$is_default = $display['id'] == 'default';
|
||||
// @todo: Figure out why getOption doesn't work here.
|
||||
$is_enabled = $view->getExecutable()->displayHandlers->get($display['id'])->isEnabled();
|
||||
|
@ -423,7 +423,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
if (!$is_default) {
|
||||
$build['top']['actions']['duplicate'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Clone !display_title', array('!display_title' => $display_title)),
|
||||
'#value' => $this->t('Duplicate !display_title', array('!display_title' => $display_title)),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array(array($this, 'submitDisplayDuplicate'), array($this, 'submitDelayDestination')),
|
||||
'#prefix' => '<li class="duplicate">',
|
||||
|
@ -445,11 +445,11 @@ class ViewEditForm extends ViewFormBase {
|
|||
continue;
|
||||
}
|
||||
|
||||
$build['top']['actions']['clone_as'][$type] = array(
|
||||
$build['top']['actions']['duplicate_as'][$type] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Clone as !type', array('!type' => $label)),
|
||||
'#value' => $this->t('Duplicate as !type', array('!type' => $label)),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array(array($this, 'submitCloneDisplayAsType'), array($this, 'submitDelayDestination')),
|
||||
'#submit' => array(array($this, 'submitDuplicateDisplayAsType'), array($this, 'submitDelayDestination')),
|
||||
'#prefix' => '<li class="duplicate">',
|
||||
'#suffix' => '</li>',
|
||||
);
|
||||
|
@ -690,9 +690,9 @@ class ViewEditForm extends ViewFormBase {
|
|||
'href' => "admin/structure/views/nojs/analyze/{$view->id()}/$display_id",
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
),
|
||||
'clone' => array(
|
||||
'title' => $this->t('Clone view'),
|
||||
) + $view->urlInfo('clone')->toArray(),
|
||||
'duplicate' => array(
|
||||
'title' => $this->t('Duplicate view'),
|
||||
) + $view->urlInfo('duplicate')->toArray(),
|
||||
'reorder' => array(
|
||||
'title' => $this->t('Reorder displays'),
|
||||
'href' => "admin/structure/views/nojs/reorder-displays/{$view->id()}/$display_id",
|
||||
|
@ -834,9 +834,9 @@ class ViewEditForm extends ViewFormBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Submit handler to clone a display as another display type.
|
||||
* Submit handler to Duplicate a display as another display type.
|
||||
*/
|
||||
public function submitCloneDisplayAsType($form, &$form_state) {
|
||||
public function submitDuplicateDisplayAsType($form, &$form_state) {
|
||||
$view = $this->entity;
|
||||
$display_id = $this->displayID;
|
||||
|
||||
|
@ -849,11 +849,11 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
// Let the display title be generated by the addDisplay method and set the
|
||||
// right display plugin, but keep the rest from the original display.
|
||||
$display_clone = $displays[$display_id];
|
||||
unset($display_clone['display_title']);
|
||||
unset($display_clone['display_plugin']);
|
||||
$display_duplicate = $displays[$display_id];
|
||||
unset($display_duplicate['display_title']);
|
||||
unset($display_duplicate['display_plugin']);
|
||||
|
||||
$displays[$new_display_id] = NestedArray::mergeDeep($displays[$new_display_id], $display_clone);
|
||||
$displays[$new_display_id] = NestedArray::mergeDeep($displays[$new_display_id], $display_duplicate);
|
||||
$displays[$new_display_id]['id'] = $new_display_id;
|
||||
$view->set('display', $displays);
|
||||
|
||||
|
|
|
@ -138,11 +138,11 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
public function getDefaultOperations(EntityInterface $entity) {
|
||||
$operations = parent::getDefaultOperations($entity);
|
||||
|
||||
if ($entity->hasLinkTemplate('clone')) {
|
||||
$operations['clone'] = array(
|
||||
'title' => $this->t('Clone'),
|
||||
if ($entity->hasLinkTemplate('duplicate')) {
|
||||
$operations['duplicate'] = array(
|
||||
'title' => $this->t('Duplicate'),
|
||||
'weight' => 15,
|
||||
) + $entity->urlInfo('clone')->toArray();
|
||||
) + $entity->urlInfo('duplicate')->toArray();
|
||||
}
|
||||
|
||||
// Add AJAX functionality to enable/disable operations.
|
||||
|
|
|
@ -47,14 +47,14 @@ function views_ui_entity_type_build(array &$entity_types) {
|
|||
->setFormClass('edit', 'Drupal\views_ui\ViewEditForm')
|
||||
->setFormClass('add', 'Drupal\views_ui\ViewAddForm')
|
||||
->setFormClass('preview', 'Drupal\views_ui\ViewPreviewForm')
|
||||
->setFormClass('clone', 'Drupal\views_ui\ViewCloneForm')
|
||||
->setFormClass('duplicate', 'Drupal\views_ui\ViewDuplicateForm')
|
||||
->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('clone', 'views_ui.clone')
|
||||
->setLinkTemplate('duplicate', 'views_ui.duplicate')
|
||||
->setLinkTemplate('delete-form', 'views_ui.delete')
|
||||
->setLinkTemplate('enable', 'views_ui.enable')
|
||||
->setLinkTemplate('disable', 'views_ui.disable')
|
||||
|
|
|
@ -64,11 +64,11 @@ views_ui.disable:
|
|||
_entity_access: view.disable
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
views_ui.clone:
|
||||
path: '/admin/structure/views/view/{view}/clone'
|
||||
views_ui.duplicate:
|
||||
path: '/admin/structure/views/view/{view}/duplicate'
|
||||
defaults:
|
||||
_entity_form: 'view.clone'
|
||||
_title: 'Clone view'
|
||||
_entity_form: 'view.duplicate'
|
||||
_title: 'Duplicate view'
|
||||
requirements:
|
||||
_entity_access: view.duplicate
|
||||
|
||||
|
|
Loading…
Reference in New Issue