1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add a default button color

This commit is contained in:
Jeremy Stretch
2020-03-26 11:26:11 -04:00
parent 68ef5dd2a4
commit 81c9177c09
3 changed files with 10 additions and 4 deletions

View File

@ -311,8 +311,8 @@ A `PluginNavMenuButton` has the following attributes:
* `link` - The name of the URL path to which this button links * `link` - The name of the URL path to which this button links
* `title` - The tooltip text (displayed when the mouse hovers over the button) * `title` - The tooltip text (displayed when the mouse hovers over the button)
* `color` - Button color (one of the choices provided by `ButtonColorChoices`)
* `icon_class` - Button icon CSS class * `icon_class` - Button icon CSS class
* `color` - One of the choices provided by `ButtonColorChoices` (optional)
* `permission` - The name of the permission required to display this button (optional) * `permission` - The name of the permission required to display this button (optional)
## Template Content ## Template Content

View File

@ -6,6 +6,7 @@ from django.template.loader import get_template
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
from extras.registry import registry from extras.registry import registry
from utilities.choices import ButtonColorChoices
# Initialize plugin registry stores # Initialize plugin registry stores
@ -174,13 +175,17 @@ class PluginNavMenuButton:
This class represents a button which is a part of the nav menu link item. This class represents a button which is a part of the nav menu link item.
Note that button colors should come from ButtonColorChoices Note that button colors should come from ButtonColorChoices
""" """
def __init__(self, link, title, icon_class, color, permission=None): color = ButtonColorChoices.DEFAULT
def __init__(self, link, title, icon_class, color=None, permission=None):
self.link = link self.link = link
self.title = title self.title = title
self.icon_class = icon_class self.icon_class = icon_class
self.color = color
self.permission = permission self.permission = permission
if color is not None:
self.color = color
def register_menu_items(section_name, class_list): def register_menu_items(section_name, class_list):
""" """

View File

@ -88,7 +88,7 @@ class ButtonColorChoices(ChoiceSet):
""" """
Map standard button color choices to Bootstrap color classes Map standard button color choices to Bootstrap color classes
""" """
DEFAULT = 'default'
BLUE = 'primary' BLUE = 'primary'
GREY = 'secondary' GREY = 'secondary'
GREEN = 'success' GREEN = 'success'
@ -97,6 +97,7 @@ class ButtonColorChoices(ChoiceSet):
BLACK = 'dark' BLACK = 'dark'
CHOICES = ( CHOICES = (
(DEFAULT, 'Default'),
(BLUE, 'Blue'), (BLUE, 'Blue'),
(GREY, 'Grey'), (GREY, 'Grey'),
(GREEN, 'Green'), (GREEN, 'Green'),