Problem/Motivation

Why not give option to change depth of menu that is shown.
Now it is hardcoded to 4.

Steps to reproduce

Proposed resolution

Two solutions
1. Create config form where we can configure this.
2. At least invoke alter hook so we can alter depth value

Remaining tasks

User interface changes

API changes

Data model changes

Comments

DavorHorvacki created an issue. See original summary.

roman-yrv’s picture

Assigned: Unassigned » roman-yrv

I will try to do it as a config form

roman-yrv’s picture

Status: Active » Needs review
StatusFileSize
new18.29 KB
new7 KB

I have done it.
Admin Toolbar config form
You can test it.

guilhermevp’s picture

StatusFileSize
new68.93 KB

I'm trying to apply the patch at the root of the module folder in the version 3.x-dev with no success.

roman-yrv’s picture

StatusFileSize
new6.33 KB

Yes, unfortunately, that patch was generated incorrectly.
I recreated the patch.
Can you test it?

guilhermevp’s picture

Assigned: roman-yrv » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new592.45 KB

Patch applies cleanly now, works perfectly!

Add video as evidence.

romainj’s picture

Thanks for the work. My only concern is that we already have a config form in the Admin Toolbar Extra Tools module. So maybe we should use it.

guilhermevp’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.45 KB

Changed the functionality to Admin Toolbar Tools config menu. Please review.

marcusvsouza’s picture

Status: Needs review » Reviewed & tested by the community

The patch in the comment #8 applies perfectly and runs as expected!

chegor’s picture

+1 RTBC

neclimdul’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/admin_toolbar_tools/admin_toolbar_tools.install
    @@ -32,3 +32,13 @@ function admin_toolbar_tools_update_8202() {
    +  ->save(TRUE);
    +}
    \ No newline at end of file
    
    +++ b/src/Render/Element/AdminToolbar.php
    @@ -36,7 +36,13 @@ class AdminToolbar implements TrustedCallbackInterface {
    +      $max_depth = \Drupal::config('admin_toolbar_tools.settings')->get('menu_depth');
    

    This removes the newline from the file.

  2. +++ b/src/Render/Element/AdminToolbar.php
    @@ -36,7 +36,13 @@ class AdminToolbar implements TrustedCallbackInterface {
    +    if (\Drupal::service('module_handler')->moduleExists('admin_toolbar_tools')) {
    +      $max_depth = \Drupal::config('admin_toolbar_tools.settings')->get('menu_depth');
    +    }
    +    else {
    +      $max_depth = 4;
    +    }
    

    This is a bit awkward. The configuration is clearly for the admin toolbar module. I'm not sure what the added complexity with the module check and the extra module adds other then additional overhead of the module check. Seems to me like Roman had the right approach in #5.

Also, this adds an update to set the value and schema for the config but doesn't set the default value in the config install. Seems like that would make new installs inconsistent and possibly broken.

neclimdul’s picture

Looking back, none of the problems from my previous review apply to #5. IMHO I think that was probably the right approach and probably RTBC.

pasqualle’s picture

Status: Needs work » Reviewed & tested by the community

One small suggestion: The config should be checked before updated in hook_update_N().
But as that was not done even in previous updates, then I am OK with that.

paulocs’s picture

Assigned: Unassigned » paulocs
Status: Reviewed & tested by the community » Needs work

I agree with #11. Patch #8 needs some work.
Why is it a problem to create a new settings form?
IMHO it does not right to add this configuration in the admin_toolbar_tools module.

paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.94 KB

A new patch with the same approach of patch #5.

Status: Needs review » Needs work

The last submitted patch, 15: 3200542-15.patch, failed testing. View results

paulocs’s picture

Status: Needs work » Needs review
StatusFileSize
new480 bytes
new5.96 KB

Ops.

marcusvsouza’s picture

StatusFileSize
new14.03 KB
new89.63 KB

Testing Steps

  • Go to admin/config/user-interface/admin-toolbar
  • Click in the dropdown Menu depth
  • Change the value to 1
  • Save
  • Check the menu depth

Expected Results

  • Change the menu depth accordingly to the value selected

Actual Results

  • Menu depth correctly changes accordingly to the value selected

The code follows the standards and not change any other functionalities.

marcusvsouza’s picture

Status: Needs review » Reviewed & tested by the community

  • adriancid committed 11640cb on 3.x authored by paulocs
    Issue #3200542 by roman-yrv, paulocs, guilhermevp, marcusvsouza,...
adriancid’s picture

Status: Reviewed & tested by the community » Fixed

Thanks

Status: Fixed » Closed (fixed)

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