mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
Clean up action buttons
This commit is contained in:
parent
87e910421c
commit
12958e9653
@ -8,8 +8,6 @@ Blocks:
|
|||||||
- content: Primary page content
|
- content: Primary page content
|
||||||
- table_controls: Control elements for the child objects table
|
- table_controls: Control elements for the child objects table
|
||||||
- bulk_controls: Bulk action buttons which appear beneath the child objects table
|
- bulk_controls: Bulk action buttons which appear beneath the child objects table
|
||||||
- bulk_edit_controls: Bulk edit buttons
|
|
||||||
- bulk_delete_controls: Bulk delete buttons
|
|
||||||
- bulk_extra_controls: Other bulk action buttons
|
- bulk_extra_controls: Other bulk action buttons
|
||||||
- modals: Any pre-loaded modals
|
- modals: Any pre-loaded modals
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% if url %}
|
<a href="{{ url }}" class="btn btn-primary" role="button">
|
||||||
{% load i18n %}
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {{ label }}
|
||||||
<a href="{{ url }}" type="button" class="btn btn-primary">
|
</a>
|
||||||
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% load i18n %}
|
<button type="submit" name="_delete" {% formaction %}="{{ url }}" class="btn btn-red">
|
||||||
{% if url %}
|
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {{ label }}
|
||||||
<button type="submit" name="_delete" {% formaction %}="{{ url }}" class="btn btn-red">
|
</button>
|
||||||
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete Selected" %}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% load i18n %}
|
<button type="submit" name="_disconnect" {% formaction %}="{{ url }}" class="btn btn-red">
|
||||||
{% if url %}
|
<i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i> {{ label }}
|
||||||
<button type="submit" name="_disconnect" {% formaction %}="{{ url }}" class="btn btn-red">
|
</button>
|
||||||
<i class="mdi mdi-ethernet-cable-off" aria-hidden="true"></i> {{ label }}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% load i18n %}
|
<button type="submit" name="_edit" {% formaction %}="{{ url }}" class="btn btn-yellow">
|
||||||
{% if url %}
|
<i class="mdi mdi-pencil" aria-hidden="true"></i> {{ label }}
|
||||||
<button type="submit" name="_edit" {% formaction %}="{{ url }}" class="btn btn-yellow">
|
</button>
|
||||||
<i class="mdi mdi-pencil" aria-hidden="true"></i> {% trans "Edit Selected" %}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% load i18n %}
|
<button type="submit" name="_rename" {% formaction %}="{{ url }}" class="btn btn-yellow">
|
||||||
{% if url %}
|
<i class="mdi mdi-pencil" aria-hidden="true"></i> {{ label }}
|
||||||
<button type="submit" name="_rename" {% formaction %}="{{ url }}" class="btn btn-yellow">
|
</button>
|
||||||
<i class="mdi mdi-pencil" aria-hidden="true"></i> {{ label }}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% load i18n %}
|
<button type="submit" name="_sync" {% formaction %}="{{ url }}" class="btn btn-primary">
|
||||||
{% if url %}
|
<i class="mdi mdi-sync" aria-hidden="true"></i> {{ label }}
|
||||||
<button type="submit" name="_sync" {% formaction %}="{{ url }}" class="btn btn-primary">
|
</button>
|
||||||
<i class="mdi mdi-sync" aria-hidden="true"></i> {{ label }}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{% load i18n %}
|
|
||||||
<a href="#"
|
<a href="#"
|
||||||
hx-get="{{ url }}"
|
hx-get="{{ url }}"
|
||||||
hx-target="#htmx-modal-content"
|
hx-target="#htmx-modal-content"
|
||||||
hx-swap="innerHTML"
|
hx-swap="innerHTML"
|
||||||
hx-select="form"
|
hx-select="form"
|
||||||
class="btn btn-red"
|
class="btn btn-red"
|
||||||
|
role="button"
|
||||||
data-bs-toggle="modal"
|
data-bs-toggle="modal"
|
||||||
data-bs-target="#htmx-modal"
|
data-bs-target="#htmx-modal"
|
||||||
>
|
>
|
||||||
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete" %}
|
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {{ label }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
{% load i18n %}
|
|
||||||
<a href="{{ url }}" class="btn btn-yellow" role="button">
|
<a href="{{ url }}" class="btn btn-yellow" role="button">
|
||||||
<i class="mdi mdi-pencil" aria-hidden="true"></i> {% trans "Edit" %}
|
<i class="mdi mdi-pencil" aria-hidden="true"></i> {{ label }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button type="button" class="btn btn-purple dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button type="button" class="btn btn-purple dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="mdi mdi-download"></i> {% trans "Export" %}
|
<i class="mdi mdi-download" aria-hidden="true"></i> {{ label }}
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
<li><a id="export_current_view" class="dropdown-item" href="?{% if url_params %}{{ url_params }}&{% endif %}export=table">{% trans "Current View" %}</a></li>
|
<li><a id="export_current_view" class="dropdown-item" href="?{% if url_params %}{{ url_params }}&{% endif %}export=table">{% trans "Current View" %}</a></li>
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
{% load i18n %}
|
<a href="{{ url }}" class="btn btn-cyan" role="button">
|
||||||
{% if url %}
|
<i class="mdi mdi-upload" aria-hidden="true"></i> {{ label }}
|
||||||
<a href="{{ url }}" type="button" class="btn btn-cyan">
|
</a>
|
||||||
<i class="mdi mdi-upload"></i> {% trans "Import" %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% load i18n %}
|
|
||||||
<form action="{{ url }}" method="post">
|
<form action="{{ url }}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<i class="mdi mdi-sync" aria-hidden="true"></i> {% trans "Sync" %}
|
<i class="mdi mdi-sync" aria-hidden="true"></i> {{ label }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -3,6 +3,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.urls import NoReverseMatch, reverse
|
from django.urls import NoReverseMatch, reverse
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from core.models import ObjectType
|
from core.models import ObjectType
|
||||||
from extras.models import Bookmark, ExportTemplate, Subscription
|
from extras.models import Bookmark, ExportTemplate, Subscription
|
||||||
@ -37,10 +38,6 @@ def action_buttons(context, actions, obj, multi=False):
|
|||||||
return mark_safe(''.join(buttons))
|
return mark_safe(''.join(buttons))
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Legacy object buttons
|
|
||||||
#
|
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/bookmark.html', takes_context=True)
|
@register.inclusion_tag('buttons/bookmark.html', takes_context=True)
|
||||||
def bookmark_button(context, instance):
|
def bookmark_button(context, instance):
|
||||||
# Check if this user has already bookmarked the object
|
# Check if this user has already bookmarked the object
|
||||||
@ -90,26 +87,6 @@ def clone_button(instance):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/edit.html')
|
|
||||||
def edit_button(instance):
|
|
||||||
viewname = get_viewname(instance, 'edit')
|
|
||||||
url = reverse(viewname, kwargs={'pk': instance.pk})
|
|
||||||
|
|
||||||
return {
|
|
||||||
'url': url,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/delete.html')
|
|
||||||
def delete_button(instance):
|
|
||||||
viewname = get_viewname(instance, 'delete')
|
|
||||||
url = reverse(viewname, kwargs={'pk': instance.pk})
|
|
||||||
|
|
||||||
return {
|
|
||||||
'url': url,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/subscribe.html', takes_context=True)
|
@register.inclusion_tag('buttons/subscribe.html', takes_context=True)
|
||||||
def subscribe_button(context, instance):
|
def subscribe_button(context, instance):
|
||||||
# Skip for objects which don't support notifications
|
# Skip for objects which don't support notifications
|
||||||
@ -145,12 +122,42 @@ def subscribe_button(context, instance):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legacy object buttons
|
||||||
|
#
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
|
@register.inclusion_tag('buttons/edit.html')
|
||||||
|
def edit_button(instance):
|
||||||
|
viewname = get_viewname(instance, 'edit')
|
||||||
|
url = reverse(viewname, kwargs={'pk': instance.pk})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'url': url,
|
||||||
|
'label': _('Edit'),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
|
@register.inclusion_tag('buttons/delete.html')
|
||||||
|
def delete_button(instance):
|
||||||
|
viewname = get_viewname(instance, 'delete')
|
||||||
|
url = reverse(viewname, kwargs={'pk': instance.pk})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'url': url,
|
||||||
|
'label': _('Delete'),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
@register.inclusion_tag('buttons/sync.html')
|
@register.inclusion_tag('buttons/sync.html')
|
||||||
def sync_button(instance):
|
def sync_button(instance):
|
||||||
viewname = get_viewname(instance, 'sync')
|
viewname = get_viewname(instance, 'sync')
|
||||||
url = reverse(viewname, kwargs={'pk': instance.pk})
|
url = reverse(viewname, kwargs={'pk': instance.pk})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'label': _('Sync'),
|
||||||
'url': url,
|
'url': url,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +166,7 @@ def sync_button(instance):
|
|||||||
# Legacy list buttons
|
# Legacy list buttons
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
@register.inclusion_tag('buttons/add.html')
|
@register.inclusion_tag('buttons/add.html')
|
||||||
def add_button(model, action='add'):
|
def add_button(model, action='add'):
|
||||||
try:
|
try:
|
||||||
@ -168,9 +176,11 @@ def add_button(model, action='add'):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'url': url,
|
'url': url,
|
||||||
|
'label': _('Add'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
@register.inclusion_tag('buttons/import.html')
|
@register.inclusion_tag('buttons/import.html')
|
||||||
def import_button(model, action='bulk_import'):
|
def import_button(model, action='bulk_import'):
|
||||||
try:
|
try:
|
||||||
@ -180,9 +190,11 @@ def import_button(model, action='bulk_import'):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'url': url,
|
'url': url,
|
||||||
|
'label': _('Import'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
@register.inclusion_tag('buttons/export.html', takes_context=True)
|
@register.inclusion_tag('buttons/export.html', takes_context=True)
|
||||||
def export_button(context, model):
|
def export_button(context, model):
|
||||||
object_type = ObjectType.objects.get_for_model(model)
|
object_type = ObjectType.objects.get_for_model(model)
|
||||||
@ -195,6 +207,7 @@ def export_button(context, model):
|
|||||||
export_templates = ExportTemplate.objects.restrict(user, 'view').filter(object_types=object_type)
|
export_templates = ExportTemplate.objects.restrict(user, 'view').filter(object_types=object_type)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'label': _('Export'),
|
||||||
'perms': context['perms'],
|
'perms': context['perms'],
|
||||||
'object_type': object_type,
|
'object_type': object_type,
|
||||||
'url_params': context['request'].GET.urlencode() if context['request'].GET else '',
|
'url_params': context['request'].GET.urlencode() if context['request'].GET else '',
|
||||||
@ -203,6 +216,7 @@ def export_button(context, model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
@register.inclusion_tag('buttons/bulk_edit.html', takes_context=True)
|
@register.inclusion_tag('buttons/bulk_edit.html', takes_context=True)
|
||||||
def bulk_edit_button(context, model, action='bulk_edit', query_params=None):
|
def bulk_edit_button(context, model, action='bulk_edit', query_params=None):
|
||||||
try:
|
try:
|
||||||
@ -213,11 +227,13 @@ def bulk_edit_button(context, model, action='bulk_edit', query_params=None):
|
|||||||
url = None
|
url = None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'htmx_navigation': context.get('htmx_navigation'),
|
'label': _('Edit Selected'),
|
||||||
'url': url,
|
'url': url,
|
||||||
|
'htmx_navigation': context.get('htmx_navigation'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove in NetBox v4.6
|
||||||
@register.inclusion_tag('buttons/bulk_delete.html', takes_context=True)
|
@register.inclusion_tag('buttons/bulk_delete.html', takes_context=True)
|
||||||
def bulk_delete_button(context, model, action='bulk_delete', query_params=None):
|
def bulk_delete_button(context, model, action='bulk_delete', query_params=None):
|
||||||
try:
|
try:
|
||||||
@ -228,6 +244,7 @@ def bulk_delete_button(context, model, action='bulk_delete', query_params=None):
|
|||||||
url = None
|
url = None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'htmx_navigation': context.get('htmx_navigation'),
|
'label': _('Delete Selected'),
|
||||||
'url': url,
|
'url': url,
|
||||||
|
'htmx_navigation': context.get('htmx_navigation'),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user