mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
16238 map custom-link button colors to tabler
This commit is contained in:
parent
9065667ddf
commit
bb0a62c837
@ -715,8 +715,20 @@ class RackRoleBulkDeleteView(generic.BulkDeleteView):
|
||||
|
||||
@register_model_view(RackType, 'list', path='', detail=False)
|
||||
class RackTypeListView(generic.ObjectListView):
|
||||
queryset = RackType.objects.annotate(
|
||||
instance_count=count_related(Rack, 'rack_type')
|
||||
queryset = Rack.objects.prefetch_related(
|
||||
'reservations',
|
||||
'devices',
|
||||
'devices__device_type'
|
||||
'site',
|
||||
'location',
|
||||
'status',
|
||||
'tenant',
|
||||
'tenant__tenant_group',
|
||||
'role',
|
||||
'rack_type',
|
||||
'rack_type__manufacturer'
|
||||
).annotate(
|
||||
device_count=count_related(Device, 'rack'),
|
||||
)
|
||||
filterset = filtersets.RackTypeFilterSet
|
||||
filterset_form = forms.RackTypeFilterForm
|
||||
|
@ -3,7 +3,6 @@ from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from core.models import ObjectType
|
||||
from extras.choices import CustomLinkButtonClassChoices
|
||||
from extras.models import CustomLink
|
||||
from netbox.choices import ButtonColorChoices
|
||||
|
||||
@ -30,22 +29,6 @@ GROUP_BUTTON = """
|
||||
GROUP_LINK = '<li><a class="dropdown-item" href="{}"{}>{}</a></li>\n'
|
||||
|
||||
|
||||
def map_button_class(button_color):
|
||||
if button_color == ButtonColorChoices.DEFAULT:
|
||||
return 'outline-secondary'
|
||||
elif button_color == ButtonColorChoices.WHITE:
|
||||
return 'light'
|
||||
elif button_color == ButtonColorChoices.BLACK:
|
||||
return 'dark'
|
||||
elif button_color == ButtonColorChoices.GRAY or button_color == ButtonColorChoices.GREY:
|
||||
return 'secondary'
|
||||
elif button_color == CustomLinkButtonClassChoices.LINK:
|
||||
# note: using ghost-secondary as ghost-dark doesn't display in dark mode
|
||||
# with current tabler version.
|
||||
return 'ghost-secondary'
|
||||
return button_color
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def custom_links(context, obj):
|
||||
"""
|
||||
@ -81,7 +64,7 @@ def custom_links(context, obj):
|
||||
try:
|
||||
if rendered := cl.render(link_context):
|
||||
template_code += LINK_BUTTON.format(
|
||||
rendered['link'], rendered['link_target'], map_button_class(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}">' \
|
||||
@ -106,7 +89,7 @@ def custom_links(context, obj):
|
||||
|
||||
if links_rendered:
|
||||
template_code += GROUP_BUTTON.format(
|
||||
map_button_class(links[0].button_class), escape(group), ''.join(links_rendered)
|
||||
links[0].button_class, escape(group), ''.join(links_rendered)
|
||||
)
|
||||
|
||||
return mark_safe(template_code)
|
||||
|
BIN
netbox/project-static/dist/netbox.css
vendored
BIN
netbox/project-static/dist/netbox.css
vendored
Binary file not shown.
@ -63,3 +63,19 @@ span.color-label {
|
||||
.sso-icon {
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.btn-white {
|
||||
@extend .btn-light;
|
||||
}
|
||||
|
||||
.btn-black {
|
||||
@extend .btn-dark;
|
||||
}
|
||||
|
||||
.btn-grey {
|
||||
@extend .btn-secondary;
|
||||
}
|
||||
|
||||
.btn-gray {
|
||||
@extend .btn-secondary;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user