From d08a13906c79a14a29e860083383fa958470de37 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Thu, 9 Jan 2025 22:36:54 +0100 Subject: [PATCH] [JENKINS-74832] disable copybutton in insecure context Copying to clipboard only works in a secure context (https). So instead of only showing that it doesn't work after pressing the button, the button is now disabled and a corresponding tooltip is shown. --- .../main/resources/lib/layout/copyButton.jelly | 10 ++++++---- .../lib/layout/copyButton/copyButton.js | 17 ++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/src/main/resources/lib/layout/copyButton.jelly b/core/src/main/resources/lib/layout/copyButton.jelly index 8a65c641657a..e5fabe0a6cf8 100644 --- a/core/src/main/resources/lib/layout/copyButton.jelly +++ b/core/src/main/resources/lib/layout/copyButton.jelly @@ -53,15 +53,17 @@ THE SOFTWARE. - + + ${attrs.label} + + diff --git a/core/src/main/resources/lib/layout/copyButton/copyButton.js b/core/src/main/resources/lib/layout/copyButton/copyButton.js index 2a9c7bfe56ff..813f5781d747 100644 --- a/core/src/main/resources/lib/layout/copyButton/copyButton.js +++ b/core/src/main/resources/lib/layout/copyButton/copyButton.js @@ -3,8 +3,8 @@ Behaviour.specify( "copyButton", 0, function (copyButton) { - copyButton.addEventListener("click", () => { - if (isSecureContext) { + if (isSecureContext) { + copyButton.addEventListener("click", () => { var text = copyButton.getAttribute("text"); if (copyButton.hasAttribute("ref")) { var ref = copyButton.getAttribute("ref"); @@ -27,12 +27,11 @@ Behaviour.specify( copyButton, ); }); - } else { - hoverNotification( - "Copy is only supported with a secure (HTTPS) connection", - copyButton, - ); - } - }); + }); + } else { + copyButton.disabled = true; + const parent = copyButton.parentElement; + parent.setAttribute("tooltip", parent.dataset.messageInsecure); + } }, );