It would be great to add an option to move the node (content entity?) local tasks to the admin toolbar.
If you agree we could provide a patch.

| Comment | File | Size | Author |
|---|---|---|---|
| #49 | 3121440-49.patch | 4.59 KB | berliner |
| #48 | 3121440_local-tasks_48.patch | 4.96 KB | beunerd |
| #44 | local-tasks-secondary-toolbar.png | 217.79 KB | svdhout |
| #41 | 3263805-41.patch | 4.6 KB | dieterholvoet |
| #34 | 3121440-34.patch | 5.48 KB | nuuou |
Issue fork gin_toolbar-3121440
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
Comment #2
breidert commentedComment #3
saschaeggiCool idea, maybe we can make this a setting?
Comment #4
saschaeggi@breidert can you provide a patch for this?
Comment #5
breidert commented@sascha - yes we are on in and have it almost ready.
Comment #6
bjcooper commentedHow's it coming @breidert? We'd love to have this too and I'm willing to help. I was just about to re-invent this wheel.
Comment #7
breidert commented@bjcooper - we have this already implemented and will commit this as patch to https://www.drupal.org/project/gin_toolbar in the next days.
Currently we are working on another feature in the toolbar: https://www.drupal.org/project/gin_toolbar/issues/3129304
The local tasks in the toolbar (this issue) would probably come in after that.
Comment #8
a.dmitriiev commentedComment #9
a.dmitriiev commentedHere is the patch, that adds the local tasks to gin_toolbar. The only thing left so far is the icon. It should be added to gin, I guess.
Comment #10
a.dmitriiev commentedComment #11
bjcooper commentedPatch in #9 appears to work perfectly (except no icon for the local task toolbar item, of course).
Comment #12
a.dmitriiev commentedRe-rolled patch
Comment #13
breidert commentedI tested the patch against the latest dev branch and it works as expected.
Two styling issues need to be solved:
However, since these styles are configured in the gin theme, style changes cannot be delivered with this patch.
Therefore, the status RTBC is ok from my point of view.
Below is a screenshot of an empty page with the patch installed.
Comment #14
beunerd commentedJust a note that the patch in #12 is no longer working on dev. I'm getting:
Drupal\Core\Security\UntrustedCallbackException: Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was gin_toolbar_add_local_tasks_bar. See https://www.drupal.org/node/2966725 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 96 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).Comment #15
a.dmitriiev commentedComment #16
yjin commentedthe patch in #9 #12 is no longer working on latest betas.
Comment #17
broonI am late to this discussion, but I want to chip in the module Moderation Sidebar which works great on core's toolbar and basically puts all the local tasks into a sidebar already (hence the name).
However, it's not working with Gin Toolbar. Maybe you could join forces and support each other?
Comment #18
ciss commentedSetting status back to Needs Work according to #14.
Comment #19
saschaeggiAny update on this? I think the placement should be different, but that's something I can work on afterwards.
Comment #20
a.dmitriiev commentedI will try to work on this this week, maybe even today.
Comment #22
a.dmitriiev commentedI created the merge request with the updated functionality. Now pre_render uses class that implemets TrustedCallbackInterface.
Comment #23
dmitry.korhovApplied #21:
TypeError: Argument 1 passed to Drupal\Core\Render\Renderer::doTrustedCallback() must be callable, array given, called in /docroot/core/lib/Drupal/Core/Render/Renderer.php on line 781 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 51 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).Comment #24
a.dmitriiev commentedHave you cleaned the cache after you applied the patch? According to PHP documentation array could be passed as callable if there is static method of class in array https://www.php.net/manual/en/language.types.callable.php .
Comment #25
seanbAttached is a reroll, plus I changed/fixed the things noted below.
Think we now need this to be a TrustedCallback.
This seems to always render all local tasks in the admin menu (even for admin pages not related to entities). I found that a bit confusing. Maybe only add local tasks if the URL contains a content entity?
The link is missing some classes so the styling doesn't show up as expected.
Since view is mostly the first tab, shouldn't this also be the main link?
This now only add the cache metadata on pages that have local tasks. That could mean another page could set the cache for the admin menu without local tasks, and after that the local task never show up. I think we should always apply the local task cache metadata since even when local tasks are empty, we did use them to build our output.
Comment #26
seanbOne other minor thing, the icon for the local tasks was already in the code, but it looks a little off. That might be a separate issue, but we could maybe fix it here. I think it is because the lines are a different width from the other icons.
Comment #27
seanbJust found that when using the "admin_toolbar_links_access_filter" module you also need #3209342: Links without "original_link" are filtered by admin_toolbar_links_access_filter.
Comment #28
seanbActually needed a few more changes to make it work with "admin_toolbar_links_access_filter".
Comment #29
paulocsLooks good to me!
Thanks seanB.
Comment #30
christian.wiedemann commentedLooks great for me!
Comment #32
christian.wiedemann commentedReroll MR2. Works now with beta17.
Comment #33
nuuou commentedNoticed a few oddities here. Screenshots attached.
Comment #34
nuuou commentedAdjusted this, resolved the two issues I reported above. Modified existing patch with some additional attributes and respecting ordering.
Patch attached.
Comment #35
tijsdeboeckTested path #34, works like a charm! Thanks!
Comment #36
design.er commentedPatch #34 is working perfectly for me as well. Thanks for the implementation! :)
I second the question from #3: shouldn't this feature have an opt-out setting for site builders who prefer to use the local task tabs and avoid duplication?
Comment #37
seanbAfter using this for a while one of our clients found it confusing to have the local tasks and primary tabs so asked us to take this out again. I think it would be nice to have a setting to enable/disable this.
Comment #38
nuuou commentedHey all, I made a new related issue to this to add some more toolbar items my team needed.
I used the base of this new system from this current issue to extend to some other options, including Shortcuts and User Actions.
Depending on how this current issue moves forward, I'll watch to consolidate some stuff! Mostly didn't want to add to this issue as it's changed scope a bit for my need!
I hope to address some of the feedback here in that new issue as well, including the desire to make these a setting rather than just a default.
https://www.drupal.org/project/gin_toolbar/issues/3244394
Comment #39
undersound3 commentedWas using Better Local Tasks before but this is even better.
Patch #34 works great on beta20.
No visual clutter in the frontend anymore! Thanks!
Comment #40
dieterholvoet commentedI'm not convinced about this approach to add the local tasks to the toolbar. I think it's confusing since the admin toolbar links are global and the local tasks are, well, local. I don't think they should be mixed.
I'm personally more fan of the Better Local Tasks approach, I have been doing the same thing for my own projects in custom code: rendering the local tasks block as usual and apply custom css to it. Here's what that looks like, floating to the bottom right of the screen:
Another option is integrating it with the new meta region since there's already an entity edit link anyway, but the problem(?) there is that that region is not sticky, it disappears when you scroll down the page.
Comment #41
dieterholvoet commentedFor those interested in testing the current implementation, here's a version of the patch re-rolled against the dev branch.
Comment #42
nishruu commented#41 Local tasks are working back for me with the 3.0.0-beta1 of gin and beta-21 of gin_toolbar. Thank you @DieterHolvoet.
I can confirm that https://www.drupal.org/project/gin_toolbar/issues/3244394 current implementation is outdated as @Nuuou said (I understood you were waiting on this issue to adapt your work).
Comment #43
chi commentedWould be nice if it highlighted the active tab.
Comment #44
svdhout commentedJust noticed that admin_toolbar has an option within admin_toolbar_tools that adds the local tasks to the secondary toolbar
Comment #45
moshe weitzman commented@svdhout Thanks for letting us know! Looks pretty good to me.
Comment #46
saschaeggiClosing this in favor of the admin_toolbar solution mentioned in #44
Comment #48
beunerd commentedI liked the way the feature was implemented here better, so I've rebased the code to get a new patch that would apply.
Comment #49
berliner commentedRe-rolled for rc4
Comment #50
dieterholvoet commentedMaybe move this to a separate module instead of re-rolling? The issue is marked as Closed (won't fix).
Comment #51
flyke commentedCan confirm thatt patch #49 works with rc4.
I understand DieterHolvoet. But we have several projects at our company that are using gin + gin toolbar + local tasks at this moment, and we need to be able to update them. Changing the patch to a rc4 compatible patch in composer is the easiest way to do that for us at the moment, until a tried and tested separate module for this actually exists.