Issue #2057427 by dawehner, olli: Fixed No delete operation available while editing a view.

8.0.x
Alex Pott 2013-09-11 00:14:39 +02:00
parent cc1f3fdeda
commit 742908a681
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
/**
* @file
* Contains \Drupal\views_ui\Tests\ViewEditTest.
*/
namespace Drupal\views_ui\Tests;
use Drupal\views\Plugin\Core\Entity\View;
/**
* Tests some general functionality of editing views, like deleting a view.
*/
class ViewEditTest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() {
return array(
'name' => 'General views edit test',
'description' => 'Tests some general functionality of editing views, like deleting a view.',
'group' => 'Views UI'
);
}
/**
* Tests the delete link on a views UI.
*/
public function testDeleteLink() {
$this->drupalGet('admin/structure/views/view/test_view');
$this->assertLink(t('Delete view'), 0, 'Ensure that the view delete link appears');
$this->clickLink(t('Delete view'));
$this->assertUrl('admin/structure/views/view/test_view/delete');
$this->drupalPost(NULL, array(), t('Delete'));
$this->assertUrl('admin/structure/views');
$view = $this->container->get('plugin.manager.entity')->getStorageController('view')->load('test_view');
$this->assertFalse($view instanceof View);
}
}

View File

@ -682,6 +682,13 @@ class ViewEditFormController extends ViewFormControllerBase {
),
);
if ($view->access('delete')) {
$element['extra_actions']['#links']['delete'] = array(
'title' => $this->t('Delete view'),
'href' => "admin/structure/views/view/{$view->id()}/delete",
);
}
// Let other modules add additional links here.
\Drupal::moduleHandler()->alter('views_ui_display_top_links', $element['extra_actions']['#links'], $view, $display_id);