Customizing the navigation pane
You can customize the Site Planner menus by adding a variable named
menu_extensions
to the navigation.py file for your plug-in.
The contents of the navigation pane are defined in the navigation.py
file.
Adding menus to the navigation pane
To add a menu to the navigation pane, add a PluginMenu
item in a
menu_extensions
variable to the plug-in's navigation.py file.
The following example adds an Applications menu
that contains an Applications group,
Applications item, and a green
Add button.
from extras.plugins import PluginMenu, PluginMenuGroup, PluginMenuButton, PluginMenuItem
from utilities.choices import ButtonColorChoices
menu_extensions = [
PluginMenu(
label='Applications',
icon_class='mdi mdi-window-maximize',
groups=[
PluginMenuGroup(
label='Applications',
items=[
PluginMenuItem(
link='plugins:netbox_applications:application_list',
link_text='Applications',
permissions=['netbox_applications.view_application'],
buttons=(
PluginMenuButton(
link='plugins:netbox_applications:application_add',
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_applications.add_virtualinfrastructure'],
color=ButtonColorChoices.GREEN
),
)
)
]
)
]
),
]
Adding groups to menus
To add a group to a menu in the navigation pane, add a PlacedPluginMenuGroup
item in a menu_extensions
variable to the plug-in's
navigation.py file. The following example adds an
Applications group with an
Applications item, and a green
Add button to the
Virtualization menu.
from extras.plugins import PlacedPluginMenuGroup, PluginMenuItem, PluginMenuButton
from utilities.choices import ButtonColorChoices
menu_extensions = [
PlacedPluginMenuGroup(
parent_label='Virtualization', # The label used on the menu we want to place this group in
label='Applications',
items=[
PluginMenuItem(
link='plugins:netbox_applications:application_list',
link_text='Applications',
permissions=['netbox_applications.view_application'],
buttons=(
PluginMenuButton(
link='plugins:netbox_applications:application_add',
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_applications.add_virtualinfrastructure'],
color=ButtonColorChoices.GREEN
),
)
)
]
),
]
Adding menu items to menus and groups
To add a menu item to the menus and groups in the navigation pane, add a
PlacedPluginMenuItem
item in a menu_extensions
variable to the
plug-in's navigation.py file. The following example adds an
Applications item with a green
Add button to the Virtual
Machines group under
Virtualization menu.
from extras.plugins import PlacedPluginMenuGroup, PluginMenuItem, PluginMenuButton
from utilities.choices import ButtonColorChoices
menu_extensions = [
PlacedPluginMenuItem(
parent_label='Virtualization.Virtual Machines', # Label of the menu and label of the group within that menu (separated by "." (dot) character)
link='plugins:netbox_applications:application_list',
link_text='Applications',
permissions=['netbox_applications.view_application'],
buttons=(
PluginMenuButton(
link='plugins:netbox_applications:application_add',
title='Add',
icon_class='mdi mdi-plus-thick',
permissions=['netbox_applications.add_virtualinfrastructure'],
color=ButtonColorChoices.GREEN
),
)
),
]