Skip to content
Snippets Groups Projects
Commit 501c91e6 authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3232761 by kunal.sachdev, tedbow, phenaproxima: Create local task links to the updater form

parent e9bc3ec3
No related branches found
No related tags found
No related merge requests found
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
......@@ -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;
}
}
}
......@@ -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
......@@ -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);
......
......@@ -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');
......
......@@ -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
......
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