diff --git a/automatic_updates.links.task.yml b/automatic_updates.links.task.yml new file mode 100644 index 0000000000000000000000000000000000000000..239f899432ca6bc4d901610f7ce0e6e40642a651 --- /dev/null +++ b/automatic_updates.links.task.yml @@ -0,0 +1,10 @@ +automatic_updates.report_update: + route_name: automatic_updates.report_update + base_route: system.admin_reports + title: Automatic Updates + weight: 15 +automatic_updates.module_update: + route_name: automatic_updates.module_update + base_route: system.modules_list + title: Automatic Updates + weight: 15 diff --git a/automatic_updates.module b/automatic_updates.module index b69cf3eb1573ccf11125ee6c9356582efba68901..1379ccbb91731d6b9b3e661a6758fb85c401a8e1 100644 --- a/automatic_updates.module +++ b/automatic_updates.module @@ -68,10 +68,19 @@ function automatic_updates_form_update_manager_update_form_alter(&$form, FormSta // Remove current message that core updates are not supported with a link to // use this modules form. if (isset($form['manual_updates']['#rows']['drupal']['data']['title'])) { - $core_updates_message = t( - '<h2>Core updates required</h2>Drupal core updates are supported by the enabled <a href="@url">Automatic Updates module</a>', - ['@url' => Url::fromRoute('automatic_updates.update_form')->toString()] - ); - $form['manual_updates']['#prefix'] = $core_updates_message; + $current_route = \Drupal::routeMatch()->getRouteName(); + if ($current_route === 'update.module_update') { + $redirect_route = 'automatic_updates.module_update'; + } + elseif ($current_route === 'update.report_update') { + $redirect_route = 'automatic_updates.report_update'; + } + if (!empty($redirect_route)) { + $core_updates_message = t( + '<h2>Core updates required</h2>Drupal core updates are supported by the enabled <a href="@url">Automatic Updates module</a>', + ['@url' => Url::fromRoute($redirect_route)->toString()] + ); + $form['manual_updates']['#prefix'] = $core_updates_message; + } } } diff --git a/automatic_updates.routing.yml b/automatic_updates.routing.yml index 4c192676a80225b427c1825129fb7ba8b5803892..4c12d0f5f7deebc9f77fdd9ad566acd0faa4c040 100644 --- a/automatic_updates.routing.yml +++ b/automatic_updates.routing.yml @@ -5,20 +5,31 @@ automatic_updates.update_readiness: _title: 'Update readiness checking' requirements: _permission: 'administer software updates' -automatic_updates.update_form: - path: '/admin/automatic-update' +automatic_updates.confirmation_page: + path: '/admin/automatic-update-ready' + defaults: + _form: '\Drupal\automatic_updates\Form\UpdateReady' + _title: 'Ready to update' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' +# Links to our updater form appear in two different sets of local tasks. To ensure the breadcrumbs and paths are +# consistent with the other local tasks in each set, we need two separate routes to the same form. +automatic_updates.report_update: + path: '/admin/reports/updates/automatic-update' defaults: _form: '\Drupal\automatic_updates\Form\UpdaterForm' - _title: 'Automatic Updates' + _title: 'Update' requirements: _permission: 'administer software updates' options: _admin_route: TRUE -automatic_updates.confirmation_page: - path: '/admin/automatic-update-ready' +automatic_updates.module_update: + path: '/admin/modules/automatic-update' defaults: - _form: '\Drupal\automatic_updates\Form\UpdateReady' - _title: 'Ready to update' + _form: '\Drupal\automatic_updates\Form\UpdaterForm' + _title: 'Update' requirements: _permission: 'administer software updates' - _access_update_manager: 'TRUE' + options: + _admin_route: TRUE diff --git a/src/BatchProcessor.php b/src/BatchProcessor.php index 09a5ac6b94d9fed301a51c49b0f752a7ff7e89e7..d7f046b7e523c3ef4aada1ffdddc9990d62e7ed8 100644 --- a/src/BatchProcessor.php +++ b/src/BatchProcessor.php @@ -158,7 +158,7 @@ class BatchProcessor { if ($success) { \Drupal::messenger()->addMessage('Update complete!'); // @todo redirect to update.php? - return new RedirectResponse(Url::fromRoute('automatic_updates.update_form', [], + return new RedirectResponse(Url::fromRoute('update.status', [], ['absolute' => TRUE])->toString()); } static::handleBatchError($results); diff --git a/tests/src/Build/CoreUpdateTest.php b/tests/src/Build/CoreUpdateTest.php index c26bbcf1a4034b285c66cbb86998606c347a3d2d..844addd8916bf849173ac7d1655cb1d6dfed7d99 100644 --- a/tests/src/Build/CoreUpdateTest.php +++ b/tests/src/Build/CoreUpdateTest.php @@ -41,7 +41,7 @@ class CoreUpdateTest extends UpdateTestBase { $this->assertCoreVersion('9.8.0'); $this->checkForUpdates(); // Ensure that an update to 9.8.1 is available. - $this->visit('/admin/automatic-update'); + $this->visit('/admin/modules/automatic-update'); $this->getMink()->assertSession()->pageTextContains('9.8.1'); } @@ -111,7 +111,7 @@ class CoreUpdateTest extends UpdateTestBase { $page = $mink->getSession()->getPage(); $assert_session = $mink->assertSession(); - $this->visit('/admin/automatic-update'); + $this->visit('/admin/modules/automatic-update'); $page->pressButton('Download these updates'); $this->waitForBatchJob(); $assert_session->pageTextContains('Ready to update'); diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index 6bd3b349f4e35efc4effd7c119adff96a5754615..f356041b483c26fb2e9875e42ef4a977cfc4b036 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -27,6 +27,7 @@ class UpdaterFormTest extends BrowserTestBase { * {@inheritdoc} */ protected static $modules = [ + 'block', 'automatic_updates', 'automatic_updates_test', 'package_manager_bypass', @@ -73,7 +74,7 @@ class UpdaterFormTest extends BrowserTestBase { $this->drupalLogin($this->rootUser); $this->checkForUpdates(); - $this->drupalGet('/admin/automatic-update'); + $this->drupalGet('/admin/modules/automatic-update'); $assert_session = $this->assertSession(); $assert_session->statusCodeEquals(200); @@ -85,13 +86,20 @@ class UpdaterFormTest extends BrowserTestBase { * Tests that available updates are rendered correctly in a table. */ public function testTableLooksCorrect(): void { + $this->drupalPlaceBlock('local_tasks_block', ['primary' => TRUE]); + $assert_session = $this->assertSession(); $this->setCoreVersion('9.8.0'); $this->drupalLogin($this->rootUser); $this->checkForUpdates(); - $this->drupalGet('/admin/automatic-update'); - - $assert_session = $this->assertSession(); + // Navigate to the automatic updates form. + $this->drupalGet('/admin'); + // @todo Add test coverage of accessing the form via the other path in + // https://www.drupal.org/i/3233564 + $this->clickLink('Extend'); + $this->clickLink('Update'); + $assert_session->pageTextContainsOnce('Drupal core updates are supported by the enabled Automatic Updates module'); + $this->clickLink('Automatic Updates module'); $cells = $assert_session->elementExists('css', '#edit-projects .update-recommended') ->findAll('css', 'td'); $this->assertCount(3, $cells); @@ -133,7 +141,7 @@ class UpdaterFormTest extends BrowserTestBase { // If a validator raises an error during readiness checking, the form should // not have a submit button. - $this->drupalGet('/admin/automatic-update'); + $this->drupalGet('/admin/modules/automatic-update'); $assert_session->buttonNotExists('Download these updates'); // Since this is an administrative page, the error message should be visible // thanks to automatic_updates_page_top(). The readiness checks were re-run