Skip to content
Snippets Groups Projects
Commit c441c332 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3260668 by phenaproxima: UpdateReady should have "cancel" button

parent d4fb6ede
No related branches found
No related tags found
1 merge request!189Issue #3260668: UpdateReady should have "cancel" button
...@@ -139,6 +139,11 @@ class UpdateReady extends FormBase { ...@@ -139,6 +139,11 @@ class UpdateReady extends FormBase {
]; ];
$form['actions'] = ['#type' => 'actions']; $form['actions'] = ['#type' => 'actions'];
$form['actions']['cancel'] = [
'#type' => 'submit',
'#value' => $this->t('Cancel update'),
'#submit' => ['::cancel'],
];
$form['actions']['submit'] = [ $form['actions']['submit'] = [
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->t('Continue'), '#value' => $this->t('Continue'),
...@@ -184,4 +189,13 @@ class UpdateReady extends FormBase { ...@@ -184,4 +189,13 @@ class UpdateReady extends FormBase {
batch_set($batch); batch_set($batch);
} }
/**
* Cancels the in-progress update.
*/
public function cancel(array &$form, FormStateInterface $form_state): void {
$this->updater->destroy();
$this->messenger()->addStatus($this->t('The update was successfully cancelled.'));
$form_state->setRedirect('automatic_updates.report_update');
}
} }
...@@ -263,6 +263,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -263,6 +263,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
// Delete the existing update. // Delete the existing update.
$page->pressButton('Delete existing update'); $page->pressButton('Delete existing update');
$assert_session->pageTextContains('Staged update deleted');
$assert_session->pageTextNotContains('Cannot begin an update because another Composer operation is currently in progress.'); $assert_session->pageTextNotContains('Cannot begin an update because another Composer operation is currently in progress.');
// Ensure we can start another update after deleting the existing one. // Ensure we can start another update after deleting the existing one.
...@@ -273,6 +274,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -273,6 +274,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertUpdateReady(); $this->assertUpdateReady();
$this->assertUpdateStagedTimes(2); $this->assertUpdateStagedTimes(2);
$assert_session->buttonExists('Continue'); $assert_session->buttonExists('Continue');
// Cancel the update, then ensure that we are bounced back to the start
// page, and that it will allow us to begin the update anew.
$page->pressButton('Cancel update');
$assert_session->addressEquals('/admin/reports/updates/automatic-update');
$assert_session->pageTextContains('The update was successfully cancelled.');
$assert_session->buttonExists('Update');
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment