Commit dd60468d authored by webchick's avatar webchick

Issue #1828414 by tim.plunkett: Fixed Allow Views to be deleted.

parent 6b17f09e
......@@ -87,6 +87,15 @@ function testDefaultViews() {
$this->clickViewsOperationLink(t('Enable'), '/frontpage/');
$this->assertUrl('admin/structure/views');
$this->assertLinkByHref($edit_href);
// Test deleting a view.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), '/frontpage/');
// Submit the confirmation form.
$this->drupalPost(NULL, array(), t('Delete'));
// Ensure the view is no longer listed.
$this->assertUrl('admin/structure/views');
$this->assertNoLinkByHref($edit_href);
}
/**
......
......@@ -57,6 +57,13 @@ function views_ui_menu() {
'title' => 'Disable a view',
) + $ajax_base;
$items['admin/structure/views/view/%views_ui/delete'] = array(
'title' => 'Delete a view',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_confirm_delete', 4),
'type' => MENU_CALLBACK,
) + $base;
$items['admin/structure/views/settings'] = array(
'title' => 'Settings',
'page callback' => 'drupal_get_form',
......@@ -752,6 +759,33 @@ function views_ui_ajax_callback(ViewExecutable $view, $op) {
}
}
/**
* Form constructor for the View deletion form.
*
* @param \Drupal\views\ViewExectuable $view
* The View being deleted.
*
* @see views_ui_confirm_delete_submit()
*/
function views_ui_confirm_delete($form, &$form_state, ViewExecutable $view) {
$form['view'] = array('#type' => 'value', '#value' => $view);
return confirm_form($form,
t('Are you sure you want to delete the %name view?', array('%name' => $view->storage->getHumanName())),
'admin/structure/views',
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
/**
* Form submission handler for views_ui_confirm_delete().
*/
function views_ui_confirm_delete_submit($form, &$form_state) {
$form_state['values']['view']->storage->delete();
$form_state['redirect'] = 'admin/structure/views';
}
/**
* Page callback: Lists all of the views.
*
......
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