From 559bc710cd2e986813dc349ae955fa52829aeafa Mon Sep 17 00:00:00 2001 From: Shlomo Dahan <64103471+shlomomdahan@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:20:41 -0400 Subject: [PATCH] [JENKINS-73875] CSP compatibility for `NewNodeConsoleNote` (#477) Co-authored-by: Basil Crow --- .../workflow/job/console/NewNodeConsoleNote/script.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/resources/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote/script.js b/src/main/resources/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote/script.js index e489c429..19bbf5b4 100644 --- a/src/main/resources/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote/script.js +++ b/src/main/resources/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote/script.js @@ -14,7 +14,13 @@ Behaviour.specify("span.pipeline-new-node", 'NewNodeConsoleNote', 0, function(e) var nodeId = e.getAttribute('nodeId') var startId = e.getAttribute('startId') if (startId == null || startId == nodeId) { - e.innerHTML = e.innerHTML.replace(/.+/, '$& (hide)') + e.innerHTML = e.innerHTML.replace(/.+/, '$& (hide)') + const toggles = e.querySelectorAll('.pipeline-show-hide .pipeline-toggle'); + const toggle = toggles[toggles.length - 1]; + toggle.addEventListener('click', (event) => { + event.preventDefault(); + showHidePipelineSection(toggle); + }); // TODO automatically hide second and subsequent branches: namely, in case a node has the same parent as an earlier one } // The CSS rule for branch names only needs to be added once per node, so we