Create an administration UI for managing Navigation Blocks

Created on 27 December 2023, 6 months ago
Updated 26 January 2024, 5 months ago

Problem/Motivation

In šŸ“Œ Convert navigation sections to blocks and use the menu system Active we created a new Navigation Section (renamed here to 'Navigation Block') plugin type as a new concept to encompass things that go into the Navigation toolbar. Navigation Block plugins are block-like, inheriting much of the same behavior of blocks. They are a unique concept as a way of distinguishing and not inheriting everything that is a block today.

We need the ability for site administrators to manage the Navigation Block plugins that live in their navigation toolbar in the same way they would manage what blocks live in the defined regions of their site.

Proposed resolution

In no particular order, this would require, but no limited to the following:

  • New admin UI mimicing the Block layout UI (/admin/structure/block). Presently, we only need to allow administration over the 'content' area of the Navigation toolbar.
  • New config entity that mimics the block config entity
  • Default install the necessary config entities to keep the Navigation toolbar elements that we currently have

Remaining tasks

Manual testing. To test:

  1. Turn on the navigation module
  2. Navigate to Administration > Configuration > User interface > Navigation blocks
  3. Reorder navigation blocks
  4. Place a new navigation block
  5. Edit existing navigation block
  6. Remove navigation block
  7. Disable navigation block
  8. Enable navigation block
  9. Play with visibility conditions

Break it! Then report it.

Also needed:

User interface changes

A new Admin UI, like the Block layout UI, for managing Navigation Blocks.

Data model changes

New navigation_block config entity

šŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

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

Merge Requests

Comments & Activities

  • Issue created by @m4olivei
  • Assigned to m4olivei
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    I'll prototype this over the next few days.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON
  • šŸ‡®šŸ‡³India Prashant.c Dharamshala

    @m4olivei

    Awesome! Eagerly anticipating this; I hope to make a meaningful contribution here too. :)

    Appreciate it.

  • Merge request !156Resolve #3411099 "Create an administration" ā†’ (Merged) created by m4olivei
  • Status changed to Needs work 6 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    I got to a good stopping point, so I thought I would post the MR. It's not done yet, but many of the back end pieces are put in place here, including (not exhaustive):

    • New navigation_section config entity and supporting handlers
    • Aligned NavigationSection plugins to be more block-like, includeing NavigationSection attribute
    • Renamed plugin folder from Navigation to NavigationSetion to follow convention
    • Define config schema for navigation_section as well as existing navigation_section settings
    • Install 4 navigation_section config entities that we currently have
    • Use navigation_section config entities to render the navigation toolbar
    • Block-like navigation_section theme hook, preprocess and template

    Still to do:

    • navigation_section list_builder handler evaluation. Might not need this, came with drush generate
    • Flesh out the admin UI on top of all the data layer implementation. Keep an eye toward allowing a future for multi-region management, but we only need content region management for now
    • Make sure contextual region / menu stuff works as expected
    • Much testing

    Will keep working on these tomorrow.

  • šŸ‡®šŸ‡³India Prashant.c Dharamshala

    Could not find the link to open the entity page therefore added code for the following:
    1. Added the collection route for the entity
    2. Added links file



    Will keep testing.

    Thank you.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Thanks for testing @Prashant.c.

    As I noted in my previous comments, I'm still actively working on the issue. The default list builder came along with the drush generate command when I initially ran it to get a start on the config entity. We won't be using it, as we're going to create a UI like blocks (with "Place Navigation Section" buttons, dialogs, etc.).

    I'll note clearly in comments when I'm done with the initial work and at that time will unassign and invite further commits. It's good to avoid duplicate effort. Thanks!

  • šŸ‡®šŸ‡³India Prashant.c Dharamshala

    Thanks, @m4olivei! I didn't notice that you had already assigned it. Nevertheless, I'm looking forward to exploring the features, especially the "Place navigation section." Cheers!

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    More commits!

    I've fleshed out most of the back-end pieces for the Navigation section layout admin UI. You can now:

    • Visit /admin/structure/navigation-section and see a listing of existing navigation_section config entities. NOTE: we talked about limiting this to only the content region. It presently works with both regions, just to keep that possibility open. We can restrict that in future.
    • Reorder navigation sections, even move into differnt regions. NOTE: presently the Javascript is not active, so you have to use the region select form element to change to a different region.
    • Place navigation section brings up a dlalog with a library of navigation section plugins to choose from
    • You can create a new navigation section config entity by clicking "Place navigation section" in the library dialog. You get the navigation section plugin form, and warpping navigation section entity form, just like blocks

    Several caveats at this point:

    • Any functionality depending on Javascript, I haven't gone through yet. Filter mechanism on the navigation section libary dialog is one example.
    • Visibility settings don't get used yet
    • Rendering multiple of the same can produce weird results, there may be additional themeing considerations to accomodate the added flexibility here.
    • Not sure if exposing the 'Category' in the UI is useful? Probably worth it, who knows how this would get implemented, maybe many plugins would proliferate in contrib.

    I'm continuing to work through open issues.

  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    I'm at a good stopping point now. I'm going to unassign and set to Needs review.

    From #6, I've finished:

    • . I decided to keep content and footer region management. Good for testing, also, seems feasible that some users may prefer their shortcuts in the footer, which totally works.
    • . More needed!

    From #10, I've finished:

    Additional notes.

    From #10:

    Rendering multiple of the same can produce weird results, there may be additional themeing considerations to accomodate the added flexibility here.

    This is still true, but would be an issue for a followup ticket. It works now to do this. We can talk about theming considerations / restrictions in a followup.

    From #10:

    Not sure if exposing the 'Category' in the UI is useful? Probably worth it, who knows how this would get implemented, maybe many plugins would proliferate in contrib.

    I thought about this. Category will probably be useful. By default it comes from the module providing the NavigationSection plugin, hence they are all showing as "Navigation". I can imagine a future when this gets into core where the User NavigationSection goes into the user module, the Shortcuts NavigationSection goes into the shortcut module, etc. Plus contrib and it will be useful to have and display. I left it in.

    Any feedback on functionality or code review is very much welcome.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON
  • šŸ‡·šŸ‡øSerbia finnsky

    1. i don't really think that contextual links should be added. This is mostly admin menu. It is kind of annoying action for 99% of users who don't want to use anything except default navigation blocs layout.

    https://gyazo.com/47492d4feda61a3b2f8a54b4c39ad4d6

    2. I don't want jQuery appear in new core code.
    https://www.drupal.org/project/drupal/issues/3052002 šŸŒ± [meta] Replace JQuery with vanilla Javascript in core Active
    I would better rewrite it with vanilla js.
    Gonna work on it in next few days.

    3. Probably we need to have button "Reset to default" in navigation layout settings? I guess can be much more blocks in future. Unexperienced users easy can break all site controls.

  • Status changed to Needs work 6 months ago
  • šŸ‡®šŸ‡³India Prashant.c Dharamshala

    1. I concur that there should be a "Reset to Default" button available on /admin/structure/navigation-section for resetting the navigation section. This feature is essential in case users or admins inadvertently modify the settings and wish to revert to the default state. Currently, this option is unavailable, and having it would be a valuable addition.

    2. Despite updating the section title in the backend, the displayed title remains unchanged. Refer to the image below for clarification:

    3. There is an issue with the scrolling functionality when the "Administration" section is positioned in the footer. The navigation bar does not scroll due to an overlap problem, and no scrollbar appears. Please see the image below for a visual representation:

    Changing IS to NW.

    @m4olivei, excellent job!

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    1. i don't really think that contextual links should be added. This is mostly admin menu. It is kind of annoying action for 99% of users who don't want to use anything except default navigation blocs layout.

    I tend to agree with you. When @ckrina and I originally discussed this, we said lets include contextual links, but yeah... now that I see it, it's problematic. Let's see what @ckrina thinks when she has a minute to review. I'm leaning towards excluding contextual links, or at least hiding it here for now and addressing the UX in a follow up in order to be able to include them.

    2. I don't want jQuery appear in new core code. https://www.drupal.org/project/drupal/issues/3052002 šŸŒ± [meta] Replace JQuery with vanilla Javascript in core Active . I would better rewrite it with vanilla js.

    Yep! This Javascript was copy pasted from core's block code hence why jQuery came along for the ride. We can for sure rewrite to avoid jQuery.

    3. Probably we need to have button "Reset to default" in navigation layout settings? I guess can be much more blocks in future. Unexperienced users easy can break all site controls.

    Perhaps? Although I'd arguee for most users, they wouldn't venture into the admin UI to adjust anything here, especially if we remove contextual links. Not sure it's worth the effort.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    2. Despite updating the section title in the backend, the displayed title remains unchanged.

    Nice catch @Prashant.c. I've fixed that in the last commit.

    3. There is an issue with the scrolling functionality when the "Administration" section is positioned in the footer. The navigation bar does not scroll due to an overlap problem, and no scrollbar appears. Please see the image below for a visual representation.

    Yeah, there will be dragons when placing things outside their intended place. This is a front-end issue and outside the scope here. We can talk about restrictions we may or may not want to place here. Adjusting styles to cope with more flexible placement would be out of scope here and a good candidate for a follow up.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Updated issue summary with more remaining tasks based on discussion.

  • šŸ‡®šŸ‡³India Prashant.c Dharamshala

    1. The concern mentioned in Point 2 on https://www.drupal.org/project/navigation/issues/3411099#comment-15378332 šŸ“Œ Create an administration UI for managing Navigation Sections Needs work has been resolved.
    2. The remaining two points pertain to frontend issues.
    3. Should we consider treating the conversion of jQuery to JS as an independent task for the entire module?
    4. Currently, it seems that decisions regarding "Reset to default" and "Contextual links" are the only outstanding matters.

    Overall, looks good to me.

  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    Iā€™ve just manually tested it and itā€™s really cool seeing this working :D

    we talked about limiting this to only the content region. It presently works with both regions, just to keep that possibility open. We can restrict that in future.

    1. We should restrict this, yes. Either in here or in a follow-up, I donā€™t mind. The more important reason is the Usability problem it opens because a huge bottom region will the difficult to use in different breakpoints. Plus itā€™s supposed to be a ā€œcomplimentaryā€ and less important region with the main purpose to give the open/close functionality in desktop: this functionality disappears on mobile and the footer stays at the bottom with only the almost no used User menu.

    2. Location of the UI: it just go into Configuration not Structure. Itā€™s a UI to change of an administration UI, not the structure of the site being built. Iā€™d recomment movig this to Configuration > User Interface > Navigation sections.

    3. Contextual links. 100% agree with #13. But there should be a quick way to get to the UI to manage this. Maybe a link or something like that. But Iā€™d leave that for a follow-up.

    Not sure if exposing the 'Category' in the UI is useful? Probably worth it, who knows how this would get implemented, maybe many plugins would proliferate in contrib.

    4. Agreed on keeping it. In the future maybe other kind of custom block could be available, like the bar Umami adds to say itā€™s a testing site.

    Probably we need to have button "Reset to default" in navigation layout settings? I guess can be much more blocks in future. Unexperienced users easy can break all site controls.

    5. From #13. Iā€™m not sure about this being a need: this pattern doesnā€™t exist on the Block Layout UI nor in the menus themselves, and showing a button for that you should clearly explain what will change to, what is in the defaults first. Plus it can actually be a disruptive change for whoever click in there. Iā€™d say this lays into the responsibility of whoever has given the permission to a user?
    ā€ØWhat about trying to solve this potential stressing situation for newbies with proper module documentation in Drupal.org and maybe linking it with something like ā€œSee the recommended defaultsā€?ā€Ø Either way Iā€™d move this to a follow-up too.

    Should we consider treating the conversion of jQuery to JS as an independent task for the entire module?

    6. ā€ØFrom #18.3. ā€ØIt would be great to not introduce any jQuery at all, but happy with it happening in a follow-up.

    7. Why is it called ā€œNavigation sectionā€ and not ā€œNavigation blockā€? I find it confusing since I expect a region as a place to put several blocks if we rely in "Drupal terminology".

    8. If you leave the Footer region without menus you loose the capacity to collapse the sidebar because the Collapse button disappears.

  • šŸ‡·šŸ‡øSerbia finnsky

    Probably it can be one contextual link in top of sidebar? in logo region.

  • Assigned to m4olivei
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Great feedback. I will work on these items this morning.

  • Issue was unassigned.
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    We met this morning to discuss the remaining items here. In summary:

    We will create follow up issues for the following:

    • I've hidden the contextual links. In a follow up, we will work on a single contextual link for the whole Navigation to link to the Navigation section UI
    • Restrict configuration of the toolbar footer items. Users should only be allowed too manage the content region of the navigation through the UI.
    • The help link, which has already been taken out of main nav, and is in footer of Navigation now, will be made its own item to be able to reorder it
    • Revert to default in navigation layout settings from the UI
    • Refactor jQuery to vanilla Javascript

    Work to do in this issue

    • . Done in 9c93a9f7.
    • Rename ā€˜navigation sectionsā€™. Consensus amongst those in the meeting was 'Navigation components'. @ckrina to solicit some buy in on this, as the change is tedious to make. It's a machine name that gets used in the code a lot.
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON
  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    Rename ā€˜navigation sectionsā€™. Consensus amongst those in the meeting was 'Navigation components'. @ckrina to solicit some buy in on this, as the change is tedious to make. It's a machine name that gets used in the code a lot.

    We discussed this with @lauriii: he suggested that we better go with "Navigation block" instead of components because he foresees conflicts and misconceptions with the components word the way it is used in Drupal. So let's go with Navigation blocks" and unblock this issue :)

  • Status changed to Needs review 6 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Made changes to issue title and description to reflect new "Navigation Block" language.

    I've made the change to rename "Navigation Section" to "Navigation Block" in the code. Ready for review.

  • Assigned to m4olivei
  • Status changed to Needs work 6 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Thanks @plopesc! I'll get to work on those straight away.

  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Fixes made! Please review.

    Also see my comment in the one open thread. Let me know if your OK with that.

    Thanks @plopesc!

  • šŸ‡ŖšŸ‡øSpain plopesc Valladolid

    Thank you for taking your time to address the feedback! Code looks good to me, also played with the TB environment and I didn't found any remarkable issue.
    Only open point would be the automated tests, but I don't know how you plan to address them.

  • Status changed to RTBC 6 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Thanks @plopesc!

    I think with both @plopesc and @Prashant.c's reviews and all threads resolved, this is good to go.

    Marking as RTBC.

  • Status changed to Fixed 6 months ago
  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    Merged. Great work!! šŸ™ŒšŸ¼

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

  • Pipeline finished with Success
    3 months ago
    Total: 314s
    #118925
  • Pipeline finished with Success
    3 months ago
    #118942
  • Pipeline finished with Success
    3 months ago
    Total: 61s
    #118947
  • Pipeline finished with Success
    3 months ago
    Total: 83s
    #125976
  • Pipeline finished with Success
    3 months ago
    Total: 263s
    #125981
  • Pipeline finished with Success
    3 months ago
    Total: 56s
    #138372
  • Pipeline finished with Success
    3 months ago
    Total: 2170s
    #138374
  • Pipeline finished with Success
    3 months ago
    Total: 55s
    #138512
  • Pipeline finished with Success
    3 months ago
    Total: 55s
    #138535
  • Pipeline finished with Success
    3 months ago
    Total: 52s
    #138764
  • Pipeline finished with Success
    3 months ago
    Total: 54s
    #140707
  • Pipeline finished with Success
    about 2 months ago
    Total: 168s
    #165213
  • Pipeline finished with Success
    about 2 months ago
    Total: 138s
    #166019
  • Pipeline finished with Canceled
    25 days ago
    Total: 27s
    #188116
  • Pipeline finished with Canceled
    25 days ago
    Total: 131s
    #188117
  • Pipeline finished with Canceled
    25 days ago
    Total: 170s
    #188118
  • Pipeline finished with Failed
    25 days ago
    Total: 1069s
    #188122
  • Pipeline finished with Failed
    25 days ago
    Total: 958s
    #188148
Production build 0.69.0 2024