This is a follow-up to: #3554658: Admin Toolbar Search: Remove dependency on Admin Toolbar

Problem/Motivation

After removing the dependency on Admin Toolbar in submodule Admin Toolbar Search and the recent work carried on refactoring the Admin Toolbar Tools module tests, it appeared the module still has a dependency on Admin Toolbar.

Theoretically, there is no reason the Admin Toolbar Tools module could not work properly without the Admin Toolbar module and in fact.... without any dependency.
See dependency in the code:
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.6.2/admin_tool...

Additionally, it could really help further clarifying the role of each module:

  • Admin Toolbar: Provides the JS dropdown menu features (Mostly front-end logic adding JS libraries).
  • Admin Toolbar Tools: Provides extra links for Tools (such as flush cache, etc...) or for configuration pages under: "Content", "Structure", "Configuration", "People", etc... Along with useful links integrated with other contrib modules, such as devel, project_browser, etc... (Mostly back-end logic adding links).

 
Looking at the code, there doesn't seem to be any reason this dependency would be necessary, in the sense, the module does not seem to use any feature from the admin_toolbar module, whether, JS, CSS, images, etc...

In other words, the impacts and changes that could be required would be very limited, while still allowing to decouple entirely the modules to provide more flexibility.
The idea behind that is to try to make the code packages as granular as possible, with only the dependencies that are really required in code.

An immediate application of this change would be the ability to enable admin_toolbar_tools along with the Drupal core Navigation module to add extra links, for example, under "Structure", such as "Content types", etc...

Steps to reproduce

Enable the admin_toolbar_tools module ==> Requires admin_toolbar to be enabled.

To uninstall the admin_toolbar module, the admin_toolbar_tools module needs to be uninstalled first.

Proposed resolution

Remove any dependency:
admin_toolbar_tools.css: The styles of the module should work fine with the Toolbar module enabled and they should not be loaded otherwise.

ToolbarController: All the services injected in the create method are from core.services.yml, so no extra dependency should be required as long as Drupal core is loaded.
Note that function views_invalidate_cache (requiring Views) used by the "Flush views cache" menu link is not directly linked in the links.menu.yml of the module, but is conditionally added as a link in the 'Extralinks' class if the Views module is enabled.
In other words, there should not be any required dependency.

ExtraLinks: It is a plugin derivative class which is triggered by MenuLinkManager which is also part of Drupal core services. All the code of the method getDerivativeDefinitions should be able to run properly with any dependency being checked.

AdminToolbarToolsHelper and admin_toolbar_tools.services.yml: All the services dependencies are on Drupal core services ==> No extra dependency needed.

admin_toolbar_tools.module: It should be fine to keep all the hooks as they currently are.
They just would not be triggered if the corresponding module is not enabled, for example: Toolbar, etc...
But it should not prevent the use of the rest of the module, for example ExtraLinks.

Impacted files:
admin_toolbar_tools.info.yml: Remove dependency constraint.
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.6.2/admin_tool...

AdminToolbarToolsSettingsFormTest
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.6.2/admin_tool...
Enable the 'admin_toolbar' module for the tests.

AdminToolbarToolsToolbarControllerTest
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.6.2/admin_tool...
Enable the 'admin_toolbar' module for the tests.

AdminToolbarToolsSortTest
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.x/tests/src/Fu...
Enable the 'admin_toolbar' module for the tests.

Add a simple Functional test class to test the module without admin_toolbar:
AdminToolbarToolsTest.php
or adapt new ones refactored in other issue/ticket.
Enable admin_toolbar_tools and check specific menu links added by the module.
 

The rest of the code should stay unchanged, in particular all the Automated tests and the module should work very well with the current dependencies.

Remaining tasks

User interface changes

When enabling the admin_toolbar_tools module, the admin_toolbar module will no longer be enabled at the same time, but users will have to enable/select it manually as well.

Before:
Select admin_toolbar_tools to be enabled ==> Enabled admin_toolbar_tools and admin_toolbar.

After:
Select admin_toobar_tools to be enabled ==> Enabled admin_toolbar_tools.

Select admin_toobar_tools and admin_toolbar ==> Enabled admin_toolbar_tools and admin_toolbar.

Select admin_toolbar_tools and admin_toolbar_search ==> Enabled admin_toolbar_tools and admin_toolbar_search.

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dydave created an issue. See original summary.

dydave’s picture

Status: Active » Needs review
StatusFileSize
new71.32 KB
new90.87 KB

Quick follow-up on this issue:

All the changes detailed in the issue summary have been implemented and described in the merge request MR !188 above at #2.

Since all the tests and jobs still seem to be passing 🟢, moving issue to Needs review as an attempt to get more testing feedback and reviews.

More work is probably needed on tests coverage but could probably be addressed in follow-up issues, for example, for some refactoring or adding new test classes.
This merge request and issue account for the bare minimum required to remove the dependency.

An immediate result of this change is the ability to enable admin_toolbar_tools with Drupal core navigation, see the screenshots below illustrating the integration with extra links added:

Before: Admin Toolbar Tools disabled

 

After: Admin Toolbar Tools enabled

 

The integration seems to require some work, but at the very least almost all the links added by the Admin Toolbar Tools module should be accessible/usable with the core Navigation menu. 👍
It should not break or there should not be any crash preventing normal usage of the modules.
This is an initial step towards getting better integration support with the core navigation module.

Feel free to let us know if you have any comments, questions or concerns on any aspects of this issue or the suggested changes in the merge request, we would surely be glad to help.
Thanks in advance!

ressa’s picture

Status: Needs review » Reviewed & tested by the community

Great work @dydave! Allowing the Admin Toolbar Tools to be installed by itself as a standalone module, while being able to work together with several other modules, is a great idea. I can confirm that the Admin Toolbar Tools module can now be installed by itself. Also, it is able to extend the functionality of the Drupal core Navigation module, for example by adding the actual content types under "Structure > Content types > Article", and also the "Flush XYZ cache" options. And it still works well with the Admin Toolbar modules, as previously. I agree that sorting out details such as adding support for "Flush all caches" when used with Navigation could be a follow up task. Thanks!

  • dydave committed 497a1462 on 3.x
    Issue #3556081 by dydave: Admin Toolbar Tools: Removed module...
dydave’s picture

Status: Reviewed & tested by the community » Fixed

Thanks a lot @ressa for taking the time to test and review this issue!
I knew you might be interested to see how the module could work with the new Navigation module. 😉

Following your confirmation, I thought I might consolidate a bit the changes from the MR, in particular, add a specific Functional tests class for the standalone 'admin_toolbar_tools' module.

So I started adding the test class and realized the checkbox to select show_local_tasks was useless without the Drupal core Toolbar module, so I added a quick check for that. 👌

Once I was satisfied with the initial tests class and that all the jobs and tests were still passing 🟢, I went ahead and merged the changes above at #5. 🥳

I also created a follow-up issue to #3556898: Admin toolbar tools: Improve support for core Navigation, with the resulting screenshots from this issue at the top, so we could easily pick this up later where we left off. 👌

Marking this issue as Fixed, for now.

Still more pending tickets in the queue! 👍
Thanks again very much for your great help @ressa! 🙏

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

ressa’s picture

You're welcome @dydave, thanks for expanding the tests with even more coverage. And yes, it was very interesting to see the interaction with the Navigation module 😊

I have subscribed to the #3556898: Admin toolbar tools: Improve support for core Navigation issue and will follow along, and help out if I can. Thanks again @dydave!

ressa’s picture

Oops, already referenced :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.