Problem/Motivation
Right now, we're printing a manually created menu in web/modules/navigation/src/Plugin/Navigation/NavigationUser.php into the footer of the admin toolbar. But the links listed in there are not the same ones the real menu would have.

Proposed resolution
Place the real user menu in there. For now it won't need to be customized on any way, and it will always be printed if the user is logged in.
This way the menu should print the user menu we would see with the old Toolbar, and the mapping would be:
- 1st level item "User menu" -> should print the actual name of the user, the same way it prints it now.
Profile-> View profileSettings-> Edit profileSign out-> Log out
The links should be the ones provided by the menu, but this menu should be printed with the current classes we are using on the hard coded one.
Note: Post MVP we might add the option to print the picture of the user if there is one, but it is totally out of scope for this issue.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | user-menu-from-user-module-service.png | 69.03 KB | prashant.c |
| #5 | user-menu.png | 24.52 KB | prashant.c |
| user-menu.png | 76.26 KB | ckrina |
Issue fork navigation-3408260
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
ckrinaComment #3
ckrinaComment #5
prashant.cAttempted to explore a solution using the "/admin/structure/menu/manage/account" menu to display user menu links. By default, it only presents two menu links: "My account" and "Logout" (or "Login" for anonymous users).
The menu links supplied by the toolbar are also hardcoded in the
core/modules/user/src/ToolbarLinkBuilder.phpfile:I would appreciate hearing your thoughts on this approach.
Thanks!
Comment #7
ckrinaAh, good point @Prashant.c! I didn't know the Toolbar was using hard-coded links now. We need the 3 links we have right now in the Toolbar:
So I would say then using those hard-coded links in the new navigation makes sense. Would it be a way to integrate this existing core code into this navigation and print those 3 links? If that was possible it would be logic that we would get rid of in this module and move it into core. We could change the naming of
ToolbarLinkBuilder.phpif needed, but we're actually working on a toolbar and naming it Toolbar too so it might not even be needed.What I would try to do then also is using the existing user name (like "admin" for example) as the value of the parent item, that right now has the "User".
Thank you!
Comment #8
prashant.cAn alternative method involves retrieving menu links directly from the

usermodule by utilizing theuser.toolbar_link_builderservice.We can explore these strategies, or if you have alternative plans for implementation, we can discuss those as well.
Thanks
Comment #9
prashant.cI have done it, you might want to review the modifications in the most recent commit.
Thanks
Comment #10
ckrinaThis is what was looking for exactly! Thank you! I'll RTBC it but it would be great to get a back-end dev to review the code :)
Comment #11
ckrinaChanging the state.
Comment #12
ckrinaChanged the status to NW per @larowlan's feedback. Please change it back to NR if the changes have been made.
Comment #13
prashant.c@ckrina
Changes have already been made yesterday https://www.drupal.org/project/navigation/issues/3408260#mr149-note242559
Thanks
Comment #14
m4oliveiI've added some feedback in the PR.
It looks like @larowlan's feedback was all addressed. I made some additional comments, mostly with respect to keeping the existing naming and structure of the theme hook (
menu_region__footer) as close to what it already is as possible.Great work so far though, funcationally working as advertised.
Comment #15
prashant.c@m4olivei, appreciate your review. I've taken care of all the comments you provided. Updating the issue status to NR once more. Thanks.
Comment #16
m4oliveiLooks great! Thanks for that changes @Prashant.c. Also noting that all of @larowlan's requested changes seem to have been incorporated as well.
This is RTBC for me.
Comment #18
ckrinaThank all, fixed!
Just a small suggestion if I may ask: it would make my life way easier that when a thread is resolved it is marked as so on a MR, so then I'm sure it's done (since it's not as easy for me to review back-end code) :)
Comment #19
prashant.c@ckrina Sure, we will do that.
Thank you.