Issue #3215044 by quietone, murilohp, larowlan, Gábor Hojtsy, catch, dww, daffie: Promote the non-stable statuses in admin/appearance page, optionally even visually

(cherry picked from commit 44a1bff1f4)
merge-requests/1523/head
catch 2022-02-22 14:00:10 +00:00
parent d185ea19dc
commit 2afbf15b31
3 changed files with 32 additions and 3 deletions

View File

@ -255,6 +255,10 @@ small .admin-link:after {
.theme-info__description { .theme-info__description {
margin-top: 0; margin-top: 0;
} }
.theme-link--non-stable {
padding-left: 18px;
background: url(../../../misc/icons/e29700/warning.svg) 0 50% no-repeat; /* LTR */
}
.system-themes-list { .system-themes-list {
margin-bottom: 20px; margin-bottom: 20px;
} }

View File

@ -4,11 +4,13 @@ namespace Drupal\system\Controller;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ExtensionLifecycle;
use Drupal\Core\Extension\ModuleDependencyMessageTrait; use Drupal\Core\Extension\ModuleDependencyMessageTrait;
use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ThemeExtensionList; use Drupal\Core\Extension\ThemeExtensionList;
use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Link;
use Drupal\Core\Menu\MenuLinkTreeInterface; use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters; use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Theme\ThemeAccessCheck; use Drupal\Core\Theme\ThemeAccessCheck;
@ -347,8 +349,7 @@ class SystemController extends ControllerBase {
} }
} }
// Add notes to default theme, administration theme and experimental // Add notes to default theme, administration theme and non-stable themes.
// themes.
$theme->notes = []; $theme->notes = [];
if ($theme->is_default) { if ($theme->is_default) {
$theme->notes[] = $this->t('default theme'); $theme->notes[] = $this->t('default theme');
@ -356,7 +357,22 @@ class SystemController extends ControllerBase {
if ($theme->is_admin) { if ($theme->is_admin) {
$theme->notes[] = $this->t('administration theme'); $theme->notes[] = $this->t('administration theme');
} }
if ($theme->isExperimental()) { $lifecycle = $theme->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER];
if (!empty($theme->info[ExtensionLifecycle::LIFECYCLE_LINK_IDENTIFIER])) {
$theme->notes[] = Link::fromTextAndUrl($this->t('@lifecycle', ['@lifecycle' => ucfirst($lifecycle)]),
Url::fromUri($theme->info[ExtensionLifecycle::LIFECYCLE_LINK_IDENTIFIER], [
'attributes' =>
[
'class' => 'theme-link--non-stable',
'aria-label' => $this->t('View information on the @lifecycle status of the theme @theme', [
'@lifecycle' => ucfirst($lifecycle),
'@theme' => $theme->info['name'],
]),
],
])
)->toString();
}
if ($theme->isExperimental() && empty($theme->info[ExtensionLifecycle::LIFECYCLE_LINK_IDENTIFIER])) {
$theme->notes[] = $this->t('experimental theme'); $theme->notes[] = $this->t('experimental theme');
} }

View File

@ -288,6 +288,15 @@ class ThemeTest extends BrowserTestBase {
$this->drupalGet('admin/appearance'); $this->drupalGet('admin/appearance');
$this->submitForm($edit, 'Save configuration'); $this->submitForm($edit, 'Save configuration');
// Check the display of non stable themes.
$themes = \Drupal::service('theme_handler')->rebuildThemeData();
$experimental_version = $themes['experimental_theme_test']->info['version'];
$deprecated_version = $themes['deprecated_theme_test']->info['version'];
$this->drupalGet('admin/appearance');
$this->assertSession()->pageTextContains('Experimental test ' . $experimental_version . ' (experimental theme)');
$this->assertSession()->pageTextContains('Test deprecated theme ' . $deprecated_version . ' (Deprecated)');
$this->assertSession()->elementExists('xpath', "//a[contains(@href, 'http://example.com/deprecated_theme')]");
// Check that the administration theme is used on an administration page. // Check that the administration theme is used on an administration page.
$this->drupalGet('admin/config'); $this->drupalGet('admin/config');
$this->assertSession()->responseContains('core/themes/seven'); $this->assertSession()->responseContains('core/themes/seven');