Files
Redmine/app/javascript/controllers/api_key_copy_controller.js
Marius Balteanu d39ff6e666 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
2025-09-20 07:41:50 +00:00

22 lines
552 B
JavaScript

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);
});
}
}