Commit a01e02d4 authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2922701 by quietone, masipila, heddn, benjifisher, phenaproxima,...

Issue #2922701 by quietone, masipila, heddn, benjifisher, phenaproxima, larowlan, xjm, catch: Migrate UI - refer to modules and add help text
parent 0fffa083
...@@ -18,3 +18,6 @@ ...@@ -18,3 +18,6 @@
.upgrade-analysis-report__status-icon--checked:before { .upgrade-analysis-report__status-icon--checked:before {
background-image: url(../../../../misc/icons/73b355/check.svg); background-image: url(../../../../misc/icons/73b355/check.svg);
} }
.upgrade-analysis-report__status-icon--error:before {
background-image: url(../../../../misc/icons/e32700/error.svg);
}
...@@ -26,7 +26,7 @@ function migrate_drupal_ui_help($route_name, RouteMatchInterface $route_match) { ...@@ -26,7 +26,7 @@ function migrate_drupal_ui_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dd>' . t('On the <a href=":upgrade">Upgrade</a> page, you are guided through performing the upgrade in several steps.', $output .= '<dd>' . t('On the <a href=":upgrade">Upgrade</a> page, you are guided through performing the upgrade in several steps.',
[':upgrade' => \Drupal::url('migrate_drupal_ui.upgrade')]) . '</dd>'; [':upgrade' => \Drupal::url('migrate_drupal_ui.upgrade')]) . '</dd>';
$output .= '<dd><ol><li>' . t('You need to enter the database credentials of the Drupal site that you want to upgrade. You can also include its files directory in the upgrade.') . '</li>'; $output .= '<dd><ol><li>' . t('You need to enter the database credentials of the Drupal site that you want to upgrade. You can also include its files directory in the upgrade.') . '</li>';
$output .= '<li>' . t('The next page then provides an overview of which upgrade paths are available or missing, before you proceed to perform the upgrade.') . '</li>'; $output .= '<li>' . t('The next page provides an overview of the modules that will be upgraded and those that will not be upgraded, before you proceed to perform the upgrade.') . '</li>';
$output .= '<li>' . t('Lastly, a message is displayed about the number of upgrade tasks that were successful or failed.') . '</li></ol></dd>'; $output .= '<li>' . t('Lastly, a message is displayed about the number of upgrade tasks that were successful or failed.') . '</li></ol></dd>';
$output .= '<dt>' . t('Reviewing the upgrade log') . '</dt>'; $output .= '<dt>' . t('Reviewing the upgrade log') . '</dt>';
$output .= '<dd>' . t('You can review a <a href=":log">log of upgrade messages</a> by clicking the link in the message provided after the upgrade or by filtering the messages for the type <em>migrate_drupal_ui</em> on the <a href=":messages">Recent log messages</a> page.', $output .= '<dd>' . t('You can review a <a href=":log">log of upgrade messages</a> by clicking the link in the message provided after the upgrade or by filtering the messages for the type <em>migrate_drupal_ui</em> on the <a href=":messages">Recent log messages</a> page.',
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\Core\State\StateInterface; use Drupal\Core\State\StateInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
...@@ -26,6 +27,13 @@ class MigrateUpgradeForm extends ConfirmFormBase { ...@@ -26,6 +27,13 @@ class MigrateUpgradeForm extends ConfirmFormBase {
use MigrationConfigurationTrait; use MigrationConfigurationTrait;
/**
* The current form step.
*
* @var string
*/
protected $step;
/** /**
* The state service. * The state service.
* *
...@@ -68,6 +76,13 @@ class MigrateUpgradeForm extends ConfirmFormBase { ...@@ -68,6 +76,13 @@ class MigrateUpgradeForm extends ConfirmFormBase {
*/ */
protected $moduleHandler; protected $moduleHandler;
/**
* The messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/** /**
* List of extensions that do not need an upgrade path. * List of extensions that do not need an upgrade path.
* *
...@@ -180,13 +195,14 @@ class MigrateUpgradeForm extends ConfirmFormBase { ...@@ -180,13 +195,14 @@ class MigrateUpgradeForm extends ConfirmFormBase {
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler. * The module handler.
*/ */
public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrateFieldPluginManagerInterface $field_plugin_manager, ModuleHandlerInterface $module_handler) { public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrateFieldPluginManagerInterface $field_plugin_manager, ModuleHandlerInterface $module_handler, MessengerInterface $messenger) {
$this->state = $state; $this->state = $state;
$this->dateFormatter = $date_formatter; $this->dateFormatter = $date_formatter;
$this->renderer = $renderer; $this->renderer = $renderer;
$this->pluginManager = $plugin_manager; $this->pluginManager = $plugin_manager;
$this->fieldPluginManager = $field_plugin_manager; $this->fieldPluginManager = $field_plugin_manager;
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
$this->messenger = $messenger;
} }
/** /**
...@@ -199,7 +215,8 @@ public static function create(ContainerInterface $container) { ...@@ -199,7 +215,8 @@ public static function create(ContainerInterface $container) {
$container->get('renderer'), $container->get('renderer'),
$container->get('plugin.manager.migration'), $container->get('plugin.manager.migration'),
$container->get('plugin.manager.migrate.field'), $container->get('plugin.manager.migrate.field'),
$container->get('module_handler') $container->get('module_handler'),
$container->get('messenger')
); );
} }
...@@ -214,8 +231,8 @@ public function getFormId() { ...@@ -214,8 +231,8 @@ public function getFormId() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, FormStateInterface $form_state) { public function buildForm(array $form, FormStateInterface $form_state) {
$step = $form_state->get('step') ?: 'overview'; $this->step = $form_state->get('step') ?: 'overview';
switch ($step) { switch ($this->step) {
case 'overview': case 'overview':
return $this->buildOverviewForm($form, $form_state); return $this->buildOverviewForm($form, $form_state);
...@@ -229,7 +246,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -229,7 +246,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
return $this->buildConfirmForm($form, $form_state); return $this->buildConfirmForm($form, $form_state);
default: default:
drupal_set_message($this->t('Unrecognized form step @step', ['@step' => $step]), 'error'); $this->messenger->addError($this->t('Unrecognized form step @step', ['@step' => $this->step]));
return []; return [];
} }
} }
...@@ -601,7 +618,7 @@ public function buildIdConflictForm(array &$form, FormStateInterface $form_state ...@@ -601,7 +618,7 @@ public function buildIdConflictForm(array &$form, FormStateInterface $form_state
return $this->buildForm($form, $form_state); return $this->buildForm($form, $form_state);
} }
drupal_set_message($this->t('WARNING: Content may be overwritten on your new site.'), 'warning'); $this->messenger->addWarning($this->t('WARNING: Content may be overwritten on your new site.'));
$form = parent::buildForm($form, $form_state); $form = parent::buildForm($form, $form_state);
$form['actions']['submit']['#submit'] = ['::submitConfirmIdConflictForm']; $form['actions']['submit']['#submit'] = ['::submitConfirmIdConflictForm'];
...@@ -742,11 +759,11 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ...@@ -742,11 +759,11 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) {
$migration_id = $migration->getPluginId(); $migration_id = $migration->getPluginId();
$source_module = $migration->getSourcePlugin()->getSourceModule(); $source_module = $migration->getSourcePlugin()->getSourceModule();
if (!$source_module) { if (!$source_module) {
drupal_set_message($this->t('Source module not found for @migration_id.', ['@migration_id' => $migration_id]), 'error'); $this->messenger->addError($this->t('Source module not found for @migration_id.', ['@migration_id' => $migration_id]));
} }
$destination_module = $migration->getDestinationPlugin()->getDestinationModule(); $destination_module = $migration->getDestinationPlugin()->getDestinationModule();
if (!$destination_module) { if (!$destination_module) {
drupal_set_message($this->t('Destination module not found for @migration_id.', ['@migration_id' => $migration_id]), 'error'); $this->messenger->addError($this->t('Destination module not found for @migration_id.', ['@migration_id' => $migration_id]));
} }
if ($source_module && $destination_module) { if ($source_module && $destination_module) {
...@@ -798,17 +815,17 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ...@@ -798,17 +815,17 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) {
'#title' => [ '#title' => [
'#type' => 'html_tag', '#type' => 'html_tag',
'#tag' => 'span', '#tag' => 'span',
'#value' => $this->t('Missing upgrade paths'), '#value' => $this->t('Modules that will not be upgraded'),
'#attributes' => ['id' => ['warning']], '#attributes' => ['id' => ['error']],
], ],
'#description' => $this->t('The following items will not be upgraded. For more information see <a href=":migrate">Upgrading from Drupal 6 or 7 to Drupal 8</a>.', [':migrate' => 'https://www.drupal.org/upgrade/migrate']), '#description' => $this->t('There are no modules installed on your new site to replace these modules. If you proceed with the upgrade now, configuration and/or content needed by these modules will not be available on your new site. For more information, see <a href=":review">Review the pre-upgrade analysis</a> in the <a href=":migrate">Upgrading to Drupal 8</a> handbook.', [':review' => 'https://www.drupal.org/docs/8/upgrade/upgrade-using-web-browser#pre-upgrade-analysis', ':migrate' => 'https://www.drupal.org/docs/8/upgrade']),
'#weight' => 2, '#weight' => 2,
]; ];
$missing_module_list['module_list'] = [ $missing_module_list['module_list'] = [
'#type' => 'table', '#type' => 'table',
'#header' => [ '#header' => [
$this->t('Source module: Drupal @version', ['@version' => $version]), $this->t('Drupal @version', ['@version' => $version]),
$this->t('Upgrade module: Drupal 8'), $this->t('Drupal 8'),
], ],
]; ];
$missing_count = 0; $missing_count = 0;
...@@ -824,21 +841,22 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ...@@ -824,21 +841,22 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) {
'#attributes' => [ '#attributes' => [
'class' => [ 'class' => [
'upgrade-analysis-report__status-icon', 'upgrade-analysis-report__status-icon',
'upgrade-analysis-report__status-icon--warning', 'upgrade-analysis-report__status-icon--error',
], ],
], ],
], ],
'destination_module' => ['#plain_text' => 'Missing'], 'destination_module' => ['#plain_text' => 'Not upgraded'],
]; ];
} }
} }
// Available migrations. // Available migrations.
$available_module_list = [ $available_module_list = [
'#type' => 'details', '#type' => 'details',
'#title' => [ '#title' => [
'#type' => 'html_tag', '#type' => 'html_tag',
'#tag' => 'span', '#tag' => 'span',
'#value' => $this->t('Available upgrade paths'), '#value' => $this->t('Modules that will be upgraded'),
'#attributes' => ['id' => ['checked']], '#attributes' => ['id' => ['checked']],
], ],
'#weight' => 3, '#weight' => 3,
...@@ -847,8 +865,8 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ...@@ -847,8 +865,8 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) {
$available_module_list['module_list'] = [ $available_module_list['module_list'] = [
'#type' => 'table', '#type' => 'table',
'#header' => [ '#header' => [
$this->t('Source module: Drupal @version', ['@version' => $version]), $this->t('Drupal @version', ['@version' => $version]),
$this->t('Upgrade module: Drupal 8'), $this->t('Drupal 8'),
], ],
]; ];
...@@ -885,8 +903,8 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ...@@ -885,8 +903,8 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) {
$counters[] = [ $counters[] = [
'#theme' => 'status_report_counter', '#theme' => 'status_report_counter',
'#amount' => $missing_count, '#amount' => $missing_count,
'#text' => $this->formatPlural($missing_count, 'Missing upgrade path', 'Missing upgrade paths'), '#text' => $this->formatPlural($missing_count, 'Module will not be upgraded', 'Modules will not be upgraded'),
'#severity' => 'warning', '#severity' => 'error',
'#weight' => 0, '#weight' => 0,
]; ];
$general_info[] = $missing_module_list; $general_info[] = $missing_module_list;
...@@ -895,7 +913,7 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { ...@@ -895,7 +913,7 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) {
$counters[] = [ $counters[] = [
'#theme' => 'status_report_counter', '#theme' => 'status_report_counter',
'#amount' => $available_count, '#amount' => $available_count,
'#text' => $this->formatPlural($available_count, 'Available upgrade path', 'Available upgrade paths'), '#text' => $this->formatPlural($available_count, 'Module will be upgraded', 'Modules will be upgraded'),
'#severity' => 'checked', '#severity' => 'checked',
'#weight' => 1, '#weight' => 1,
]; ];
...@@ -960,7 +978,10 @@ protected function getDatabaseTypes() { ...@@ -960,7 +978,10 @@ protected function getDatabaseTypes() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getQuestion() { public function getQuestion() {
return $this->t('Upgrade analysis report'); if ($this->step === 'confirm_id_conflicts') {
return $this->t('Upgrade analysis report');
}
return $this->t('What will be upgraded?');
} }
/** /**
......
...@@ -99,7 +99,7 @@ public function testMigrateUpgradeExecute() { ...@@ -99,7 +99,7 @@ public function testMigrateUpgradeExecute() {
$session->pageTextContains('There is translated content of these types:'); $session->pageTextContains('There is translated content of these types:');
$this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.')); $this->drupalPostForm(NULL, [], t('I acknowledge I may lose data. Continue anyway.'));
$session->statusCodeEquals(200); $session->statusCodeEquals(200);
$session->pageTextContains('Upgrade analysis report'); $session->pageTextContains('What will be upgraded?');
// Ensure there are no errors about missing modules from the test module. // Ensure there are no errors about missing modules from the test module.
$session->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.')); $session->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.'));
$session->pageTextNotContains(t('Source module not found for migration_provider_test.')); $session->pageTextNotContains(t('Source module not found for migration_provider_test.'));
......
...@@ -132,17 +132,17 @@ protected function assertUpgradePaths(WebAssert $session, array $available_paths ...@@ -132,17 +132,17 @@ protected function assertUpgradePaths(WebAssert $session, array $available_paths
// Test the available migration paths. // Test the available migration paths.
foreach ($available_paths as $available) { foreach ($available_paths as $available) {
$session->elementExists('xpath', "//span[contains(@class, 'checked') and text() = '$available']"); $session->elementExists('xpath', "//span[contains(@class, 'checked') and text() = '$available']");
$session->elementNotExists('xpath', "//span[contains(@class, 'warning') and text() = '$available']"); $session->elementNotExists('xpath', "//span[contains(@class, 'error') and text() = '$available']");
} }
// Test the missing migration paths. // Test the missing migration paths.
foreach ($missing_paths as $missing) { foreach ($missing_paths as $missing) {
$session->elementExists('xpath', "//span[contains(@class, 'warning') and text() = '$missing']"); $session->elementExists('xpath', "//span[contains(@class, 'error') and text() = '$missing']");
$session->elementNotExists('xpath', "//span[contains(@class, 'checked') and text() = '$missing']"); $session->elementNotExists('xpath', "//span[contains(@class, 'checked') and text() = '$missing']");
} }
// Test the total count of missing and available paths. // Test the total count of missing and available paths.
$session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--warning')]", count($missing_paths)); $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--error')]", count($missing_paths));
$session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", count($available_paths)); $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", count($available_paths));
} }
......
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