Przeglądaj źródła

fix custom link rendering

checktheroads 4 lat temu
rodzic
commit
5e4878843e

+ 20 - 10
netbox/extras/templatetags/custom_links.py

@@ -10,14 +10,24 @@ from utilities.utils import render_jinja2
 
 register = template.Library()
 
-LINK_BUTTON = '<a href="{}"{} class="btn btn-sm btn-{}">{}</a>\n'
-GROUP_BUTTON = '<div class="btn-group">\n' \
-               '<button type="button" class="btn btn-sm btn-{} dropdown-toggle" data-toggle="dropdown">\n' \
-               '{} <span class="caret"></span>\n' \
-               '</button>\n' \
-               '<ul class="dropdown-menu pull-right">\n' \
-               '{}</ul></div>\n'
-GROUP_LINK = '<li><a href="{}"{}>{}</a></li>\n'
+LINK_BUTTON = '<a href="{}"{} class="btn btn-sm btn-{} m-1">{}</a>\n'
+
+GROUP_BUTTON = """
+<div class="dropdown m-1">
+    <button
+        class="btn btn-sm btn-{} dropdown-toggle"
+        type="button"
+        data-bs-toggle="dropdown"
+        aria-expanded="false">
+        {}
+    </button>
+    <ul class="dropdown-menu dropdown-menu-end">
+        {}
+    </ul>
+</div>
+"""
+
+GROUP_LINK = '<li><a class="dropdown-item" href="{}"{}>{}</a></li>\n'
 
 
 @register.simple_tag(takes_context=True)
@@ -60,7 +70,7 @@ def custom_links(context, obj):
                         link_rendered, link_target, cl.button_class, text_rendered
                     )
             except Exception as e:
-                template_code += '<a class="btn btn-sm btn-default" disabled="disabled" title="{}">' \
+                template_code += '<a class="btn btn-sm btn-outline-dark" disabled="disabled" title="{}">' \
                                  '<i class="mdi mdi-alert"></i> {}</a>\n'.format(e, cl.name)
 
     # Add grouped links to template
@@ -79,7 +89,7 @@ def custom_links(context, obj):
                     )
             except Exception as e:
                 links_rendered.append(
-                    '<li><a disabled="disabled" title="{}"><span class="text-muted">'
+                    '<li><a class="dropdown-item" disabled="disabled" title="{}"><span class="text-muted">'
                     '<i class="mdi mdi-alert"></i> {}</span></a></li>'.format(e, cl.name)
                 )
 

+ 0 - 1
netbox/templates/dcim/device/base.html

@@ -2,7 +2,6 @@
 {% load buttons %}
 {% load static %}
 {% load helpers %}
-{% load custom_links %}
 {% load plugins %}
 
 {% block breadcrumbs %}

+ 0 - 1
netbox/templates/dcim/device_component.html

@@ -1,7 +1,6 @@
 {% extends 'generic/object.html' %}
 {% load helpers %}
 {% load perms %}
-{% load custom_links %}
 {% load plugins %}
 
 {% block title %}{{ object.device }} / {{ object }}{% endblock %}

+ 0 - 1
netbox/templates/dcim/powerfeed.html

@@ -1,7 +1,6 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
 {% load static %}
-{% load custom_links %}
 {% load helpers %}
 {% load plugins %}
 

+ 0 - 1
netbox/templates/dcim/rackreservation.html

@@ -1,6 +1,5 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
-{% load custom_links %}
 {% load helpers %}
 {% load static %}
 {% load plugins %}

+ 0 - 1
netbox/templates/dcim/virtualchassis.html

@@ -1,6 +1,5 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
-{% load custom_links %}
 {% load helpers %}
 {% load plugins %}
 

+ 2 - 2
netbox/templates/generic/object.html

@@ -18,9 +18,10 @@
 {% endblock %}
 
 {% block controls %}
-{% plugin_buttons object %}
 <div class="controls mb-2 mx-0">
   <div class="d-flex flex-wrap justify-content-end">
+  {% custom_links object %}
+  {% plugin_buttons object %}
   {% block extra_controls %}{% endblock %}
   {% if request.user|can_add:object %}
     {% clone_button object %}
@@ -71,6 +72,5 @@
   </small>
   <span class="badge bg-primary">{{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}:{{ object.pk }}</span>
 </p>
-{% block tab_buttons %}{% custom_links object %}{% endblock %}
 {% endblock %}
 {% block components %}{% endblock %}

+ 0 - 1
netbox/templates/ipam/aggregate.html

@@ -1,6 +1,5 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
-{% load custom_links %}
 {% load helpers %}
 {% load plugins %}
 

+ 0 - 1
netbox/templates/ipam/prefix/base.html

@@ -1,7 +1,6 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
 {% load helpers %}
-{% load custom_links %}
 
 {% block breadcrumbs %}
   <li class="breadcrumb-item">

+ 0 - 1
netbox/templates/ipam/vrf.html

@@ -1,6 +1,5 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
-{% load custom_links %}
 {% load helpers %}
 {% load plugins %}
 

+ 0 - 1
netbox/templates/virtualization/cluster/base.html

@@ -1,7 +1,6 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
 {% load helpers %}
-{% load custom_links %}
 {% load plugins %}
 
 {% block breadcrumbs %}

+ 0 - 1
netbox/templates/virtualization/virtualmachine.html

@@ -1,6 +1,5 @@
 {% extends 'virtualization/virtualmachine/base.html' %}
 {% load buttons %}
-{% load custom_links %}
 {% load static %}
 {% load helpers %}
 {% load plugins %}

+ 0 - 1
netbox/templates/virtualization/virtualmachine/base.html

@@ -1,7 +1,6 @@
 {% extends 'generic/object.html' %}
 {% load buttons %}
 {% load helpers %}
-{% load custom_links %}
 {% load plugins %}
 
 {% block breadcrumbs %}