Fix extension-provided navbar entries in the mobile menu.

Review Request #14154 — Created Sept. 10, 2024 and submitted

Information

Review Board
release-7.x

Reviewers

We render navbar entries in two places: the topbar (just under the
"Review Board" label) and the mobile menu. In the mobile menu, the
navbar entries should be rendered using the sidebar layout/classes,
rather than the topbar ones. Unfortunately, extension-provided navbar
entries would only render using the topbar layout, which made them look
very ugly in the mobile menu.

This change adds an optional argument to the templatetag we use to
render the navbar items, which lets us choose a template to use.

  • Ran unit tests.
  • Looked and saw that the "Reports" entry added by Power Pack no longer
    looked terrible in the mobile menu.
Summary ID
Fix extension-provided navbar entries in the mobile menu.
We render navbar entries in two places: the topbar (just under the "Review Board" label) and the mobile menu. In the mobile menu, the navbar entries should be rendered using the sidebar layout/classes, rather than the topbar ones. Unfortunately, extension-provided navbar entries would only render using the topbar layout, which made them look very ugly in the mobile menu. This change adds an optional argument to the templatetag we use to render the navbar items, which lets us choose a template to use. Testing Done: - Ran unit tests. - Looked and saw that the "Reports" entry added by Power Pack no longer looked terrible in the mobile menu.
1643609b199c24510f49d0771b2b24eb1e531584
Description From Last Updated

Can we make this keyword-only?

chipx86chipx86

Let's compute this only once outside the loop.

chipx86chipx86

nit: How do you feel about settinng the default first, and changing only if sidebar is defined? template_name = "extensions/navbar_entry.html" …

OfficeStaplerOfficeStapler
OfficeStapler
  1. 
      
  2. Show all issues

    nit: How do you feel about settinng the default first, and changing only if sidebar is defined?

    template_name = "extensions/navbar_entry.html"
    if sidebar:
        template_name = "..."
    
    1. Thanks for chiming in, always happy to have more eyes on our code!

      It's a line shorter, but I don't know that it's any cleaner (and with our coding style we'd put a blank line before the if anyway). My general preference in these situations is to have the assignments be at the same level of indentation so it's visually clear that it's one-or-the-other.

  3. 
      
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. Show all issues

    Can we make this keyword-only?

  3. reviewboard/extensions/templatetags/rb_extensions.py (Diff revision 1)
     
     
     
     
     
    Show all issues

    Let's compute this only once outside the loop.

  4. 
      
david
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.x (aa4a450)