Issue #3266397 by quietone, murilohp, dww, AaronMcHale, benjifisher, Antoniya, andregp, rkoller, kimberlly_amaral, ckrina: Highlight non-stable modules on the admin/modules/uninstall form
parent
9048a7d9c0
commit
62c91e97c6
|
@ -2,13 +2,16 @@
|
||||||
|
|
||||||
namespace Drupal\system\Form;
|
namespace Drupal\system\Form;
|
||||||
|
|
||||||
|
use Drupal\Core\Extension\ExtensionLifecycle;
|
||||||
use Drupal\Core\Extension\ModuleExtensionList;
|
use Drupal\Core\Extension\ModuleExtensionList;
|
||||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||||
use Drupal\Core\Extension\ModuleInstallerInterface;
|
use Drupal\Core\Extension\ModuleInstallerInterface;
|
||||||
use Drupal\Core\Form\FormBase;
|
use Drupal\Core\Form\FormBase;
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
|
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
|
||||||
|
use Drupal\Core\Link;
|
||||||
use Drupal\Core\Update\UpdateHookRegistry;
|
use Drupal\Core\Update\UpdateHookRegistry;
|
||||||
|
use Drupal\Core\Url;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,6 +153,21 @@ class ModulesUninstallForm extends FormBase {
|
||||||
$form['modules'][$module->getName()]['name']['#markup'] = $name;
|
$form['modules'][$module->getName()]['name']['#markup'] = $name;
|
||||||
$form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']);
|
$form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']);
|
||||||
|
|
||||||
|
$lifecycle = $module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER];
|
||||||
|
if ($lifecycle !== ExtensionLifecycle::STABLE && !empty($module->info[ExtensionLifecycle::LIFECYCLE_LINK_IDENTIFIER])) {
|
||||||
|
$form['modules'][$module->getName()]['name']['#markup'] .= ' ' . Link::fromTextAndUrl('(' . $this->t('@lifecycle', ['@lifecycle' => ucfirst($lifecycle)]) . ')',
|
||||||
|
Url::fromUri($module->info[ExtensionLifecycle::LIFECYCLE_LINK_IDENTIFIER], [
|
||||||
|
'attributes' =>
|
||||||
|
[
|
||||||
|
'class' => 'module-link--non-stable',
|
||||||
|
'aria-label' => $this->t('View information on the @lifecycle status of the module @module', [
|
||||||
|
'@lifecycle' => ucfirst($lifecycle),
|
||||||
|
'@module' => $module->info['name'],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
])
|
||||||
|
)->toString();
|
||||||
|
}
|
||||||
$form['uninstall'][$module->getName()] = [
|
$form['uninstall'][$module->getName()] = [
|
||||||
'#type' => 'checkbox',
|
'#type' => 'checkbox',
|
||||||
'#title' => $this->t('Uninstall @module module', ['@module' => $name]),
|
'#title' => $this->t('Uninstall @module module', ['@module' => $name]),
|
||||||
|
|
|
@ -3,4 +3,5 @@ type: module
|
||||||
description: 'Module in the experimental package to test experimental functionality.'
|
description: 'Module in the experimental package to test experimental functionality.'
|
||||||
package: Core (Experimental)
|
package: Core (Experimental)
|
||||||
lifecycle: experimental
|
lifecycle: experimental
|
||||||
|
lifecycle_link: https://example.com/experimental
|
||||||
version: 8.y.x-unstable
|
version: 8.y.x-unstable
|
||||||
|
|
|
@ -4,4 +4,4 @@ description: 'Support module for testing an obsolete module extension.'
|
||||||
package: Testing
|
package: Testing
|
||||||
version: VERSION
|
version: VERSION
|
||||||
lifecycle: obsolete
|
lifecycle: obsolete
|
||||||
lifecycle_link: 'https://i.giphy.com/media/100JPq1ylYXEti/giphy.webp'
|
lifecycle_link: 'https://example.com/obsolete'
|
||||||
|
|
|
@ -59,9 +59,29 @@ class UninstallTest extends BrowserTestBase {
|
||||||
]);
|
]);
|
||||||
$node->save();
|
$node->save();
|
||||||
|
|
||||||
|
// Change the config directly to "install" non-stable modules.
|
||||||
|
$this->config('core.extension')
|
||||||
|
->set('module.system_status_obsolete_test', 0)
|
||||||
|
->set('module.deprecated_module', 0)
|
||||||
|
->set('module.experimental_module_test', 0)
|
||||||
|
->save();
|
||||||
|
$this->rebuildAll();
|
||||||
|
|
||||||
$this->drupalGet('admin/modules/uninstall');
|
$this->drupalGet('admin/modules/uninstall');
|
||||||
$this->assertSession()->titleEquals('Uninstall | Drupal');
|
$this->assertSession()->titleEquals('Uninstall | Drupal');
|
||||||
|
|
||||||
|
// Check that the experimental module link was rendered correctly.
|
||||||
|
$this->assertSession()->elementExists('xpath', "//a[contains(@aria-label, 'View information on the Experimental status of the module Experimental Test')]");
|
||||||
|
$this->assertSession()->elementExists('xpath', "//a[contains(@href, 'https://example.com/experimental')]");
|
||||||
|
|
||||||
|
// Check that the deprecated module link was rendered correctly.
|
||||||
|
$this->assertSession()->elementExists('xpath', "//a[contains(@aria-label, 'View information on the Deprecated status of the module Deprecated module')]");
|
||||||
|
$this->assertSession()->elementExists('xpath', "//a[contains(@href, 'http://example.com/deprecated')]");
|
||||||
|
|
||||||
|
// Check that the obsolete module link was rendered correctly.
|
||||||
|
$this->assertSession()->elementExists('xpath', "//a[contains(@aria-label, 'View information on the Obsolete status of the module System obsolete status test')]");
|
||||||
|
$this->assertSession()->elementExists('xpath', "//a[contains(@href, 'https://example.com/obsolete')]");
|
||||||
|
|
||||||
foreach (\Drupal::service('extension.list.module')->getAllInstalledInfo() as $module => $info) {
|
foreach (\Drupal::service('extension.list.module')->getAllInstalledInfo() as $module => $info) {
|
||||||
$field_name = "uninstall[$module]";
|
$field_name = "uninstall[$module]";
|
||||||
if (!empty($info['required'])) {
|
if (!empty($info['required'])) {
|
||||||
|
|
Loading…
Reference in New Issue