From 4d85e9ce340e2184e7da16bf15073852caaf3d74 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 18 Mar 2024 17:03:49 -0400 Subject: [PATCH] Enable HTMX navigation only when selected by user --- netbox/netbox/context_processors.py | 4 +++- netbox/templates/base/layout.html | 2 +- netbox/templates/dcim/component_list.html | 2 +- .../dcim/device/components_base.html | 6 ++---- .../templates/dcim/device/consoleports.html | 3 +-- .../dcim/device/consoleserverports.html | 3 +-- netbox/templates/dcim/device/frontports.html | 3 +-- netbox/templates/dcim/device/interfaces.html | 3 +-- .../templates/dcim/device/poweroutlets.html | 3 +-- netbox/templates/dcim/device/powerports.html | 3 +-- netbox/templates/dcim/device/rearports.html | 3 +-- netbox/templates/dcim/device_list.html | 20 +++++++++---------- .../dcim/devicetype/component_templates.html | 6 ++---- .../dcim/moduletype/component_templates.html | 6 +++--- netbox/templates/dcim/powerpanel.html | 6 +++--- .../templates/extras/configcontext_list.html | 2 +- .../templates/extras/configtemplate_list.html | 2 +- .../templates/extras/exporttemplate_list.html | 2 +- netbox/templates/generic/object_children.html | 6 ++---- .../virtualization/cluster/devices.html | 3 +-- .../virtualmachine/interfaces.html | 3 +-- .../virtualmachine/virtual_disks.html | 3 +-- .../virtualization/virtualmachine_list.html | 4 ++-- .../templates/buttons/bulk_delete.html | 2 +- .../templates/buttons/bulk_edit.html | 2 +- .../utilities/templates/navigation/menu.html | 2 +- .../utilities/templatetags/builtins/tags.py | 12 +++++++++++ 27 files changed, 57 insertions(+), 59 deletions(-) diff --git a/netbox/netbox/context_processors.py b/netbox/netbox/context_processors.py index 024ca85b5..ce4f8c45e 100644 --- a/netbox/netbox/context_processors.py +++ b/netbox/netbox/context_processors.py @@ -8,9 +8,11 @@ def settings_and_registry(request): """ Expose Django settings and NetBox registry stores in the template context. Example: {{ settings.DEBUG }} """ + user_preferences = request.user.config if request.user.is_authenticated else {} return { 'settings': django_settings, 'config': get_config(), 'registry': registry, - 'preferences': request.user.config if request.user.is_authenticated else {}, + 'preferences': user_preferences, + 'htmx_navigation': user_preferences.get('ui.htmx_navigation', False) == 'true' } diff --git a/netbox/templates/base/layout.html b/netbox/templates/base/layout.html index 943ec9dbf..e154254b5 100644 --- a/netbox/templates/base/layout.html +++ b/netbox/templates/base/layout.html @@ -79,7 +79,7 @@ Blocks: {# Page content #}
-
+
{# Page header #} {% block header %} diff --git a/netbox/templates/dcim/component_list.html b/netbox/templates/dcim/component_list.html index 089f161e7..3d261ea4d 100644 --- a/netbox/templates/dcim/component_list.html +++ b/netbox/templates/dcim/component_list.html @@ -10,7 +10,7 @@ {% endif %} {% if 'bulk_rename' in actions %} {% with bulk_rename_view=model|validated_viewname:"bulk_rename" %} - {% endwith %} diff --git a/netbox/templates/dcim/device/components_base.html b/netbox/templates/dcim/device/components_base.html index c6f68439b..47b0d7aab 100644 --- a/netbox/templates/dcim/device/components_base.html +++ b/netbox/templates/dcim/device/components_base.html @@ -5,8 +5,7 @@ {% with bulk_edit_view=child_model|validated_viewname:"bulk_edit" %} {% if 'bulk_edit' in actions and bulk_edit_view %} @@ -15,8 +14,7 @@ {% with bulk_rename_view=child_model|validated_viewname:"bulk_rename" %} {% if 'bulk_rename' in actions and bulk_rename_view %} diff --git a/netbox/templates/dcim/device/consoleports.html b/netbox/templates/dcim/device/consoleports.html index 41116fe84..d8de85868 100644 --- a/netbox/templates/dcim/device/consoleports.html +++ b/netbox/templates/dcim/device/consoleports.html @@ -7,8 +7,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device/consoleserverports.html b/netbox/templates/dcim/device/consoleserverports.html index 0284f950d..29efdb65b 100644 --- a/netbox/templates/dcim/device/consoleserverports.html +++ b/netbox/templates/dcim/device/consoleserverports.html @@ -7,8 +7,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device/frontports.html b/netbox/templates/dcim/device/frontports.html index 1132aea5e..4d7f14769 100644 --- a/netbox/templates/dcim/device/frontports.html +++ b/netbox/templates/dcim/device/frontports.html @@ -7,8 +7,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device/interfaces.html b/netbox/templates/dcim/device/interfaces.html index 5c47d944d..8d46d77ea 100644 --- a/netbox/templates/dcim/device/interfaces.html +++ b/netbox/templates/dcim/device/interfaces.html @@ -11,8 +11,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device/poweroutlets.html b/netbox/templates/dcim/device/poweroutlets.html index 5a9758964..66c765181 100644 --- a/netbox/templates/dcim/device/poweroutlets.html +++ b/netbox/templates/dcim/device/poweroutlets.html @@ -7,8 +7,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device/powerports.html b/netbox/templates/dcim/device/powerports.html index 669222b37..a299130a4 100644 --- a/netbox/templates/dcim/device/powerports.html +++ b/netbox/templates/dcim/device/powerports.html @@ -7,8 +7,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device/rearports.html b/netbox/templates/dcim/device/rearports.html index 8cf99ccd0..184e80d99 100644 --- a/netbox/templates/dcim/device/rearports.html +++ b/netbox/templates/dcim/device/rearports.html @@ -7,8 +7,7 @@ {% with bulk_disconnect_view=child_model|validated_viewname:"bulk_disconnect" %} {% if 'bulk_disconnect' in actions and bulk_disconnect_view %} diff --git a/netbox/templates/dcim/device_list.html b/netbox/templates/dcim/device_list.html index e8bf7b5a0..41ef8fc73 100644 --- a/netbox/templates/dcim/device_list.html +++ b/netbox/templates/dcim/device_list.html @@ -11,63 +11,63 @@