Rename PluginNavMenuLink to PluginMenuItem

This commit is contained in:
Jeremy Stretch 2020-03-26 11:29:05 -04:00
parent 81c9177c09
commit 40574b65af
2 changed files with 8 additions and 8 deletions

View File

@ -281,14 +281,14 @@ With these three components in place, we can request `/api/plugins/animal-sounds
## Navigation Menu Items
To make its views easily accessible to users, a plugin can inject items in NetBox's navigation menu under the "Plugins" header. Menu items are added by defining a list of PluginNavMenuLink instances. By default, this should be a variable named `menu_items` in the file `navigation.py`. An example is shown below.
To make its views easily accessible to users, a plugin can inject items in NetBox's navigation menu under the "Plugins" header. Menu items are added by defining a list of PluginMenuItem instances. By default, this should be a variable named `menu_items` in the file `navigation.py`. An example is shown below.
```python
from extras.plugins import PluginNavMenuButton, PluginNavMenuLink
from extras.plugins import PluginNavMenuButton, PluginMenuItem
from utilities.choices import ButtonColorChoices
menu_items = (
PluginNavMenuLink(
PluginMenuItem(
link='plugins:netbox_animal_sounds:random_sound',
link_text='Random sound',
buttons=(
@ -299,7 +299,7 @@ menu_items = (
)
```
A `PluginNavMenuLink` has the following attributes:
A `PluginMenuItem` has the following attributes:
* `link` - The name of the URL path to which this menu item links
* `link_text` - The text presented to the user

View File

@ -152,7 +152,7 @@ def register_template_content_classes(class_list):
# Navigation menu links
#
class PluginNavMenuLink:
class PluginMenuItem:
"""
This class represents a nav menu item. This constitutes primary link and its text, but also allows for
specifying additional link buttons that appear to the right of the item in the van menu.
@ -189,12 +189,12 @@ class PluginNavMenuButton:
def register_menu_items(section_name, class_list):
"""
Register a list of PluginNavMenuLink instances for a given menu section (e.g. plugin name)
Register a list of PluginMenuItem instances for a given menu section (e.g. plugin name)
"""
# Validation
for menu_link in class_list:
if not isinstance(menu_link, PluginNavMenuLink):
raise TypeError(f"{menu_link} must be an instance of extras.plugins.PluginNavMenuLink")
if not isinstance(menu_link, PluginMenuItem):
raise TypeError(f"{menu_link} must be an instance of extras.plugins.PluginMenuItem")
for button in menu_link.buttons:
if not isinstance(button, PluginNavMenuButton):
raise TypeError(f"{button} must be an instance of extras.plugins.PluginNavMenuButton")