Fixes #5046: Disabled plugin menu items are no longer clickable

This commit is contained in:
Jeremy Stretch 2020-09-04 14:13:35 -04:00
parent dd0185816c
commit 78d104e60c
3 changed files with 20 additions and 12 deletions

View File

@ -328,6 +328,9 @@ A `PluginMenuButton` has the following attributes:
* `color` - One of the choices provided by `ButtonColorChoices` (optional) * `color` - One of the choices provided by `ButtonColorChoices` (optional)
* `permissions` - A list of permissions required to display this button (optional) * `permissions` - A list of permissions required to display this button (optional)
!!! note
Any buttons associated within a menu item will be shown only if the user has permission to view the link, regardless of what permissions are set on the buttons.
## Extending Core Templates ## Extending Core Templates
Plugins can inject custom content into certain areas of the detail views of applicable models. This is accomplished by subclassing `PluginTemplateExtension`, designating a particular NetBox model, and defining the desired methods to render custom content. Four methods are available: Plugins can inject custom content into certain areas of the detail views of applicable models. This is accomplished by subclassing `PluginTemplateExtension`, designating a particular NetBox model, and defining the desired methods to render custom content. Four methods are available:

View File

@ -10,6 +10,7 @@
### Bug Fixes ### Bug Fixes
* [#5046](https://github.com/netbox-community/netbox/issues/5046) - Disabled plugin menu items are no longer clickable
* [#5063](https://github.com/netbox-community/netbox/issues/5063) - Fix "add device" link in rack elevations for opposite side of half-depth devices * [#5063](https://github.com/netbox-community/netbox/issues/5063) - Fix "add device" link in rack elevations for opposite side of half-depth devices
* [#5074](https://github.com/netbox-community/netbox/issues/5074) - Fix inclusion of VC member interfaces when viewing VC master * [#5074](https://github.com/netbox-community/netbox/issues/5074) - Fix inclusion of VC member interfaces when viewing VC master
* [#5078](https://github.com/netbox-community/netbox/issues/5078) - Fix assignment of existing IP addresses to interfaces via web UI * [#5078](https://github.com/netbox-community/netbox/issues/5078) - Fix assignment of existing IP addresses to interfaces via web UI

View File

@ -5,18 +5,22 @@
{% for section_name, menu_items in registry.plugin_menu_items.items %} {% for section_name, menu_items in registry.plugin_menu_items.items %}
<li class="dropdown-header">{{ section_name }}</li> <li class="dropdown-header">{{ section_name }}</li>
{% for menu_item in menu_items %} {% for menu_item in menu_items %}
<li{% if menu_item.permissions and not request.user|has_perms:menu_item.permissions %} class="disabled"{% endif %}> {% if not menu_item.permissions or request.user|has_perms:menu_item.permissions %}
{% if menu_item.buttons %} <li>
<div class="buttons pull-right"> {% if menu_item.buttons %}
{% for button in menu_item.buttons %} <div class="buttons pull-right">
{% if not button.permissions or request.user|has_perms:button.permissions %} {% for button in menu_item.buttons %}
<a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="{{ button.icon_class }}"></i></a> {% if not button.permissions or request.user|has_perms:button.permissions %}
{% endif %} <a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="{{ button.icon_class }}"></i></a>
{% endfor %} {% endif %}
</div> {% endfor %}
{% endif %} </div>
<a href="{% url menu_item.link %}">{{ menu_item.link_text }}</a> {% endif %}
</li> <a href="{% url menu_item.link %}">{{ menu_item.link_text }}</a>
</li>
{% else %}
<li class="disabled"><a href="#">{{ menu_item.link_text }}</a></li>
{% endif %}
{% endfor %} {% endfor %}
{% if not forloop.last %} {% if not forloop.last %}
<li class="divider"></li> <li class="divider"></li>