diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 7d16f9916..426302ea8 100644 Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index 1797f57ce..077c4bcc0 100644 Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ diff --git a/netbox/project-static/src/clipboard.ts b/netbox/project-static/src/clipboard.ts index 46ca5e36c..ddcb7b96e 100644 --- a/netbox/project-static/src/clipboard.ts +++ b/netbox/project-static/src/clipboard.ts @@ -2,7 +2,7 @@ import Clipboard from 'clipboard'; import { getElements } from './util'; export function initClipboard(): void { - for (const element of getElements('a.copy-content')) { + for (const element of getElements('.copy-content')) { new Clipboard(element); } } diff --git a/netbox/templates/account/token.html b/netbox/templates/account/token.html index d83e13ff5..57d1de3f4 100644 --- a/netbox/templates/account/token.html +++ b/netbox/templates/account/token.html @@ -15,11 +15,6 @@ {% block content %}
- {% if key and not settings.ALLOW_TOKEN_RETRIEVAL %} - - {% endif %}
{% trans "Token" %}
diff --git a/netbox/users/forms/model_forms.py b/netbox/users/forms/model_forms.py index 5fe84ad5f..1c3233f87 100644 --- a/netbox/users/forms/model_forms.py +++ b/netbox/users/forms/model_forms.py @@ -114,6 +114,9 @@ class UserTokenForm(BootstrapMixin, forms.ModelForm): help_text=_( 'Keys must be at least 40 characters in length. Be sure to record your key prior to ' 'submitting this form, as it may no longer be accessible once the token has been created.' + ), + widget=forms.TextInput( + attrs={'data-clipboard': 'true'} ) ) allowed_ips = SimpleArrayField( diff --git a/netbox/utilities/templates/form_helpers/render_field.html b/netbox/utilities/templates/form_helpers/render_field.html index 379dcc021..e5a564a3d 100644 --- a/netbox/utilities/templates/form_helpers/render_field.html +++ b/netbox/utilities/templates/form_helpers/render_field.html @@ -29,6 +29,14 @@ {{ label }}
+ {# Include a copy-to-clipboard button #} + {% elif 'data-clipboard' in field.field.widget.attrs %} +
+ {{ field }} + +
{# Default field rendering #} {% else %} {{ field }}