From 9c8a84bf543ac22c307a0caf18ecf9f2dae3ce35 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 9 Feb 2024 10:02:48 +0000
Subject: [PATCH] Revert "Issue #3405660 by smustgrave, quietone, Wim Leers,
 larowlan, lauriii: Remove tour from themes"

This reverts commit 3951fa4de90ad3b1038eb96030a734b71b1eba4c.
---
 core/modules/tour/tour.libraries.yml          | 14 -------------
 core/modules/tour/tour.module                 | 20 -------------------
 ...solvedLibraryDefinitionsFilesMatchTest.php |  8 ++------
 .../Core/Theme/Stable9LibraryOverrideTest.php |  3 ---
 .../Theme/StableLibraryOverrideTestBase.php   |  7 +------
 core/themes/claro/claro.info.yml              |  2 ++
 core/themes/claro/claro.libraries.yml         |  6 ++++++
 .../claro/css/theme/tour.theme.css}           |  0
 .../claro/css/theme/tour.theme.pcss.css}      |  0
 .../olivero/css/components/site-header.css    |  2 +-
 .../css/components/site-header.pcss.css       |  2 +-
 .../stable9/css/tour/tour.module.css}         |  0
 .../js/theme => themes/stable9/js}/tour.js    |  0
 core/themes/stable9/stable9.info.yml          |  9 +++++++++
 core/themes/stable9/stable9.libraries.yml     |  5 +++++
 15 files changed, 27 insertions(+), 51 deletions(-)
 rename core/{modules/tour/css/theme/claro-tour.theme.css => themes/claro/css/theme/tour.theme.css} (100%)
 rename core/{modules/tour/css/theme/claro-tour.theme.pcss.css => themes/claro/css/theme/tour.theme.pcss.css} (100%)
 rename core/{modules/tour/css/theme/stable9-tour.module.css => themes/stable9/css/tour/tour.module.css} (100%)
 rename core/{modules/tour/js/theme => themes/stable9/js}/tour.js (100%)

diff --git a/core/modules/tour/tour.libraries.yml b/core/modules/tour/tour.libraries.yml
index 19c0d3a39ca3..52cbc50573d8 100644
--- a/core/modules/tour/tour.libraries.yml
+++ b/core/modules/tour/tour.libraries.yml
@@ -16,17 +16,3 @@ tour-styling:
   css:
     component:
       css/tour.module.css: { media: screen }
-
-tour-claro-styling:
-  version: VERSION
-  css:
-    theme:
-      css/theme/claro-tour.theme.css: {}
-
-tour-stable9-styling:
-  version: VERSION
-  js:
-    js/theme/tour.js: {}
-  css:
-    theme:
-      css/theme/stable9-tour.module.css: {}
diff --git a/core/modules/tour/tour.module b/core/modules/tour/tour.module
index bd05f7311c73..da432ef9ed7f 100644
--- a/core/modules/tour/tour.module
+++ b/core/modules/tour/tour.module
@@ -115,23 +115,3 @@ function tour_tour_insert($entity) {
 function tour_tour_update($entity) {
   \Drupal::service('plugin.manager.tour.tip')->clearCachedDefinitions();
 }
-
-/**
- * Implements hook_library_info_alter().
- */
-function tour_library_info_alter(&$libraries, $extension) {
-  if ($extension === 'tour') {
-    $theme = \Drupal::service('theme.manager')->getActiveTheme()->getName();
-    $base_theme = FALSE;
-    if ($theme && !\Drupal::service('theme_handler')->listInfo()[$theme]) {
-      $base_theme = \Drupal::service('theme_handler')->listInfo()[$theme]->base_theme;
-    }
-    if (in_array('claro', [$theme, $base_theme])) {
-      $libraries['tour']['dependencies'][] = 'tour/tour-claro-styling';
-    }
-    elseif (in_array('stable9', [$theme, $base_theme])) {
-      $libraries['tour']['dependencies'][] = 'tour/tour-stable9-styling';
-    }
-  }
-
-}
diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
index e31900a27efa..5ba0c7bb4d8f 100644
--- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
@@ -207,10 +207,7 @@ protected function getAllLibraries() {
     $extensions = $modules;
     $module_list = array_keys($modules);
     sort($module_list);
-    // Remove deprecated module Tour.
-    $module_list = array_diff($module_list, ['tour']);
-    $all_modules = array_diff($this->allModules, ['tour']);
-    $this->assertEquals($all_modules, $module_list, 'All core modules are installed.');
+    $this->assertEquals($this->allModules, $module_list, 'All core modules are installed.');
 
     $themes = $this->themeHandler->listInfo();
     $extensions += $themes;
@@ -219,8 +216,7 @@ protected function getAllLibraries() {
     $this->assertEquals($this->allThemes, $theme_list, 'All core themes are installed.');
 
     $libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');
-    // Remove deprecated module Tour.
-    unset($extensions['tour']);
+
     foreach ($extensions as $extension_name => $extension) {
       $library_file = $extension->getPath() . '/' . $extension_name . '.libraries.yml';
       if (is_file($this->root . '/' . $library_file)) {
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php
index 20bbe21c5bf3..39ccd4038d53 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php
@@ -26,9 +26,6 @@ class Stable9LibraryOverrideTest extends StableLibraryOverrideTestBase {
     'media/drupal.media-icon',
     'options/drupal.options-icon',
     'telephone/drupal.telephone-icon',
-    'tour/tour-styling',
-    'tour/tour-claro-styling',
-    'tour/tour-stable9-styling',
   ];
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTestBase.php b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTestBase.php
index bfe0ecfafd34..6e80b20fbd52 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTestBase.php
@@ -121,15 +121,10 @@ protected function getAllLibraries() {
     $modules = \Drupal::moduleHandler()->getModuleList();
     $module_list = array_keys($modules);
     sort($module_list);
-    // Remove deprecated module Tour.
-    $module_list = array_diff($module_list, ['tour']);
-    $all_modules = array_diff($this->allModules, ['tour']);
-    $this->assertEquals($all_modules, $module_list, 'All core modules are installed.');
+    $this->assertEquals($this->allModules, $module_list, 'All core modules are installed.');
 
     $libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');
 
-    // Remove deprecated module Tour.
-    unset($modules['tour']);
     foreach ($modules as $module_name => $module) {
       $library_file = $module->getPath() . '/' . $module_name . '.libraries.yml';
       if (is_file($this->root . '/' . $library_file)) {
diff --git a/core/themes/claro/claro.info.yml b/core/themes/claro/claro.info.yml
index c47d4b86e51c..5b8fd2393527 100644
--- a/core/themes/claro/claro.info.yml
+++ b/core/themes/claro/claro.info.yml
@@ -128,6 +128,8 @@ libraries-extend:
     - claro/system.admin
   core/drupal.autocomplete:
     - claro/autocomplete
+  tour/tour-styling:
+    - claro/tour-styling
   shortcut/drupal.shortcut:
     - claro/drupal.shortcut
   core/drupal.ajax:
diff --git a/core/themes/claro/claro.libraries.yml b/core/themes/claro/claro.libraries.yml
index bcc8788ebea2..3a16437d1ae7 100644
--- a/core/themes/claro/claro.libraries.yml
+++ b/core/themes/claro/claro.libraries.yml
@@ -139,6 +139,12 @@ drupal.node.preview:
     theme:
       css/components/node-preview.css: {}
 
+tour-styling:
+  version: VERSION
+  css:
+    theme:
+      css/theme/tour.theme.css: {}
+
 media-form:
   version: VERSION
   css:
diff --git a/core/modules/tour/css/theme/claro-tour.theme.css b/core/themes/claro/css/theme/tour.theme.css
similarity index 100%
rename from core/modules/tour/css/theme/claro-tour.theme.css
rename to core/themes/claro/css/theme/tour.theme.css
diff --git a/core/modules/tour/css/theme/claro-tour.theme.pcss.css b/core/themes/claro/css/theme/tour.theme.pcss.css
similarity index 100%
rename from core/modules/tour/css/theme/claro-tour.theme.pcss.css
rename to core/themes/claro/css/theme/tour.theme.pcss.css
diff --git a/core/themes/olivero/css/components/site-header.css b/core/themes/olivero/css/components/site-header.css
index ecbdc1ea9cc7..6dc7c5162ac3 100644
--- a/core/themes/olivero/css/components/site-header.css
+++ b/core/themes/olivero/css/components/site-header.css
@@ -14,7 +14,7 @@
   position: relative;
   /**
    * Ensure mobile site header is always above other elements including
-   * contextual links.
+   * contextual links, and Tour.
    */
   z-index: 101;
 }
diff --git a/core/themes/olivero/css/components/site-header.pcss.css b/core/themes/olivero/css/components/site-header.pcss.css
index ee6822646357..1ab7251194de 100644
--- a/core/themes/olivero/css/components/site-header.pcss.css
+++ b/core/themes/olivero/css/components/site-header.pcss.css
@@ -9,7 +9,7 @@
   position: relative;
   /**
    * Ensure mobile site header is always above other elements including
-   * contextual links.
+   * contextual links, and Tour.
    */
   z-index: 101;
 
diff --git a/core/modules/tour/css/theme/stable9-tour.module.css b/core/themes/stable9/css/tour/tour.module.css
similarity index 100%
rename from core/modules/tour/css/theme/stable9-tour.module.css
rename to core/themes/stable9/css/tour/tour.module.css
diff --git a/core/modules/tour/js/theme/tour.js b/core/themes/stable9/js/tour.js
similarity index 100%
rename from core/modules/tour/js/theme/tour.js
rename to core/themes/stable9/js/tour.js
diff --git a/core/themes/stable9/stable9.info.yml b/core/themes/stable9/stable9.info.yml
index 4c757b84feed..fd2dd2e022fb 100644
--- a/core/themes/stable9/stable9.info.yml
+++ b/core/themes/stable9/stable9.info.yml
@@ -261,6 +261,11 @@ libraries-override:
       state:
         css/toolbar.menu.css: css/toolbar/toolbar.menu.css
 
+  tour/tour-styling:
+    css:
+      component:
+        css/tour.module.css: css/tour/tour.module.css
+
   update/drupal.update.admin:
     css:
       theme:
@@ -295,3 +300,7 @@ libraries-override:
     css:
       theme:
         css/field_ui_display_mode_table.css: css/field_ui/field_ui_display_mode_table.css
+
+libraries-extend:
+  tour/tour:
+    - stable9/tour
diff --git a/core/themes/stable9/stable9.libraries.yml b/core/themes/stable9/stable9.libraries.yml
index 98535a37153f..828fdd4aa16d 100644
--- a/core/themes/stable9/stable9.libraries.yml
+++ b/core/themes/stable9/stable9.libraries.yml
@@ -8,3 +8,8 @@ normalize:
   css:
     base:
       css/core/assets/vendor/normalize-css/normalize.css: { weight: -20 }
+
+tour:
+  version: VERSION
+  js:
+    js/tour.js: {}
-- 
GitLab