mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 15:56:15 +01:00
Adds button to copy API access key to clipboard.
Patch by Mizuki ISHIKAWA (user:ishikawa999). git-svn-id: https://svn.redmine.org/redmine/trunk@23991 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
22
app/javascript/controllers/api_key_copy_controller.js
Normal file
22
app/javascript/controllers/api_key_copy_controller.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["apiKey"];
|
||||
|
||||
copy(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const apiKeyText = this.apiKeyTarget.textContent?.trim();
|
||||
if (!apiKeyText) return;
|
||||
|
||||
const svgIcon = event.target.closest('.copy-api-key-link').querySelector('svg')
|
||||
if (!svgIcon) return;
|
||||
|
||||
copyToClipboard(apiKeyText).then(() => {
|
||||
updateSVGIcon(svgIcon, 'checked');
|
||||
setTimeout(() => {
|
||||
updateSVGIcon(svgIcon, 'copy');
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user