Skip to content

Commit

Permalink
Fixes #10984: Fix navigation menu expansion for plugin menus comprisi…
Browse files Browse the repository at this point in the history
…ng multiple words
  • Loading branch information
jeremystretch committed Nov 21, 2022
1 parent e494d7b commit 150cb77
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/version-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [#10973](https://github.com/netbox-community/netbox/issues/10973) - Fix device links in VDC table
* [#10980](https://github.com/netbox-community/netbox/issues/10980) - Fix view tabs for plugin objects
* [#10982](https://github.com/netbox-community/netbox/issues/10982) - Catch `NoReverseMatch` exception when rendering tabs with no registered URL
* [#10984](https://github.com/netbox-community/netbox/issues/10984) - Fix navigation menu expansion for plugin menus comprising multiple words

## v3.4-beta1 (2022-11-16)

Expand Down
4 changes: 4 additions & 0 deletions netbox/extras/plugins/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def __init__(self, label, groups, icon_class=None):
if icon_class is not None:
self.icon_class = icon_class

@property
def name(self):
return self.label.replace(' ', '_')


class PluginMenuItem:
"""
Expand Down
2 changes: 1 addition & 1 deletion netbox/extras/tests/dummy_plugin/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)

menu = PluginMenu(
label=_('Dummy'),
label=_('Dummy Plugin'),
groups=(('Group 1', items),),
)
menu_items = items
4 changes: 4 additions & 0 deletions netbox/netbox/navigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class Menu:
icon_class: str
groups: Sequence[MenuGroup]

@property
def name(self):
return self.label.replace(' ', '_')


#
# Utility functions
Expand Down
4 changes: 2 additions & 2 deletions netbox/utilities/templates/navigation/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
{% for menu, groups in nav_items %}
<li class="nav-item">
{# Menu heading #}
<a class="nav-link" href="#menu{{ menu.label }}" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="menu{{ menu.label }}">
<a class="nav-link" href="#menu{{ menu.name }}" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="menu{{ menu.name }}">
<i class="{{ menu.icon_class }}"></i>
<span class="nav-link-text">{{ menu.label }}</span>
</a>
{# Menu groups #}
<div class="collapse" id="menu{{ menu.label }}">
<div class="collapse" id="menu{{ menu.name }}">
<ul class="nav nav-sm flex-column">
{% for group, items in groups %}
{# Group heading #}
Expand Down

0 comments on commit 150cb77

Please sign in to comment.