From 09d6866435fee0eaee8c92d7451cbca51e04b3af Mon Sep 17 00:00:00 2001 From: Pamela Barone <31375-pameeela@users.noreply.drupalcode.org> Date: Wed, 29 Jan 2025 07:10:07 +0000 Subject: [PATCH 1/2] Adds model to override labels --- recipes/drupal_cms_starter/composer.json | 2 +- ...lter_project_browser_local_task_labels.yml | 45 +++++++++++++++++++ recipes/drupal_cms_starter/recipe.yml | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml diff --git a/recipes/drupal_cms_starter/composer.json b/recipes/drupal_cms_starter/composer.json index 22c033156..d2e8dbafd 100644 --- a/recipes/drupal_cms_starter/composer.json +++ b/recipes/drupal_cms_starter/composer.json @@ -7,7 +7,7 @@ "drupal/automatic_updates": "^3.1.7", "drupal/bpmn_io": "^2.0.3", "drupal/core": ">=10.4", - "drupal/eca": "^2.1", + "drupal/eca": "^2.1.2", "drupal/dashboard": "^2", "drupal/drupal_cms_admin_ui": "^1", "drupal/drupal_cms_anti_spam": "^1", diff --git a/recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml b/recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml new file mode 100644 index 000000000..ae78c3530 --- /dev/null +++ b/recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml @@ -0,0 +1,45 @@ +langcode: en +status: true +dependencies: + module: + - eca_project_browser +id: alter_project_browser_local_task_label +modeller: bpmn_io +label: 'Alter Project Browser local task label' +version: 1.0.0 +weight: 0 +events: + Event_alter_source_info: + plugin: 'project_browser:source_info_alter' + label: 'Alter source info' + configuration: { } + successors: + - + id: Activity_set_title + condition: '' + - + id: Activity_0dlv38b + condition: '' +conditions: { } +gateways: { } +actions: + Activity_set_title: + plugin: eca_project_browser_source_plugin_info_alter + label: 'Set recipes title' + configuration: + plugin_id: recipes + label: '' + description: '' + local_task_title: Recommended + local_task_weight: '0' + successors: { } + Activity_0dlv38b: + plugin: eca_project_browser_source_plugin_info_alter + label: 'Set modules title' + configuration: + plugin_id: drupalorg_jsonapi + label: '' + description: '' + local_task_title: 'Browse modules' + local_task_weight: '' + successors: { } diff --git a/recipes/drupal_cms_starter/recipe.yml b/recipes/drupal_cms_starter/recipe.yml index 35029517c..31008fbe4 100644 --- a/recipes/drupal_cms_starter/recipe.yml +++ b/recipes/drupal_cms_starter/recipe.yml @@ -23,6 +23,7 @@ install: - eca_base - eca_config - eca_content + - eca_project_browser - eca_render - menu_link_content - olivero -- GitLab From 36c0892de5aa6a62442387e03c3efcb73681d1e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net> Date: Wed, 29 Jan 2025 09:23:39 -0500 Subject: [PATCH 2/2] Rename ECA model and add test coverage --- ...> eca.eca.rename_project_browser_tabs.yml} | 12 ++++---- .../Functional/ComponentValidationTest.php | 29 ++++++++++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) rename recipes/drupal_cms_starter/config/{eca.eca.alter_project_browser_local_task_labels.yml => eca.eca.rename_project_browser_tabs.yml} (80%) diff --git a/recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml b/recipes/drupal_cms_starter/config/eca.eca.rename_project_browser_tabs.yml similarity index 80% rename from recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml rename to recipes/drupal_cms_starter/config/eca.eca.rename_project_browser_tabs.yml index ae78c3530..63778038a 100644 --- a/recipes/drupal_cms_starter/config/eca.eca.alter_project_browser_local_task_labels.yml +++ b/recipes/drupal_cms_starter/config/eca.eca.rename_project_browser_tabs.yml @@ -3,15 +3,15 @@ status: true dependencies: module: - eca_project_browser -id: alter_project_browser_local_task_label -modeller: bpmn_io -label: 'Alter Project Browser local task label' +id: rename_project_browser_tabs +modeller: fallback +label: 'Rename Project Browser tabs' version: 1.0.0 weight: 0 events: Event_alter_source_info: plugin: 'project_browser:source_info_alter' - label: 'Alter source info' + label: 'Alter source plugin info' configuration: { } successors: - @@ -25,7 +25,7 @@ gateways: { } actions: Activity_set_title: plugin: eca_project_browser_source_plugin_info_alter - label: 'Set recipes title' + label: 'Change title of recipes tab' configuration: plugin_id: recipes label: '' @@ -35,7 +35,7 @@ actions: successors: { } Activity_0dlv38b: plugin: eca_project_browser_source_plugin_info_alter - label: 'Set modules title' + label: 'Change title of contributed modules tab' configuration: plugin_id: drupalorg_jsonapi label: '' diff --git a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php index 038208c90..5ae5c1e1e 100644 --- a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php +++ b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Drupal\Tests\drupal_cms_starter\Functional; +use Behat\Mink\Element\NodeElement; use Composer\InstalledVersions; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; @@ -159,12 +160,32 @@ class ComponentValidationTest extends BrowserTestBase { $assert_session->linkExists("Search for this $node_type"); } - // If you have permission to administer modules, you should see a dedicated - // tab to browse recipes. + // Ensure that the Project Browser local tasks work as expected. $account = $this->drupalCreateUser(['administer modules']); $this->drupalLogin($account); - $this->drupalGet('/admin/modules/browse/recipes'); - $assert_session->statusCodeEquals(200); + $this->drupalGet('/admin/modules'); + // Get the Project Browser local tasks. + $elements = $assert_session->elementExists('css', 'h2:contains("Primary tabs") + nav') + ->findAll('css', 'ul li a'); + $local_tasks = []; + /** @var \Behat\Mink\Element\NodeElement $element */ + foreach ($elements as $element) { + $link_text = $element->getText(); + $local_tasks[$link_text] = $element->getAttribute('data-drupal-link-system-path'); + } + // The first task should go to core's regular modules page. + $this->assertSame('admin/modules', reset($local_tasks)); + // Ensure the Project Browser tasks are in the expected order, have the + // expected link text, and link to the expected place. + $project_browser_tasks = preg_grep('|admin/modules/browse/.+|', $local_tasks); + $this->assertSame(['Recommended', 'Browse modules'], array_keys($project_browser_tasks)); + $this->assertStringEndsWith('/recipes', $project_browser_tasks['Recommended']); + $this->assertStringEndsWith('/drupalorg_jsonapi', $project_browser_tasks['Browse modules']); + // We should have access to all Project Browser tasks. + foreach ($project_browser_tasks as $path) { + $this->drupalGet($path); + $assert_session->statusCodeEquals(200); + } } } -- GitLab