[PR #2848] [CLOSED] Closes #2638: Copy Button for Secrets #12449

Closed
opened 2025-12-29 22:21:38 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/2848
Author: @hSaria
Created: 2/3/2019
Status: Closed

Base: developHead: develop


📝 Commits (3)

  • acd5bcd Added clipboard.min.js
  • a04e116 Added copy button to secrets
  • 04650f7 Added InfiniBand interface form factor

📊 Changes

6 files changed (+44 additions, -2 deletions)

View changed files

📝 netbox/dcim/constants.py (+24 -0)
netbox/project-static/js/clipboard.min.js (+7 -0)
📝 netbox/project-static/js/secrets.js (+4 -0)
📝 netbox/templates/_base.html (+1 -0)
📝 netbox/templates/secrets/inc/secret_tr.html (+3 -0)
📝 netbox/templates/secrets/secret.html (+5 -2)

📄 Description

Fixes: #2638

Added a copy button after unlocking secret.

As mentioned in #2638, the clipboard cannot be modified while running an asynchronous operation (like AJAX call) since the user-triggered event would have been processed before the response is received.
There are hacky solutions, but I'd rather keep things simple. There is a draft API that addresses this challenge, but its support is not wide enough, yet.

Note: I have purposefully avoided adding the copy button to the secret_edit.html page as I see it as unnecessary (you wouldn't normally go to edit to unlock then copy the secret). However, if you'd like it there for consistency, you can copy the button from secret.html (that's the only change needed).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/2848 **Author:** [@hSaria](https://github.com/hSaria) **Created:** 2/3/2019 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `develop` --- ### 📝 Commits (3) - [`acd5bcd`](https://github.com/netbox-community/netbox/commit/acd5bcd99be13e90beaad19f33a364cca6bc492f) Added clipboard.min.js - [`a04e116`](https://github.com/netbox-community/netbox/commit/a04e116f7935fe1eb6785cda24c656b382ba3118) Added copy button to secrets - [`04650f7`](https://github.com/netbox-community/netbox/commit/04650f728f147aee60f7b9a0a93b903751442b7f) Added InfiniBand interface form factor ### 📊 Changes **6 files changed** (+44 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/constants.py` (+24 -0) ➕ `netbox/project-static/js/clipboard.min.js` (+7 -0) 📝 `netbox/project-static/js/secrets.js` (+4 -0) 📝 `netbox/templates/_base.html` (+1 -0) 📝 `netbox/templates/secrets/inc/secret_tr.html` (+3 -0) 📝 `netbox/templates/secrets/secret.html` (+5 -2) </details> ### 📄 Description ### Fixes: #2638 Added a copy button after unlocking secret. As mentioned in #2638, the clipboard cannot be modified while running an asynchronous operation (like AJAX call) since the user-triggered event would have been processed before the response is received. There are hacky solutions, but I'd rather keep things simple. There is a [draft API](https://www.w3.org/TR/clipboard-apis/) that addresses this challenge, but its support is not [wide enough](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText), yet. Note: I have purposefully avoided adding the copy button to the secret_edit.html page as I see it as unnecessary (you wouldn't normally go to edit to unlock then copy the secret). However, if you'd like it there for consistency, you can copy the button from secret.html (that's the only change needed). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:21:38 +01:00
adam closed this issue 2025-12-29 22:21:38 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12449