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:
Marius Balteanu
2025-09-20 07:41:50 +00:00
parent 7c2d967bb1
commit d39ff6e666
5 changed files with 101 additions and 12 deletions

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