Skip to content

Commit 0157ac6

Browse files
17186 change custom link button color from outline-dark to outline-se… (#17248)
* 17186 change custom link button color from outline-dark to outline-secondary * 17186 change choice to default * 17186 change choice to default * 17186 change choice to default * Misc cleanup --------- Co-authored-by: Jeremy Stretch <[email protected]>
1 parent d23b937 commit 0157ac6

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from django.db import migrations, models
2+
3+
4+
def update_link_buttons(apps, schema_editor):
5+
CustomLink = apps.get_model('extras', 'CustomLink')
6+
CustomLink.objects.filter(button_class='outline-dark').update(button_class='default')
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('extras', '0115_convert_dashboard_widgets'),
13+
]
14+
15+
operations = [
16+
migrations.AlterField(
17+
model_name='customlink',
18+
name='button_class',
19+
field=models.CharField(default='default', max_length=30),
20+
),
21+
migrations.RunPython(
22+
code=update_link_buttons,
23+
reverse_code=migrations.RunPython.noop
24+
),
25+
]

netbox/extras/templatetags/custom_links.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from core.models import ObjectType
66
from extras.models import CustomLink
7+
from netbox.choices import ButtonColorChoices
78

89

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

6061
# Add non-grouped links
6162
else:
63+
button_class = 'outline-secondary' if cl.button_class == ButtonColorChoices.DEFAULT else cl.button_class
6264
try:
6365
if rendered := cl.render(link_context):
6466
template_code += LINK_BUTTON.format(
65-
rendered['link'], rendered['link_target'], cl.button_class, rendered['text']
67+
rendered['link'], rendered['link_target'], button_class, rendered['text']
6668
)
6769
except Exception as e:
6870
template_code += f'<a class="btn btn-sm btn-outline-secondary" disabled="disabled" title="{e}">' \

netbox/netbox/choices.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ class ColorChoices(ChoiceSet):
8181
#
8282

8383
class ButtonColorChoices(ChoiceSet):
84-
"""
85-
Map standard button color choices to Bootstrap 3 button classes
86-
"""
87-
DEFAULT = 'outline-dark'
84+
DEFAULT = 'default'
8885
BLUE = 'blue'
8986
INDIGO = 'indigo'
9087
PURPLE = 'purple'

0 commit comments

Comments
 (0)