Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions netbox/extras/migrations/0116_custom_link_button_color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db import migrations, models


def update_link_buttons(apps, schema_editor):
CustomLink = apps.get_model('extras', 'CustomLink')
CustomLink.objects.filter(button_class='outline-dark').update(button_class='default')


class Migration(migrations.Migration):

dependencies = [
('extras', '0115_convert_dashboard_widgets'),
]

operations = [
migrations.AlterField(
model_name='customlink',
name='button_class',
field=models.CharField(default='default', max_length=30),
),
migrations.RunPython(
code=update_link_buttons,
reverse_code=migrations.RunPython.noop
),
]
4 changes: 3 additions & 1 deletion netbox/extras/templatetags/custom_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from core.models import ObjectType
from extras.models import CustomLink
from netbox.choices import ButtonColorChoices


register = template.Library()
Expand Down Expand Up @@ -59,10 +60,11 @@ def custom_links(context, obj):

# Add non-grouped links
else:
button_class = 'outline-secondary' if cl.button_class == ButtonColorChoices.DEFAULT else cl.button_class
try:
if rendered := cl.render(link_context):
template_code += LINK_BUTTON.format(
rendered['link'], rendered['link_target'], cl.button_class, rendered['text']
rendered['link'], rendered['link_target'], button_class, rendered['text']
)
except Exception as e:
template_code += f'<a class="btn btn-sm btn-outline-secondary" disabled="disabled" title="{e}">' \
Expand Down
5 changes: 1 addition & 4 deletions netbox/netbox/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ class ColorChoices(ChoiceSet):
#

class ButtonColorChoices(ChoiceSet):
"""
Map standard button color choices to Bootstrap 3 button classes
"""
DEFAULT = 'outline-dark'
DEFAULT = 'default'
BLUE = 'blue'
INDIGO = 'indigo'
PURPLE = 'purple'
Expand Down