Problem/Motivation
Sites might want to give users access to the toolbar that aren't actually admins. For example, to provide easy access to shortcuts, a more slick user menu experience, etc. Toolbar doesn't have to just be for admins.
However, as currently written, toolbar.module assumes that anyone seeing the toolbar must be an admin, and it always provides a "Manage" tray, even if the user cannot access any admin links and the tray is empty.
Note: although the machine name for the permission to use the toolbar is just access toolbar
, the label in the admin UI is unfortunately called "Use the administration toolbar". Fixing that is at #3025839: Change toolbar's permission label to 'Use the toolbar'. A more complete solution for this will be at #1044090: Enable toolbar for authenticated users also, so that non-admin users can use shortcuts as well. This issue is only about fixing the bug in the toolbar that renders an empty tray, not about "rebranding" the toolbar to stop assuming only "admins" use it.
Steps to reproduce
- Disable shortcut module (to avoid confusion).
- Create a user with
access toolbar
permission but nothing admin-related. In particular, notaccess administration pages
. - Login as the non-admin auth user.
- You should see an empty "Manage" tray in the toolbar (along with the "User" tray).
- If you apply the latest patch, clear all caches, and reload a page, the "Manage" tray should disappear and you should just have the User tray.
Proposed resolution
Test if the current user has access administration pages
permission before doing any work to create/render the "Manage" link and tray in the toolbar.
It'd be "better" to see if the admin menu is in fact empty for the user, but thanks to lazy loading, #pre_render, #2301317: MenuLinkNG part4: Conversion and all sorts of other unfathomable complication, that code is now far removed from where we actually register the 'Manage' toolbar link/tray.
Remaining tasks
Write and verify test (comment #27)Write code that fixes failing test (comment #39)- Review
- Commit
- Rejoice (and unblock [#1044090])
User interface changes
Fixes a UI bug where an empty "Manage" tray appears for users who don't have access to any administration pages.
Before
After
API changes
None.
Original report by @jessebeach
Almost anyone developing on Drupal 8 has admin privileges to their local site. We rarely see that Toolbar module under a permission set that doesn't have god-access.
We need to do some permission combo tests and verify that the Toolbar renders and displays well when a user does not have bypass privileges, but simple privilege sets that someone like a content editor might have.
Permission Combinations
Standard authenticated user with use administration toolbar permission
The Menu tab is visible and the tray is empty. The tab should not be visible.
Test the Toolbar against reduced permission sets that simulate non-admin users: content producers, content editors, site builders, etc.