Print the real User account menu in the footer

Created on 12 December 2023, about 1 year ago
Updated 2 January 2024, 12 months ago

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.
    • -> View profile
    • -> Edit profile
    • -> 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

๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Pipeline finished with Skipped
    about 1 year ago
    #30243
  • Issue created by @ckrina
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    Prashant.c โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    Attempted 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.php file:

    • View profile
    • Edit profile
    • Log out

    I would appreciate hearing your thoughts on this approach.

    Thanks!

  • Merge request !149User account menu as user menu โ†’ (Merged) created by prashant.c
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    Ah, 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:

    1. A way to view the profile
    2. A way to edit the profile, which right now is going into the form
    3. A way to log out

    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.php if 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!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    An alternative method involves retrieving menu links directly from the user module by utilizing the user.toolbar_link_builder service.

    We can explore these strategies, or if you have alternative plans for implementation, we can discuss those as well.

    Thanks

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    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".

    I have done it, you might want to review the modifications in the most recent commit.
    Thanks

  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    I think this I 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 :)

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    Changing the state.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    Changed the status to NW per @larowlan's feedback. Please change it back to NR if the changes have been made.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    @ckrina

    Changes have already been made yesterday https://www.drupal.org/project/navigation/issues/3408260#mr149-note242559 ๐Ÿ“Œ Print the real User account menu in the footer Needs review

    Thanks

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada m4olivei Grimsby, ON

    I'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 nameing and strucutre of the theme hook (menu_region__footer) as close to what it already is as possible.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    @m4olivei, appreciate your review. I've taken care of all the comments you provided. Updating the issue status to NR once more. Thanks.

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada m4olivei Grimsby, ON

    Looks 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.

  • Status changed to Fixed about 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    Thank 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) :)

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    @ckrina Sure, we will do that.

    Thank you.

  • Status changed to Fixed 12 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Success
    11 months ago
    Total: 948s
    #77525
  • Pipeline finished with Failed
    11 months ago
    Total: 1056s
    #77553
  • Pipeline finished with Success
    10 months ago
    Total: 263s
    #113724
  • Pipeline finished with Success
    10 months ago
    Total: 109s
    #113727
  • Pipeline finished with Success
    10 months ago
    Total: 35s
    #113730
  • Pipeline finished with Success
    10 months ago
    Total: 33s
    #113731
  • Pipeline finished with Success
    9 months ago
    Total: 137s
    #121957
  • Pipeline finished with Success
    9 months ago
    Total: 256s
    #122793
  • Pipeline finished with Success
    9 months ago
    Total: 168s
    #124579
  • Pipeline finished with Success
    9 months ago
    Total: 168s
    #131070
Production build 0.71.5 2024