diff --git a/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml b/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml index edaabb1e223cd755dba3cf07fc2aa400cc7a8d07..988cf9a1bd3cd1f66ef9044f384a017617f594e6 100644 --- a/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml +++ b/core/modules/navigation/modules/navigation_top_bar/navigation_top_bar.info.yml @@ -1,8 +1,9 @@ name: Navigation Top Bar type: module -description: 'When enabled, this module provides relevant administrative information and tasks for the current page on a top bar. It is not feature complete nor fully functional so enabling it could lead to possible inconsistencies.' +description: 'Obsolete. All the functionality has been moved to the navigation module.' package: Core (Experimental) -lifecycle: experimental +lifecycle: obsolete +lifecycle_link: 'https://www.drupal.org/docs/core-modules-and-themes/deprecated-and-obsolete#s-understanding-obsolete-extensions' version: VERSION dependencies: - navigation:navigation diff --git a/core/modules/navigation/modules/navigation_top_bar/src/Hook/NavigationTopBarHooks.php b/core/modules/navigation/modules/navigation_top_bar/src/Hook/NavigationTopBarHooks.php deleted file mode 100644 index 7c76e867bb2deabd1f43a3681eff81ccaafdcacf..0000000000000000000000000000000000000000 --- a/core/modules/navigation/modules/navigation_top_bar/src/Hook/NavigationTopBarHooks.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -namespace Drupal\navigation_top_bar\Hook; - -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\Hook\Attribute\Hook; -use Drupal\Core\StringTranslation\StringTranslationTrait; - -/** - * Hook implementations for navigation_top_bar. - */ -class NavigationTopBarHooks { - - use StringTranslationTrait; - - /** - * Implements hook_help(). - */ - #[Hook('help')] - public function help($route_name, RouteMatchInterface $route_match): ?string { - switch ($route_name) { - case 'help.page.navigation_top_bar': - $output = '<h2>' . $this->t('About') . '</h2>'; - $output .= '<p>' . $this->t('The Navigation Top Bar module is a Feature Flag module which, when enabled, renders the experimental navigation top bar.') . '</p>'; - $output .= '<p>' . $this->t('The top bar provides relevant administrative information and tasks for the current page. It is not feature complete nor fully functional.') . '</p>'; - $output .= '<p>' . $this->t('Leaving this module enabled can affect both admin and front-end pages layouts and blocks like Primary admin actions, whose content might be moved to te top bar.') . '</p>'; - $output .= '<p>' . $this->t('It is recommended to leave this module off while it is under active development and experimental phase.') . '</p>'; - $output .= '<p>' . $this->t('For more information, see the <a href=":docs">online documentation for the Navigation Top Bar module</a>.', [':docs' => 'https://www.drupal.org/project/navigation']) . '</p>'; - return $output; - } - return NULL; - } - -} diff --git a/core/modules/navigation/modules/navigation_top_bar/tests/src/Functional/GenericTest.php b/core/modules/navigation/modules/navigation_top_bar/tests/src/Functional/GenericTest.php deleted file mode 100644 index 69c4913ab3f6f4da5cadea93e46b8a770d74bd77..0000000000000000000000000000000000000000 --- a/core/modules/navigation/modules/navigation_top_bar/tests/src/Functional/GenericTest.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\navigation_top_bar\Functional; - -use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; - -/** - * Generic module test for navigation_top_bar. - * - * @group navigation_top_bar - */ -class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/navigation/navigation.post_update.php b/core/modules/navigation/navigation.post_update.php index db25c0a332851e4abdd8df6e3eafe43a25e89244..fad303185db7ef8df49229b6c40e79e6cc6fa7e7 100644 --- a/core/modules/navigation/navigation.post_update.php +++ b/core/modules/navigation/navigation.post_update.php @@ -60,3 +60,14 @@ function navigation_post_update_navigation_user_links_menu(array &$sandbox): voi 'locked' => TRUE, ])->save(); } + +/** + * Uninstall the navigation_top_bar module if installed. + * + * @see https://www.drupal.org/project/drupal/issues/3507866 + */ +function navigation_post_update_uninstall_navigation_top_bar(): void { + if (\Drupal::moduleHandler()->moduleExists('navigation_top_bar')) { + \Drupal::service('module_installer')->uninstall(['navigation_top_bar'], FALSE); + } +} diff --git a/core/modules/navigation/src/NavigationRenderer.php b/core/modules/navigation/src/NavigationRenderer.php index fe8792bc4926a1148b1f792b69a721d9c6624089..dfb9dd7cc779db30a5ff6a0011ba03b7eff3deb4 100644 --- a/core/modules/navigation/src/NavigationRenderer.php +++ b/core/modules/navigation/src/NavigationRenderer.php @@ -204,10 +204,6 @@ protected function getContentTop(): array { * @see hook_page_top() */ public function buildTopBar(array &$page_top): void { - if (!$this->moduleHandler->moduleExists('navigation_top_bar')) { - return; - } - $page_top['top_bar'] = [ '#type' => 'top_bar', '#access' => $this->currentUser->hasPermission('access navigation'), @@ -236,7 +232,7 @@ public function removeLocalTasks(array &$build, BlockPluginInterface $block): vo if ($block->getPluginId() !== 'local_tasks_block') { return; } - if ($this->hasLocalTasks() && $this->moduleHandler->moduleExists('navigation_top_bar')) { + if ($this->hasLocalTasks()) { $build['#access'] = FALSE; } } diff --git a/core/modules/navigation/tests/src/Functional/NavigationShortcutsBlockTest.php b/core/modules/navigation/tests/src/Functional/NavigationShortcutsBlockTest.php index 93fd7df80ca49f78e1495f3773d26964db394913..a4b6c7ecabe182119649fb00e92f204d6dc48f59 100644 --- a/core/modules/navigation/tests/src/Functional/NavigationShortcutsBlockTest.php +++ b/core/modules/navigation/tests/src/Functional/NavigationShortcutsBlockTest.php @@ -116,13 +116,13 @@ public function testNavigationBlock(): void { $this->drupalLogin($site_configuration_user1); $this->verifyDynamicPageCache($test_page_url, 'MISS'); $this->verifyDynamicPageCache($test_page_url, 'HIT'); - $this->assertCacheContexts(['user', 'url.query_args:_wrapper_format', 'session']); + $this->assertCacheContexts(['user', 'url.query_args:_wrapper_format', 'session', 'route']); $this->assertSession()->pageTextContains('Shortcuts'); $this->assertSession()->linkExists('Cron'); $this->drupalLogin($site_configuration_user2); $this->verifyDynamicPageCache($test_page_url, 'HIT'); - $this->assertCacheContexts(['user', 'url.query_args:_wrapper_format', 'session']); + $this->assertCacheContexts(['user', 'url.query_args:_wrapper_format', 'session', 'route']); $this->assertSession()->pageTextContains('Shortcuts'); $this->assertSession()->linkExists('Cron'); diff --git a/core/modules/navigation/tests/src/Functional/NavigationTopBarContentModerationTest.php b/core/modules/navigation/tests/src/Functional/NavigationTopBarContentModerationTest.php index bb9ab36e2f0a03d1c27660c372947fba6b80c9e0..71e96ae36c73c871f006b5f5630e794d81b630b1 100644 --- a/core/modules/navigation/tests/src/Functional/NavigationTopBarContentModerationTest.php +++ b/core/modules/navigation/tests/src/Functional/NavigationTopBarContentModerationTest.php @@ -25,7 +25,7 @@ class NavigationTopBarContentModerationTest extends ModerationStateTestBase { protected static $modules = [ 'content_moderation', 'node', - 'navigation_top_bar', + 'navigation', ]; /** diff --git a/core/modules/navigation/tests/src/Functional/NavigationTopBarPageContextTest.php b/core/modules/navigation/tests/src/Functional/NavigationTopBarPageContextTest.php index 800106b1e0f452a1ed7f91e166a8a74337303059..51c0ea4dc9f4459dbd94d6196e2dc82fe9723626 100644 --- a/core/modules/navigation/tests/src/Functional/NavigationTopBarPageContextTest.php +++ b/core/modules/navigation/tests/src/Functional/NavigationTopBarPageContextTest.php @@ -26,7 +26,6 @@ class NavigationTopBarPageContextTest extends BrowserTestBase { protected static $modules = [ 'node', 'navigation', - 'navigation_top_bar', 'test_page_test', ]; diff --git a/core/modules/navigation/tests/src/Functional/NavigationTopBarTest.php b/core/modules/navigation/tests/src/Functional/NavigationTopBarTest.php index 7165eb946fd0656798572b850bef39277fb58f85..91c1875a4e031660f81f1f7387145aeb25975a5b 100644 --- a/core/modules/navigation/tests/src/Functional/NavigationTopBarTest.php +++ b/core/modules/navigation/tests/src/Functional/NavigationTopBarTest.php @@ -85,21 +85,7 @@ public function testTopBarVisibility(): void { $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->assertSession()->elementNotExists('xpath', "//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button"); - $this->verifyDynamicPageCache($this->node->toUrl(), 'MISS'); - $this->verifyDynamicPageCache($this->node->toUrl(), 'HIT'); - // Top Bar is not visible if the feature flag module is disabled. - $this->assertSession()->elementNotExists('xpath', "//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button"); - $this->assertSession()->elementExists('xpath', '//div[@id="block-tabs"]'); - - \Drupal::service('module_installer')->install(['navigation_top_bar']); - - // Test page does not include the Top Bar. - $test_page_url = Url::fromRoute('test_page_test.test_page'); - $this->verifyDynamicPageCache($test_page_url, 'MISS'); - $this->verifyDynamicPageCache($test_page_url, 'HIT'); - $this->assertSession()->elementNotExists('xpath', "//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button"); - - // Top Bar is visible once the feature flag module is enabled. + // Top Bar is visible on node pages. $this->verifyDynamicPageCache($this->node->toUrl(), 'MISS'); $this->verifyDynamicPageCache($this->node->toUrl(), 'HIT'); $this->assertSession()->elementExists('xpath', "(//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button)[1]"); diff --git a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php index f447a9aa3aae9974e1fcc63079b8169738ca2961..2c5296d0a780a09c4ee44228f8214547b9acc0f9 100644 --- a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php +++ b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php @@ -73,14 +73,14 @@ public function testLogin(): void { $expected = [ 'QueryCount' => 4, - 'CacheGetCount' => 58, + 'CacheGetCount' => 60, 'CacheGetCountByBin' => [ 'config' => 11, 'data' => 5, 'discovery' => 10, 'bootstrap' => 6, 'dynamic_page_cache' => 2, - 'render' => 23, + 'render' => 25, 'menu' => 1, ], 'CacheSetCount' => 2, diff --git a/core/modules/navigation/tests/src/FunctionalJavascript/TopBarPerformanceTest.php b/core/modules/navigation/tests/src/FunctionalJavascript/TopBarPerformanceTest.php deleted file mode 100644 index 796e02332c4b96b7ed368b77bd9692afcf1d530c..0000000000000000000000000000000000000000 --- a/core/modules/navigation/tests/src/FunctionalJavascript/TopBarPerformanceTest.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\navigation\FunctionalJavascript; - -use Drupal\Core\Cache\Cache; -use Drupal\FunctionalJavascriptTests\PerformanceTestBase; - -/** - * Tests the performance impacts of navigation module. - * - * Stark is used as the default theme so that this test is not Olivero specific. - * - * @group navigation - */ -class TopBarPerformanceTest extends PerformanceTestBase { - - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'navigation', - ]; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - - /** - * {@inheritdoc} - */ - protected $profile = 'testing'; - - /** - * Tests performance for anonymous users is not affected by the Top Bar. - */ - public function testTopBarPerformance(): void { - // Request the front page, then immediately clear all object caches, so that - // aggregates and image styles are created on disk but otherwise caches are - // empty. - $this->drupalGet(''); - // Give time for big pipe placeholders, asset aggregate requests, and post - // response tasks to finish processing and write to any caches before - // clearing caches again. - sleep(2); - foreach (Cache::getBins() as $bin) { - $bin->deleteAll(); - } - - // Gather performance data before enabling navigation_top_bar. - $performance_data_before_top_bar = $this->collectPerformanceData(function () { - $this->drupalGet(''); - }, 'navigationFrontPageTopBarDisabled'); - - // Install navigation_top_bar module. - \Drupal::service('module_installer')->install(['navigation_top_bar']); - - // Clear caches to prep for another performance data collect. - foreach (Cache::getBins() as $bin) { - $bin->deleteAll(); - } - - // Gather performance data after enabling navigation_top_bar. - $performance_data_after_top_bar = $this->collectPerformanceData(function () { - $this->drupalGet(''); - }, 'navigationFrontPageTopBarEnabled'); - - // Ensure that there is no change to performance metrics from the Top Bar. - // Anonymous users should never see the Top Bar. - $this->assertMetrics([ - 'QueryCount' => $performance_data_before_top_bar->getQueryCount(), - 'CacheGetCount' => $performance_data_before_top_bar->getCacheGetCount(), - 'CacheSetCount' => $performance_data_before_top_bar->getCacheSetCount(), - 'CacheDeleteCount' => $performance_data_before_top_bar->getCacheDeleteCount(), - 'CacheTagInvalidationCount' => $performance_data_before_top_bar->getCacheTagInvalidationCount(), - ], $performance_data_after_top_bar); - } - -} diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 7bf3fb32f3459138c79d944c91c156302065b30c..d30459033dba23604db012c156a3caee301586ca 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -108,7 +108,6 @@ <directory>modules/config/tests/config_test/tests/src/Functional</directory> <directory>modules/system/tests/modules/entity_test/tests/src/Functional</directory> <directory>modules/layout_builder/modules/layout_builder_expose_all_field_blocks/tests/src/Functional</directory> - <directory>modules/navigation/modules/navigation_top_bar/tests/src/Functional</directory> <directory>profiles/**/tests/src/Functional</directory> <directory>profiles/demo_umami/modules/demo_umami_content/tests/src/Functional</directory> <directory>recipes/*/tests/src/Functional</directory>