Sfoglia il codice sorgente

Rename PluginNavMenuLink to PluginMenuItem

Jeremy Stretch 5 anni fa
parent
commit
40574b65af
2 ha cambiato i file con 8 aggiunte e 8 eliminazioni
  1. 4 4
      docs/plugins/development.md
  2. 4 4
      netbox/extras/plugins/__init__.py

+ 4 - 4
docs/plugins/development.md

@@ -281,14 +281,14 @@ With these three components in place, we can request `/api/plugins/animal-sounds
 
 
 ## Navigation Menu Items
 ## 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
 ```python
-from extras.plugins import PluginNavMenuButton, PluginNavMenuLink
+from extras.plugins import PluginNavMenuButton, PluginMenuItem
 from utilities.choices import ButtonColorChoices
 from utilities.choices import ButtonColorChoices
 
 
 menu_items = (
 menu_items = (
-    PluginNavMenuLink(
+    PluginMenuItem(
         link='plugins:netbox_animal_sounds:random_sound',
         link='plugins:netbox_animal_sounds:random_sound',
         link_text='Random sound',
         link_text='Random sound',
         buttons=(
         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` - The name of the URL path to which this menu item links
 * `link_text` - The text presented to the user
 * `link_text` - The text presented to the user

+ 4 - 4
netbox/extras/plugins/__init__.py

@@ -152,7 +152,7 @@ def register_template_content_classes(class_list):
 # Navigation menu links
 # 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
     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.
     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):
 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
     # Validation
     for menu_link in class_list:
     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:
         for button in menu_link.buttons:
             if not isinstance(button, PluginNavMenuButton):
             if not isinstance(button, PluginNavMenuButton):
                 raise TypeError(f"{button} must be an instance of extras.plugins.PluginNavMenuButton")
                 raise TypeError(f"{button} must be an instance of extras.plugins.PluginNavMenuButton")