From 16aad96ae6c0763a50c95494472ef8d4858138d8 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 23 Oct 2024 15:52:27 -0400
Subject: [PATCH 01/23] fix: Update jQuery filter removal syntax for 3.x
compatibility
---
src/main/webapp/js/jquery.fancybox-1.3.4.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/webapp/js/jquery.fancybox-1.3.4.js b/src/main/webapp/js/jquery.fancybox-1.3.4.js
index 55c08ddb..b1667fcd 100644
--- a/src/main/webapp/js/jquery.fancybox-1.3.4.js
+++ b/src/main/webapp/js/jquery.fancybox-1.3.4.js
@@ -577,8 +577,8 @@
_finish = function () {
if (!$.support.opacity) {
- content.get(0).style.removeAttribute('filter');
- wrap.get(0).style.removeAttribute('filter');
+ content.css('filter', '');
+ wrap.css('filter', '');
}
if (selectedOpts.autoDimensions) {
From d74f1295bcc8df18bdbb57f85e6fba84f8738196 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 23 Oct 2024 16:23:26 -0400
Subject: [PATCH 02/23] address first csp issue:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L64
---
.../plugin/buildpipeline/BuildPipelineView/bpp.jelly | 1 +
.../BuildCardExtension/build-card-template-onclicks.js | 10 ++++++++++
.../BuildCardExtension/buildCardTemplate.jelly | 3 ++-
3 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index f349bfc8..546e01fb 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -12,6 +12,7 @@
+
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
new file mode 100644
index 00000000..53c8672b
--- /dev/null
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -0,0 +1,10 @@
+Behaviour.specify(".progress-console-onclick", 'progress-bar-click', 0, function (progressBarElement) {
+
+ const dataContainer = document.querySelector(".fill-dialog-data-container");
+ const href = dataContainer.dataset.fillDialogHref;
+ const title = dataContainer.dataset.fillDialogTitle;
+
+ progressBarElement.addEventListener('click', () => {
+ buildPipeline.fillDialog(href, title);
+ });
+});
\ No newline at end of file
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 9ccb95a2..1ac7e88b 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -61,7 +61,8 @@
{{#unless project.disabled}}
{{#if build.isBuilding}}
-
+
+
From 317e0fa572887a803a89820e629802fb974b0c5c Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 23 Oct 2024 16:26:05 -0400
Subject: [PATCH 03/23] address first csp issue:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L64
---
.../BuildCardExtension/build-card-template-onclicks.js | 2 +-
.../extension/BuildCardExtension/buildCardTemplate.jelly | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 53c8672b..7bcb8a4b 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -7,4 +7,4 @@ Behaviour.specify(".progress-console-onclick", 'progress-bar-click', 0, function
progressBarElement.addEventListener('click', () => {
buildPipeline.fillDialog(href, title);
});
-});
\ No newline at end of file
+});
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 1ac7e88b..417e3844 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -61,7 +61,7 @@
{{#unless project.disabled}}
{{#if build.isBuilding}}
-
+
From 913d01a13f6d9fa1e817818c336fb7e870ac5298 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 23 Oct 2024 16:54:15 -0400
Subject: [PATCH 04/23] line 97:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L97
---
.../build-card-template-onclicks.js | 13 ++++++++++++-
.../BuildCardExtension/buildCardTemplate.jelly | 5 +++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 7bcb8a4b..6d72ac68 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,6 +1,6 @@
Behaviour.specify(".progress-console-onclick", 'progress-bar-click', 0, function (progressBarElement) {
- const dataContainer = document.querySelector(".fill-dialog-data-container");
+ const dataContainer = document.querySelector(".fill-dialog-params-statusbar");
const href = dataContainer.dataset.fillDialogHref;
const title = dataContainer.dataset.fillDialogTitle;
@@ -8,3 +8,14 @@ Behaviour.specify(".progress-console-onclick", 'progress-bar-click', 0, function
buildPipeline.fillDialog(href, title);
});
});
+
+Behaviour.specify(".console-icon-onlick", 'console-icon-click', 0, function (consoleIconElement) {
+
+ const dataContainer = document.querySelector(".fill-dialog-params-console-output-icon");
+ const href = dataContainer.dataset.fillDialogHref;
+ const title = dataContainer.dataset.fillDialogTitle;
+
+ consoleIconElement.addEventListener('click', () => {
+ buildPipeline.fillDialog(href, title);
+ });
+});
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 417e3844..3b96b954 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -61,7 +61,7 @@
{{#unless project.disabled}}
{{#if build.isBuilding}}
-
+
@@ -95,7 +95,8 @@
-
+
+
From 31008b15489f09e2429733674786f553b1bc9bb7 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 15:50:57 -0400
Subject: [PATCH 05/23] fix:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L109
---
.../build-card-template-onclicks.js | 30 +++++++++++++++----
.../buildCardTemplate.jelly | 11 +++----
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 6d72ac68..1b1a8823 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,21 +1,39 @@
-Behaviour.specify(".progress-console-onclick", 'progress-bar-click', 0, function (progressBarElement) {
+Behaviour.specify(".bct-progress-console-onclick", 'BuildCardExtension_progressBarClick', 0, function (element) {
- const dataContainer = document.querySelector(".fill-dialog-params-statusbar");
+ const dataContainer = document.querySelector(".bct-progress-console-onclick-params");;
const href = dataContainer.dataset.fillDialogHref;
const title = dataContainer.dataset.fillDialogTitle;
- progressBarElement.addEventListener('click', () => {
+ element.addEventListener('click', () => {
buildPipeline.fillDialog(href, title);
});
});
-Behaviour.specify(".console-icon-onlick", 'console-icon-click', 0, function (consoleIconElement) {
+Behaviour.specify(".bct-console-icon-onclick", 'BuildCardExtension_consoleIconClick', 0, function (element) {
- const dataContainer = document.querySelector(".fill-dialog-params-console-output-icon");
+ const dataContainer = document.querySelector(".bct-console-icon-onclick-params");
const href = dataContainer.dataset.fillDialogHref;
const title = dataContainer.dataset.fillDialogTitle;
- consoleIconElement.addEventListener('click', () => {
+ element.addEventListener('click', () => {
buildPipeline.fillDialog(href, title);
});
});
+
+Behaviour.specify(".bct-rerun-success-icon-onclick", 'BuildCardExtension_successRerunClick', 0, function(element) {
+
+ const dataContainer = document.querySelector(".bct-rerun-success-icon-onclick-params");
+ const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
+ const buildExtId = dataContainer.dataset.rerunBuildExtId;
+ const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
+ .split(',')
+ .filter(Boolean)
+ .map(id => parseInt(id, 10));
+
+ element.addEventListener('click', () => {
+ buildPipeline.showSpinner(id);
+ buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+ });
+});
+
+
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 3b96b954..c484961f 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -61,8 +61,8 @@
{{#unless project.disabled}}
{{#if build.isBuilding}}
-
-
+
+
@@ -95,8 +95,8 @@
-
-
+
+
@@ -108,7 +108,8 @@
{{#if build.isSuccess}}
{{#if ${!it.triggerOnlyLatestJob}}}
-
+
+
From 85d08a32b988e08edd979cdc338ffdea6f627384 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 17:04:39 -0400
Subject: [PATCH 06/23]
fix:https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L118
---
.../build-card-template-onclicks.js | 16 ++++++++++++++++
.../BuildCardExtension/buildCardTemplate.jelly | 9 ++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 1b1a8823..a17ecb89 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -36,4 +36,20 @@ Behaviour.specify(".bct-rerun-success-icon-onclick", 'BuildCardExtension_success
});
});
+Behaviour.specify(".bct-rerun-latest-build-onclick", 'BuildCardExtension_latestRerunClick', 0, function(element) {
+
+ const dataContainer = document.querySelector(".bct-rerun-latest-build-onclick-params");
+ const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
+ const buildExtId = dataContainer.dataset.rerunBuildExtId;
+ const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
+ .split(',')
+ .filter(Boolean)
+ .map(id => parseInt(id, 10));
+
+ element.addEventListener('click', () => {
+ buildPipeline.showSpinner(id);
+ buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+ });
+});
+
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index c484961f..17cdf210 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -118,19 +118,26 @@
{{#if ${it.triggerOnlyLatestJob}}}
{{#if build.isLatestBuild}}
{{#if build.isUpstreamBuildLatest}}
-
+
+
+
+
+
+
{{/if}}
{{/if}}
{{else}}
{{#if build.isManual}}
+ Shlomo2
{{else}}
+ Shlomo3
{{/if}}
{{/if}}
From f5f7cc7b8f898e7a9fbb32d1f9de289907d244e8 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 17:05:07 -0400
Subject: [PATCH 07/23]
fix:https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L118
---
.../extension/BuildCardExtension/buildCardTemplate.jelly | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 17cdf210..538a74e6 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -122,10 +122,6 @@
-
-
-
-
{{/if}}
{{/if}}
{{else}}
From 2147df295726abf07a7c451e2076e4e14fdae113 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 21:30:52 -0400
Subject: [PATCH 08/23] fix:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L129
---
.../build-card-template-onclicks.js | 317 +++++++++++++++---
.../buildCardTemplate.jelly | 11 +-
2 files changed, 282 insertions(+), 46 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index a17ecb89..7def0a23 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,55 +1,288 @@
-Behaviour.specify(".bct-progress-console-onclick", 'BuildCardExtension_progressBarClick', 0, function (element) {
+// Store references to handlers to avoid duplicates
+let pipelineClickHandler = null;
+let consoleClickHandler = null;
+let progressClickHandler = null;
+let successRerunHandler = null;
+let latestRerunHandler = null;
- const dataContainer = document.querySelector(".bct-progress-console-onclick-params");;
- const href = dataContainer.dataset.fillDialogHref;
- const title = dataContainer.dataset.fillDialogTitle;
-
- element.addEventListener('click', () => {
- buildPipeline.fillDialog(href, title);
- });
+// Common utilities
+const parseDataAttributes = (container) => ({
+ id: parseInt(container.dataset.showSpinnerId, 10),
+ buildExtId: container.dataset.rerunBuildExtId,
+ dependencyIds: container.dataset.rerunBuildDependencyIds
+ .split(',')
+ .filter(Boolean)
+ .map(id => parseInt(id, 10))
});
-Behaviour.specify(".bct-console-icon-onclick", 'BuildCardExtension_consoleIconClick', 0, function (element) {
+// Dialog handlers
+const handleDialogClick = (dataContainer) => {
+ const { fillDialogHref: href, fillDialogTitle: title } = dataContainer.dataset;
+ buildPipeline.fillDialog(href, title);
+};
- const dataContainer = document.querySelector(".bct-console-icon-onclick-params");
- const href = dataContainer.dataset.fillDialogHref;
- const title = dataContainer.dataset.fillDialogTitle;
+// Rerun build handlers
+const handleRerunClick = (dataContainer) => {
+ const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
+ buildPipeline.showSpinner(id);
+ buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+};
- element.addEventListener('click', () => {
- buildPipeline.fillDialog(href, title);
- });
-});
+// Create delegated event handler
+const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, existingHandler) => {
+ const parentElement = document.querySelector(parentSelector);
+ if (!parentElement) {
+ console.warn(`Parent element not found: ${parentSelector}`);
+ return;
+ }
-Behaviour.specify(".bct-rerun-success-icon-onclick", 'BuildCardExtension_successRerunClick', 0, function(element) {
+ // Remove existing handler if it exists
+ if (existingHandler) {
+ parentElement.removeEventListener('click', existingHandler);
+ }
- const dataContainer = document.querySelector(".bct-rerun-success-icon-onclick-params");
- const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
- const buildExtId = dataContainer.dataset.rerunBuildExtId;
- const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
- .split(',')
- .filter(Boolean)
- .map(id => parseInt(id, 10));
+ // Create new handler
+ const newHandler = (event) => {
+ const clickTarget = event.target.closest(targetSelector);
+ if (!clickTarget) return;
- element.addEventListener('click', () => {
- buildPipeline.showSpinner(id);
- buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
- });
-});
+ // All data containers follow the pattern: selector + '-params'
+ const dataContainer = document.querySelector(targetSelector + '-params');
+ if (!dataContainer) {
+ console.warn('Data container not found');
+ return;
+ }
-Behaviour.specify(".bct-rerun-latest-build-onclick", 'BuildCardExtension_latestRerunClick', 0, function(element) {
+ handlerFn(dataContainer);
+ };
- const dataContainer = document.querySelector(".bct-rerun-latest-build-onclick-params");
- const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
- const buildExtId = dataContainer.dataset.rerunBuildExtId;
- const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
- .split(',')
- .filter(Boolean)
- .map(id => parseInt(id, 10));
+ // Add the new handler
+ parentElement.addEventListener('click', newHandler);
+ return newHandler;
+};
- element.addEventListener('click', () => {
- buildPipeline.showSpinner(id);
- buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
- });
-});
+// Register behaviours using delegation pattern
+Behaviour.specify(
+ ".bct-progress-console-onclick",
+ 'BuildCardExtension_progressBarClick',
+ 0,
+ function() {
+ progressClickHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-progress-console-onclick',
+ handleDialogClick,
+ progressClickHandler
+ );
+ }
+);
+
+Behaviour.specify(
+ ".bct-console-icon-onclick",
+ 'BuildCardExtension_consoleIconClick',
+ 0,
+ function() {
+ consoleClickHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-console-icon-onclick',
+ handleDialogClick,
+ consoleClickHandler
+ );
+ }
+);
+
+Behaviour.specify(
+ ".bct-rerun-success-icon-onclick",
+ 'BuildCardExtension_successRerunClick',
+ 0,
+ function() {
+ successRerunHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-rerun-success-icon-onclick',
+ handleRerunClick,
+ successRerunHandler
+ );
+ }
+);
+
+Behaviour.specify(
+ ".bct-rerun-latest-build-onclick",
+ 'BuildCardExtension_latestRerunClick',
+ 0,
+ function() {
+ latestRerunHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-rerun-latest-build-onclick',
+ handleRerunClick,
+ latestRerunHandler
+ );
+ }
+);
+
+Behaviour.specify(
+ ".bct-rerun-failed-not-manual-build-onclick",
+ 'BuildCardExtension_failedNotManualRerunClick',
+ 0,
+ function() {
+ pipelineClickHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-rerun-failed-not-manual-build-onclick',
+ handleRerunClick,
+ pipelineClickHandler
+ );
+ }
+);
+
+//
+// Behaviour.specify(".bct-progress-console-onclick", 'BuildCardExtension_progressBarClick', 0, function (element) {
+//
+// const dataContainer = document.querySelector(".bct-progress-console-onclick-params");;
+// const href = dataContainer.dataset.fillDialogHref;
+// const title = dataContainer.dataset.fillDialogTitle;
+//
+// element.addEventListener('click', () => {
+// buildPipeline.fillDialog(href, title);
+// });
+// });
+//
+// Behaviour.specify(".bct-console-icon-onclick", 'BuildCardExtension_consoleIconClick', 0, function (element) {
+//
+// const dataContainer = document.querySelector(".bct-console-icon-onclick-params");
+// const href = dataContainer.dataset.fillDialogHref;
+// const title = dataContainer.dataset.fillDialogTitle;
+//
+// element.addEventListener('click', () => {
+// buildPipeline.fillDialog(href, title);
+// });
+// });
+//
+// Behaviour.specify(".bct-rerun-success-icon-onclick", 'BuildCardExtension_successRerunClick', 0, function(element) {
+//
+// const dataContainer = document.querySelector(".bct-rerun-success-icon-onclick-params");
+// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
+// const buildExtId = dataContainer.dataset.rerunBuildExtId;
+// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
+// .split(',')
+// .filter(Boolean)
+// .map(id => parseInt(id, 10));
+//
+// element.addEventListener('click', () => {
+// buildPipeline.showSpinner(id);
+// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+// });
+// });
+//
+// Behaviour.specify(".bct-rerun-latest-build-onclick", 'BuildCardExtension_latestRerunClick', 0, function(element) {
+//
+// const dataContainer = document.querySelector(".bct-rerun-failed-latest-build-onclick-params");
+// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
+// const buildExtId = dataContainer.dataset.rerunBuildExtId;
+// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
+// .split(',')
+// .filter(Boolean)
+// .map(id => parseInt(id, 10));
+//
+// element.addEventListener('click', () => {
+// buildPipeline.showSpinner(id);
+// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+// });
+// });
+//
+// Behaviour.specify(".bct-rerun-failed-not-manual-build-onclick", 'BuildCardExtension_failedNotManualRerunClick', 0, function(element) {
+// const pipelineWrapper = document.querySelector('.pipelines');
+// if (!pipelineWrapper) {
+// console.warn('Pipeline not found');
+// return;
+// }
+//
+// pipelineWrapper.addEventListener('click', function(event) {
+// console.log("Clicked on pipeline wrapper");
+// const clickTarget = event.target.closest('.bct-rerun-failed-not-manual-build-onclick');
+// if (!clickTarget) return;
+//
+// const dataContainer = clickTarget.previousElementSibling;
+//
+// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
+// console.log("ID:", id);
+// const buildExtId = dataContainer.dataset.rerunBuildExtId;
+// console.log("BuildExtId:", buildExtId);
+// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
+// .split(',')
+// .filter(Boolean)
+// .map(id => parseInt(id, 10));
+// console.log("DependencyIds:", dependencyIds);
+//
+// buildPipeline.showSpinner(id);
+// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+// });
+// });
+//
+// // Generic handler function for dialog-based clicks
+// function createDialogClickHandler(paramsSelector, clickSelector, behaviourName) {
+// Behaviour.specify(clickSelector, behaviourName, 0, function(element) {
+// // Find the closest params container to this specific element
+// const dataContainer = element.closest('.build-card').querySelector(paramsSelector);
+// if (!dataContainer) return;
+//
+// const href = dataContainer.dataset.fillDialogHref;
+// const title = dataContainer.dataset.fillDialogTitle;
+//
+// element.addEventListener('click', () => {
+// buildPipeline.fillDialog(href, title);
+// });
+// });
+// }
+//
+// // Generic handler function for rerun-based clicks
+// function createRerunClickHandler(paramsSelector, clickSelector, behaviourName) {
+// Behaviour.specify(clickSelector, behaviourName, 0, function(element) {
+// // Find the closest params container to this specific element
+// const dataContainer = element.closest('.build-card').querySelector(paramsSelector);
+// if (!dataContainer) return;
+//
+// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
+// const buildExtId = dataContainer.dataset.rerunBuildExtId;
+// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
+// .split(',')
+// .filter(Boolean)
+// .map(id => parseInt(id, 10));
+//
+// element.addEventListener('click', () => {
+// buildPipeline.showSpinner(id);
+// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
+// });
+// });
+// }
+//
+// // Dialog-based handlers
+// createDialogClickHandler(
+// '.bct-progress-console-onclick-params',
+// '.bct-progress-console-onclick',
+// 'BuildCardExtension_progressBarClick'
+// );
+//
+// createDialogClickHandler(
+// '.bct-console-icon-onclick-params',
+// '.bct-console-icon-onclick',
+// 'BuildCardExtension_consoleIconClick'
+// );
+//
+// // Rerun-based handlers
+// createRerunClickHandler(
+// '.bct-rerun-success-icon-onclick-params',
+// '.bct-rerun-success-icon-onclick',
+// 'BuildCardExtension_successRerunClick'
+// );
+//
+// createRerunClickHandler(
+// '.bct-rerun-failed-latest-build-onclick-params',
+// '.bct-rerun-failed-latest-build-onclick',
+// 'BuildCardExtension_latestRerunClick'
+// );
+//
+// createRerunClickHandler(
+// '.bct-rerun-failed-not-manual-build-onclick-params',
+// '.bct-rerun-failed-not-manual-build-onclick',
+// 'BuildCardExtension_failedNotManualRerunClick'
+// );
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 538a74e6..1b69912d 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -118,8 +118,8 @@
{{#if ${it.triggerOnlyLatestJob}}}
{{#if build.isLatestBuild}}
{{#if build.isUpstreamBuildLatest}}
-
-
+
+
{{/if}}
@@ -131,10 +131,11 @@
Shlomo2
{{else}}
-
+
+
- Shlomo3
+ Shlomo3
{{/if}}
{{/if}}
{{/if}}
@@ -146,11 +147,13 @@
+ SHLOMO4
{{/if}}
{{else}}
+ SHLOMO5
{{/if}}
{{/if}}
From 047a7471a1271b59ce19d4ea2ad9188aa2a616dc Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 21:44:33 -0400
Subject: [PATCH 09/23] fix:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L140
---
.../build-card-template-onclicks.js | 39 +++++++++++++++++--
.../buildCardTemplate.jelly | 13 ++++---
2 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 7def0a23..665a89e1 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -4,6 +4,7 @@ let consoleClickHandler = null;
let progressClickHandler = null;
let successRerunHandler = null;
let latestRerunHandler = null;
+let triggerBuildHandler = null;
// Common utilities
const parseDataAttributes = (container) => ({
@@ -15,6 +16,17 @@ const parseDataAttributes = (container) => ({
.map(id => parseInt(id, 10))
});
+const parseTriggerAttributes = (container) => ({
+ id: parseInt(container.dataset.showSpinnerId, 10),
+ upstreamProjectName: container.dataset.upstreamProjectName,
+ upstreamBuildNumber: parseInt(container.dataset.upstreamBuildNumber, 10),
+ projectName: container.dataset.projectName,
+ dependencyIds: container.dataset.dependencyIds
+ .split(',')
+ .filter(Boolean)
+ .map(id => parseInt(id, 10))
+});
+
// Dialog handlers
const handleDialogClick = (dataContainer) => {
const { fillDialogHref: href, fillDialogTitle: title } = dataContainer.dataset;
@@ -28,6 +40,13 @@ const handleRerunClick = (dataContainer) => {
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
};
+// Trigger build handler
+const handleTriggerBuild = (dataContainer) => {
+ const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
+ buildPipeline.showSpinner(id);
+ buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
+};
+
// Create delegated event handler
const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, existingHandler) => {
const parentElement = document.querySelector(parentSelector);
@@ -61,7 +80,7 @@ const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, exist
return newHandler;
};
-// Register behaviours using delegation pattern
+// Register behaviours
Behaviour.specify(
".bct-progress-console-onclick",
'BuildCardExtension_progressBarClick',
@@ -105,13 +124,13 @@ Behaviour.specify(
);
Behaviour.specify(
- ".bct-rerun-latest-build-onclick",
+ ".bct-rerun-failed-latest-build-onclick", // Changed to match HTML class
'BuildCardExtension_latestRerunClick',
0,
function() {
latestRerunHandler = createDelegatedHandler(
'.pipelines',
- '.bct-rerun-latest-build-onclick',
+ '.bct-rerun-failed-latest-build-onclick', // Changed to match HTML class
handleRerunClick,
latestRerunHandler
);
@@ -132,6 +151,20 @@ Behaviour.specify(
}
);
+Behaviour.specify(
+ ".bct-trigger-build-onclick",
+ 'BuildCardExtension_triggerBuildClick',
+ 0,
+ function() {
+ triggerBuildHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-trigger-build-onclick',
+ handleTriggerBuild,
+ triggerBuildHandler
+ );
+ }
+);
+
//
// Behaviour.specify(".bct-progress-console-onclick", 'BuildCardExtension_progressBarClick', 0, function (element) {
//
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 1b69912d..1a265d94 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -112,6 +112,7 @@
+ test1
{{/if}}
{{else}}
@@ -122,20 +123,21 @@
+ test2
{{/if}}
{{/if}}
{{else}}
{{#if build.isManual}}
- Shlomo2
+ test3
{{else}}
- Shlomo3
+ test4
{{/if}}
{{/if}}
{{/if}}
@@ -144,16 +146,17 @@
{{#if build.isReadyToBeManuallyBuilt}}
{{#if ${it.triggerOnlyLatestJob}}}
{{#if build.isUpstreamBuildLatestSuccess}}
-
+
+
- SHLOMO4
+ test5
{{/if}}
{{else}}
- SHLOMO5
+ test6
{{/if}}
{{/if}}
From 6ef42407e9c91b247d8cd7253e54f4d1ee2957ec Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 22:04:32 -0400
Subject: [PATCH 10/23] fix:
https://github.com/jenkinsci/build-pipeline-plugin/blob/master/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly\#L145
---
.../build-card-template-onclicks.js | 20 +++++++++++++++++--
.../buildCardTemplate.jelly | 8 +++++---
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 665a89e1..baf79599 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -5,6 +5,8 @@ let progressClickHandler = null;
let successRerunHandler = null;
let latestRerunHandler = null;
let triggerBuildHandler = null;
+let triggerManualBuildLatestHandler = null;
+let triggerManualBuildHandler = null;
// Common utilities
const parseDataAttributes = (container) => ({
@@ -152,19 +154,33 @@ Behaviour.specify(
);
Behaviour.specify(
- ".bct-trigger-build-onclick",
+ ".bct-trigger-manual-build-latest-onclick",
'BuildCardExtension_triggerBuildClick',
0,
function() {
triggerBuildHandler = createDelegatedHandler(
'.pipelines',
- '.bct-trigger-build-onclick',
+ '.bct-trigger-manual-build-latest-onclick',
handleTriggerBuild,
triggerBuildHandler
);
}
);
+Behaviour.specify(
+ ".bct-trigger-manual-build-onclick",
+ 'BuildCardExtension_triggerManualBuildClick',
+ 0,
+ function() {
+ triggerManualBuildHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-trigger-manual-build-onclick',
+ handleTriggerBuild,
+ triggerManualBuildHandler
+ );
+ }
+);
+
//
// Behaviour.specify(".bct-progress-console-onclick", 'BuildCardExtension_progressBarClick', 0, function (element) {
//
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 1a265d94..00759455 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -146,14 +146,16 @@
{{#if build.isReadyToBeManuallyBuilt}}
{{#if ${it.triggerOnlyLatestJob}}}
{{#if build.isUpstreamBuildLatestSuccess}}
-
-
+
+
test5
{{/if}}
{{else}}
-
+
+
+
test6
From a3b8458724744076a72e388f4610187c7b539c37 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 22:07:50 -0400
Subject: [PATCH 11/23] dynamic behaviour.specify
---
.../build-card-template-onclicks.js | 180 +-----------------
1 file changed, 4 insertions(+), 176 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index baf79599..3a48a242 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -8,7 +8,6 @@ let triggerBuildHandler = null;
let triggerManualBuildLatestHandler = null;
let triggerManualBuildHandler = null;
-// Common utilities
const parseDataAttributes = (container) => ({
id: parseInt(container.dataset.showSpinnerId, 10),
buildExtId: container.dataset.rerunBuildExtId,
@@ -29,60 +28,43 @@ const parseTriggerAttributes = (container) => ({
.map(id => parseInt(id, 10))
});
-// Dialog handlers
const handleDialogClick = (dataContainer) => {
const { fillDialogHref: href, fillDialogTitle: title } = dataContainer.dataset;
buildPipeline.fillDialog(href, title);
};
-// Rerun build handlers
const handleRerunClick = (dataContainer) => {
const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
};
-// Trigger build handler
const handleTriggerBuild = (dataContainer) => {
const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
};
-// Create delegated event handler
const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, existingHandler) => {
+
const parentElement = document.querySelector(parentSelector);
- if (!parentElement) {
- console.warn(`Parent element not found: ${parentSelector}`);
- return;
- }
- // Remove existing handler if it exists
if (existingHandler) {
parentElement.removeEventListener('click', existingHandler);
}
- // Create new handler
const newHandler = (event) => {
const clickTarget = event.target.closest(targetSelector);
if (!clickTarget) return;
- // All data containers follow the pattern: selector + '-params'
const dataContainer = document.querySelector(targetSelector + '-params');
- if (!dataContainer) {
- console.warn('Data container not found');
- return;
- }
-
handlerFn(dataContainer);
};
- // Add the new handler
parentElement.addEventListener('click', newHandler);
return newHandler;
};
-// Register behaviours
Behaviour.specify(
".bct-progress-console-onclick",
'BuildCardExtension_progressBarClick',
@@ -126,13 +108,13 @@ Behaviour.specify(
);
Behaviour.specify(
- ".bct-rerun-failed-latest-build-onclick", // Changed to match HTML class
+ ".bct-rerun-failed-latest-build-onclick",
'BuildCardExtension_latestRerunClick',
0,
function() {
latestRerunHandler = createDelegatedHandler(
'.pipelines',
- '.bct-rerun-failed-latest-build-onclick', // Changed to match HTML class
+ '.bct-rerun-failed-latest-build-onclick',
handleRerunClick,
latestRerunHandler
);
@@ -158,7 +140,7 @@ Behaviour.specify(
'BuildCardExtension_triggerBuildClick',
0,
function() {
- triggerBuildHandler = createDelegatedHandler(
+ triggerManualBuildLatestHandler = createDelegatedHandler(
'.pipelines',
'.bct-trigger-manual-build-latest-onclick',
handleTriggerBuild,
@@ -181,157 +163,3 @@ Behaviour.specify(
}
);
-//
-// Behaviour.specify(".bct-progress-console-onclick", 'BuildCardExtension_progressBarClick', 0, function (element) {
-//
-// const dataContainer = document.querySelector(".bct-progress-console-onclick-params");;
-// const href = dataContainer.dataset.fillDialogHref;
-// const title = dataContainer.dataset.fillDialogTitle;
-//
-// element.addEventListener('click', () => {
-// buildPipeline.fillDialog(href, title);
-// });
-// });
-//
-// Behaviour.specify(".bct-console-icon-onclick", 'BuildCardExtension_consoleIconClick', 0, function (element) {
-//
-// const dataContainer = document.querySelector(".bct-console-icon-onclick-params");
-// const href = dataContainer.dataset.fillDialogHref;
-// const title = dataContainer.dataset.fillDialogTitle;
-//
-// element.addEventListener('click', () => {
-// buildPipeline.fillDialog(href, title);
-// });
-// });
-//
-// Behaviour.specify(".bct-rerun-success-icon-onclick", 'BuildCardExtension_successRerunClick', 0, function(element) {
-//
-// const dataContainer = document.querySelector(".bct-rerun-success-icon-onclick-params");
-// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
-// const buildExtId = dataContainer.dataset.rerunBuildExtId;
-// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
-// .split(',')
-// .filter(Boolean)
-// .map(id => parseInt(id, 10));
-//
-// element.addEventListener('click', () => {
-// buildPipeline.showSpinner(id);
-// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
-// });
-// });
-//
-// Behaviour.specify(".bct-rerun-latest-build-onclick", 'BuildCardExtension_latestRerunClick', 0, function(element) {
-//
-// const dataContainer = document.querySelector(".bct-rerun-failed-latest-build-onclick-params");
-// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
-// const buildExtId = dataContainer.dataset.rerunBuildExtId;
-// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
-// .split(',')
-// .filter(Boolean)
-// .map(id => parseInt(id, 10));
-//
-// element.addEventListener('click', () => {
-// buildPipeline.showSpinner(id);
-// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
-// });
-// });
-//
-// Behaviour.specify(".bct-rerun-failed-not-manual-build-onclick", 'BuildCardExtension_failedNotManualRerunClick', 0, function(element) {
-// const pipelineWrapper = document.querySelector('.pipelines');
-// if (!pipelineWrapper) {
-// console.warn('Pipeline not found');
-// return;
-// }
-//
-// pipelineWrapper.addEventListener('click', function(event) {
-// console.log("Clicked on pipeline wrapper");
-// const clickTarget = event.target.closest('.bct-rerun-failed-not-manual-build-onclick');
-// if (!clickTarget) return;
-//
-// const dataContainer = clickTarget.previousElementSibling;
-//
-// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
-// console.log("ID:", id);
-// const buildExtId = dataContainer.dataset.rerunBuildExtId;
-// console.log("BuildExtId:", buildExtId);
-// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
-// .split(',')
-// .filter(Boolean)
-// .map(id => parseInt(id, 10));
-// console.log("DependencyIds:", dependencyIds);
-//
-// buildPipeline.showSpinner(id);
-// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
-// });
-// });
-//
-
-
-// // Generic handler function for dialog-based clicks
-// function createDialogClickHandler(paramsSelector, clickSelector, behaviourName) {
-// Behaviour.specify(clickSelector, behaviourName, 0, function(element) {
-// // Find the closest params container to this specific element
-// const dataContainer = element.closest('.build-card').querySelector(paramsSelector);
-// if (!dataContainer) return;
-//
-// const href = dataContainer.dataset.fillDialogHref;
-// const title = dataContainer.dataset.fillDialogTitle;
-//
-// element.addEventListener('click', () => {
-// buildPipeline.fillDialog(href, title);
-// });
-// });
-// }
-//
-// // Generic handler function for rerun-based clicks
-// function createRerunClickHandler(paramsSelector, clickSelector, behaviourName) {
-// Behaviour.specify(clickSelector, behaviourName, 0, function(element) {
-// // Find the closest params container to this specific element
-// const dataContainer = element.closest('.build-card').querySelector(paramsSelector);
-// if (!dataContainer) return;
-//
-// const id = parseInt(dataContainer.dataset.showSpinnerId, 10);
-// const buildExtId = dataContainer.dataset.rerunBuildExtId;
-// const dependencyIds = dataContainer.dataset.rerunBuildDependencyIds
-// .split(',')
-// .filter(Boolean)
-// .map(id => parseInt(id, 10));
-//
-// element.addEventListener('click', () => {
-// buildPipeline.showSpinner(id);
-// buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
-// });
-// });
-// }
-//
-// // Dialog-based handlers
-// createDialogClickHandler(
-// '.bct-progress-console-onclick-params',
-// '.bct-progress-console-onclick',
-// 'BuildCardExtension_progressBarClick'
-// );
-//
-// createDialogClickHandler(
-// '.bct-console-icon-onclick-params',
-// '.bct-console-icon-onclick',
-// 'BuildCardExtension_consoleIconClick'
-// );
-//
-// // Rerun-based handlers
-// createRerunClickHandler(
-// '.bct-rerun-success-icon-onclick-params',
-// '.bct-rerun-success-icon-onclick',
-// 'BuildCardExtension_successRerunClick'
-// );
-//
-// createRerunClickHandler(
-// '.bct-rerun-failed-latest-build-onclick-params',
-// '.bct-rerun-failed-latest-build-onclick',
-// 'BuildCardExtension_latestRerunClick'
-// );
-//
-// createRerunClickHandler(
-// '.bct-rerun-failed-not-manual-build-onclick-params',
-// '.bct-rerun-failed-not-manual-build-onclick',
-// 'BuildCardExtension_failedNotManualRerunClick'
-// );
From ed0c9e57e87fae277d354a837cf8529ff2de47f5 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 29 Oct 2024 22:08:33 -0400
Subject: [PATCH 12/23] dynamic behaviour.specify
---
.../extension/BuildCardExtension/build-card-template-onclicks.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 3a48a242..e95bf447 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,4 +1,3 @@
-// Store references to handlers to avoid duplicates
let pipelineClickHandler = null;
let consoleClickHandler = null;
let progressClickHandler = null;
From 30476d5fab7fded5d376c0de2ea062018687f35c Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 30 Oct 2024 13:54:20 -0400
Subject: [PATCH 13/23] update names, update java method, all working
---
.../hudson/plugin/util/ProjectUtil.java | 2 +-
.../build-card-template-onclicks.js | 62 ++++++++++++-------
.../buildCardTemplate.jelly | 24 +++----
3 files changed, 49 insertions(+), 39 deletions(-)
diff --git a/src/main/java/au/com/centrumsystems/hudson/plugin/util/ProjectUtil.java b/src/main/java/au/com/centrumsystems/hudson/plugin/util/ProjectUtil.java
index f2787846..942211cb 100644
--- a/src/main/java/au/com/centrumsystems/hudson/plugin/util/ProjectUtil.java
+++ b/src/main/java/au/com/centrumsystems/hudson/plugin/util/ProjectUtil.java
@@ -105,7 +105,7 @@ public static boolean isManualTrigger(final AbstractProject, ?> upstreamProjec
final String manualDownstreamProjects = ((BuildPipelineTrigger) upstreamPub).getDownstreamProjectNames();
final String[] downstreamProjs = manualDownstreamProjects.split(",");
for (final String nextProj : downstreamProjs) {
- if (Jenkins.getInstance().getItem(nextProj.trim(), upstreamProject) == downstreamProject) {
+ if (Jenkins.getInstance().getItem(nextProj.trim(), upstreamProject).getName().equals(downstreamProject.getName())) {
manualTrigger = true;
break;
}
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index e95bf447..94dca262 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,9 +1,9 @@
-let pipelineClickHandler = null;
-let consoleClickHandler = null;
-let progressClickHandler = null;
+let progressBarClickHandler = null;
+let consoleIconClickHandler = null;
let successRerunHandler = null;
-let latestRerunHandler = null;
-let triggerBuildHandler = null;
+let latestFailedRerunHandler = null;
+let manualFailedRerunHandler = null;
+let failedRerunHandler = null;
let triggerManualBuildLatestHandler = null;
let triggerManualBuildHandler = null;
@@ -29,6 +29,7 @@ const parseTriggerAttributes = (container) => ({
const handleDialogClick = (dataContainer) => {
const { fillDialogHref: href, fillDialogTitle: title } = dataContainer.dataset;
+ console.log('handleDialogClick', href, title);
buildPipeline.fillDialog(href, title);
};
@@ -45,7 +46,6 @@ const handleTriggerBuild = (dataContainer) => {
};
const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, existingHandler) => {
-
const parentElement = document.querySelector(parentSelector);
if (existingHandler) {
@@ -56,7 +56,9 @@ const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, exist
const clickTarget = event.target.closest(targetSelector);
if (!clickTarget) return;
- const dataContainer = document.querySelector(targetSelector + '-params');
+ const buildCard = clickTarget.closest('.build-card');
+ const dataContainer = buildCard.querySelector(targetSelector + '-params');
+
handlerFn(dataContainer);
};
@@ -65,15 +67,15 @@ const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, exist
};
Behaviour.specify(
- ".bct-progress-console-onclick",
+ ".bct-progress-bar-onclick",
'BuildCardExtension_progressBarClick',
0,
function() {
- progressClickHandler = createDelegatedHandler(
+ progressBarClickHandler = createDelegatedHandler(
'.pipelines',
- '.bct-progress-console-onclick',
+ '.bct-progress-bar-onclick',
handleDialogClick,
- progressClickHandler
+ progressBarClickHandler
);
}
);
@@ -83,23 +85,23 @@ Behaviour.specify(
'BuildCardExtension_consoleIconClick',
0,
function() {
- consoleClickHandler = createDelegatedHandler(
+ consoleIconClickHandler = createDelegatedHandler(
'.pipelines',
'.bct-console-icon-onclick',
handleDialogClick,
- consoleClickHandler
+ consoleIconClickHandler
);
}
);
Behaviour.specify(
- ".bct-rerun-success-icon-onclick",
+ ".bct-rerun-successful-build-onclick",
'BuildCardExtension_successRerunClick',
0,
function() {
successRerunHandler = createDelegatedHandler(
'.pipelines',
- '.bct-rerun-success-icon-onclick',
+ '.bct-rerun-successful-build-onclick',
handleRerunClick,
successRerunHandler
);
@@ -108,28 +110,42 @@ Behaviour.specify(
Behaviour.specify(
".bct-rerun-failed-latest-build-onclick",
- 'BuildCardExtension_latestRerunClick',
+ 'BuildCardExtension_latestFailedRerunClick',
0,
function() {
- latestRerunHandler = createDelegatedHandler(
+ latestFailedRerunHandler = createDelegatedHandler(
'.pipelines',
'.bct-rerun-failed-latest-build-onclick',
handleRerunClick,
- latestRerunHandler
+ latestFailedRerunHandler
+ );
+ }
+);
+
+Behaviour.specify(
+ ".bct-rerun-failed-manual-build-onclick",
+ 'BuildCardExtension_failedManualRerunClick',
+ 0,
+ function() {
+ manualFailedRerunHandler = createDelegatedHandler(
+ '.pipelines',
+ '.bct-rerun-failed-manual-build-onclick',
+ handleTriggerBuild,
+ manualFailedRerunHandler
);
}
);
Behaviour.specify(
- ".bct-rerun-failed-not-manual-build-onclick",
+ ".bct-rerun-failed-build-onclick",
'BuildCardExtension_failedNotManualRerunClick',
0,
function() {
- pipelineClickHandler = createDelegatedHandler(
+ failedRerunHandler = createDelegatedHandler(
'.pipelines',
- '.bct-rerun-failed-not-manual-build-onclick',
+ '.bct-rerun-failed-build-onclick',
handleRerunClick,
- pipelineClickHandler
+ failedRerunHandler
);
}
);
@@ -143,7 +159,7 @@ Behaviour.specify(
'.pipelines',
'.bct-trigger-manual-build-latest-onclick',
handleTriggerBuild,
- triggerBuildHandler
+ triggerManualBuildLatestHandler
);
}
);
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index 00759455..dbe53222 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -61,8 +61,8 @@
{{#unless project.disabled}}
{{#if build.isBuilding}}
-
-
+
+
@@ -108,11 +108,10 @@
{{#if build.isSuccess}}
{{#if ${!it.triggerOnlyLatestJob}}}
-
-
+
+
- test1
{{/if}}
{{else}}
@@ -123,21 +122,19 @@
- test2
{{/if}}
{{/if}}
{{else}}
- {{#if build.isManual}}
-
+ {{#if build.isManualTrigger}}
+
+
- test3
{{else}}
-
-
+
+
- test4
{{/if}}
{{/if}}
{{/if}}
@@ -150,15 +147,12 @@
- test5
{{/if}}
{{else}}
-
- test6
{{/if}}
{{/if}}
From 557205125841b97ec4c17fd1afd0ab6ac95d5cf1 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 30 Oct 2024 17:23:57 -0400
Subject: [PATCH 14/23] remove Behaviour.specify \ Use dynamic approach
---
.../build-card-template-onclicks.js | 225 ++++++------------
1 file changed, 71 insertions(+), 154 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 94dca262..f4d4ce60 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,180 +1,97 @@
-let progressBarClickHandler = null;
-let consoleIconClickHandler = null;
-let successRerunHandler = null;
-let latestFailedRerunHandler = null;
-let manualFailedRerunHandler = null;
-let failedRerunHandler = null;
-let triggerManualBuildLatestHandler = null;
-let triggerManualBuildHandler = null;
-
-const parseDataAttributes = (container) => ({
- id: parseInt(container.dataset.showSpinnerId, 10),
- buildExtId: container.dataset.rerunBuildExtId,
- dependencyIds: container.dataset.rerunBuildDependencyIds
- .split(',')
- .filter(Boolean)
- .map(id => parseInt(id, 10))
-});
+const parseDataAttributes = function(container) {
+ return {
+ id: parseInt(container.dataset.showSpinnerId, 10),
+ buildExtId: container.dataset.rerunBuildExtId,
+ dependencyIds: container.dataset.rerunBuildDependencyIds
+ .split(",")
+ .filter(Boolean)
+ .map(function(id) {
+ return parseInt(id, 10);
+ })
+ };
+};
-const parseTriggerAttributes = (container) => ({
- id: parseInt(container.dataset.showSpinnerId, 10),
- upstreamProjectName: container.dataset.upstreamProjectName,
- upstreamBuildNumber: parseInt(container.dataset.upstreamBuildNumber, 10),
- projectName: container.dataset.projectName,
- dependencyIds: container.dataset.dependencyIds
- .split(',')
- .filter(Boolean)
- .map(id => parseInt(id, 10))
-});
+const parseTriggerAttributes = function(container) {
+ return {
+ id: parseInt(container.dataset.showSpinnerId, 10),
+ upstreamProjectName: container.dataset.upstreamProjectName,
+ upstreamBuildNumber: parseInt(container.dataset.upstreamBuildNumber, 10),
+ projectName: container.dataset.projectName,
+ dependencyIds: container.dataset.dependencyIds
+ .split(",")
+ .filter(Boolean)
+ .map(function(id) {
+ return parseInt(id, 10);
+ })
+ };
+};
-const handleDialogClick = (dataContainer) => {
- const { fillDialogHref: href, fillDialogTitle: title } = dataContainer.dataset;
- console.log('handleDialogClick', href, title);
+const handleDialogClick = function(dataContainer) {
+ const href = dataContainer.dataset.fillDialogHref;
+ const title = dataContainer.dataset.fillDialogTitle;
buildPipeline.fillDialog(href, title);
};
-const handleRerunClick = (dataContainer) => {
+const handleRerunClick = function(dataContainer) {
const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
};
-const handleTriggerBuild = (dataContainer) => {
+const handleTriggerBuild = function(dataContainer) {
const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
};
-const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, existingHandler) => {
- const parentElement = document.querySelector(parentSelector);
-
- if (existingHandler) {
- parentElement.removeEventListener('click', existingHandler);
- }
-
- const newHandler = (event) => {
+const createClickHandler = function(parentElement, targetSelector, handlerFn) {
+ const newHandler = function(event) {
const clickTarget = event.target.closest(targetSelector);
- if (!clickTarget) return;
+ if (!clickTarget || !parentElement.contains(clickTarget)) return;
- const buildCard = clickTarget.closest('.build-card');
- const dataContainer = buildCard.querySelector(targetSelector + '-params');
+ const buildCard = clickTarget.closest(".build-card");
+ if (!buildCard) return;
+ const dataContainer = buildCard.querySelector(targetSelector + "-params");
handlerFn(dataContainer);
};
- parentElement.addEventListener('click', newHandler);
- return newHandler;
+ parentElement.addEventListener("click", newHandler);
};
-Behaviour.specify(
- ".bct-progress-bar-onclick",
- 'BuildCardExtension_progressBarClick',
- 0,
- function() {
- progressBarClickHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-progress-bar-onclick',
- handleDialogClick,
- progressBarClickHandler
- );
+const onclickElements = {
+ ".bct-progress-bar-onclick": {
+ handler: handleDialogClick
+ },
+ ".bct-console-icon-onclick": {
+ handler: handleDialogClick
+ },
+ ".bct-rerun-successful-build-onclick": {
+ handler: handleRerunClick
+ },
+ ".bct-rerun-failed-latest-build-onclick": {
+ handler: handleRerunClick
+ },
+ ".bct-rerun-failed-manual-build-onclick": {
+ handler: handleTriggerBuild
+ },
+ ".bct-rerun-failed-build-onclick": {
+ handler: handleRerunClick
+ },
+ ".bct-trigger-manual-build-latest-onclick": {
+ handler: handleTriggerBuild
+ },
+ ".bct-trigger-manual-build-onclick": {
+ handler: handleTriggerBuild
}
-);
-
-Behaviour.specify(
- ".bct-console-icon-onclick",
- 'BuildCardExtension_consoleIconClick',
- 0,
- function() {
- consoleIconClickHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-console-icon-onclick',
- handleDialogClick,
- consoleIconClickHandler
- );
- }
-);
-
-Behaviour.specify(
- ".bct-rerun-successful-build-onclick",
- 'BuildCardExtension_successRerunClick',
- 0,
- function() {
- successRerunHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-rerun-successful-build-onclick',
- handleRerunClick,
- successRerunHandler
- );
- }
-);
-
-Behaviour.specify(
- ".bct-rerun-failed-latest-build-onclick",
- 'BuildCardExtension_latestFailedRerunClick',
- 0,
- function() {
- latestFailedRerunHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-rerun-failed-latest-build-onclick',
- handleRerunClick,
- latestFailedRerunHandler
- );
- }
-);
-
-Behaviour.specify(
- ".bct-rerun-failed-manual-build-onclick",
- 'BuildCardExtension_failedManualRerunClick',
- 0,
- function() {
- manualFailedRerunHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-rerun-failed-manual-build-onclick',
- handleTriggerBuild,
- manualFailedRerunHandler
- );
- }
-);
-
-Behaviour.specify(
- ".bct-rerun-failed-build-onclick",
- 'BuildCardExtension_failedNotManualRerunClick',
- 0,
- function() {
- failedRerunHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-rerun-failed-build-onclick',
- handleRerunClick,
- failedRerunHandler
- );
- }
-);
-
-Behaviour.specify(
- ".bct-trigger-manual-build-latest-onclick",
- 'BuildCardExtension_triggerBuildClick',
- 0,
- function() {
- triggerManualBuildLatestHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-trigger-manual-build-latest-onclick',
- handleTriggerBuild,
- triggerManualBuildLatestHandler
- );
- }
-);
+};
-Behaviour.specify(
- ".bct-trigger-manual-build-onclick",
- 'BuildCardExtension_triggerManualBuildClick',
- 0,
- function() {
- triggerManualBuildHandler = createDelegatedHandler(
- '.pipelines',
- '.bct-trigger-manual-build-onclick',
- handleTriggerBuild,
- triggerManualBuildHandler
- );
- }
-);
+document.addEventListener("DOMContentLoaded", function () {
+ const parentElement = document.querySelector(".pipelines");
+ Object.entries(onclickElements).forEach(function(entry) {
+ const selector = entry[0];
+ const handlerConfig = entry[1];
+ createClickHandler(parentElement, selector, handlerConfig.handler);
+ });
+});
From ba67a4b32f5af3d5489c5b3fcd211c1ad3f2a56a Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 30 Oct 2024 17:27:24 -0400
Subject: [PATCH 15/23] remove Behaviour.specify \ Use dynamic approach
---
.../BuildCardExtension/build-card-template-onclicks.js | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index f4d4ce60..d4e091df 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -5,9 +5,8 @@ const parseDataAttributes = function(container) {
dependencyIds: container.dataset.rerunBuildDependencyIds
.split(",")
.filter(Boolean)
- .map(function(id) {
- return parseInt(id, 10);
- })
+ .map(id => parseInt(id, 10))
+
};
};
@@ -20,9 +19,7 @@ const parseTriggerAttributes = function(container) {
dependencyIds: container.dataset.dependencyIds
.split(",")
.filter(Boolean)
- .map(function(id) {
- return parseInt(id, 10);
- })
+ .map(id => parseInt(id, 10))
};
};
From 9bf83a9cec7530283cc134a9dbadd7d1984c36f7 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 30 Oct 2024 17:33:12 -0400
Subject: [PATCH 16/23] remove Behaviour.specify \ Use dynamic approach
---
.../build-card-template-onclicks.js | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index d4e091df..9184ad30 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -1,4 +1,4 @@
-const parseDataAttributes = function(container) {
+function parseDataAttributes(container) {
return {
id: parseInt(container.dataset.showSpinnerId, 10),
buildExtId: container.dataset.rerunBuildExtId,
@@ -6,11 +6,10 @@ const parseDataAttributes = function(container) {
.split(",")
.filter(Boolean)
.map(id => parseInt(id, 10))
-
};
-};
+}
-const parseTriggerAttributes = function(container) {
+function parseTriggerAttributes(container) {
return {
id: parseInt(container.dataset.showSpinnerId, 10),
upstreamProjectName: container.dataset.upstreamProjectName,
@@ -21,27 +20,27 @@ const parseTriggerAttributes = function(container) {
.filter(Boolean)
.map(id => parseInt(id, 10))
};
-};
+}
-const handleDialogClick = function(dataContainer) {
+function handleDialogClick(dataContainer) {
const href = dataContainer.dataset.fillDialogHref;
const title = dataContainer.dataset.fillDialogTitle;
buildPipeline.fillDialog(href, title);
-};
+}
-const handleRerunClick = function(dataContainer) {
+function handleRerunClick(dataContainer) {
const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
-};
+}
-const handleTriggerBuild = function(dataContainer) {
+function handleTriggerBuild(dataContainer) {
const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
-};
+}
-const createClickHandler = function(parentElement, targetSelector, handlerFn) {
+function createClickHandler(parentElement, targetSelector, handlerFn) {
const newHandler = function(event) {
const clickTarget = event.target.closest(targetSelector);
if (!clickTarget || !parentElement.contains(clickTarget)) return;
@@ -54,7 +53,7 @@ const createClickHandler = function(parentElement, targetSelector, handlerFn) {
};
parentElement.addEventListener("click", newHandler);
-};
+}
const onclickElements = {
".bct-progress-bar-onclick": {
From 59e2952986537f08c4918cdefb44d2a37cf263f9 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Wed, 30 Oct 2024 21:07:33 -0400
Subject: [PATCH 17/23] rerun tests
---
.../extension/BuildCardExtension/build-card-template-onclicks.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 9184ad30..8233a9b8 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -84,6 +84,7 @@ const onclickElements = {
document.addEventListener("DOMContentLoaded", function () {
const parentElement = document.querySelector(".pipelines");
+ if (!parentElement) return;
Object.entries(onclickElements).forEach(function(entry) {
const selector = entry[0];
From 7beca3498797419ec4a44d997929f08fdc1d2b0a Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Thu, 7 Nov 2024 14:35:19 -0500
Subject: [PATCH 18/23] specify pipeline wrapper - fixes onclick issues
---
.../hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly | 2 +-
.../BuildCardExtension/build-card-template-onclicks.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index 546e01fb..d50bd9e3 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -124,7 +124,7 @@
-
+
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 8233a9b8..78d6e594 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -83,7 +83,7 @@ const onclickElements = {
};
document.addEventListener("DOMContentLoaded", function () {
- const parentElement = document.querySelector(".pipelines");
+ const parentElement = document.querySelector(".main-pipeline-selector");
if (!parentElement) return;
Object.entries(onclickElements).forEach(function(entry) {
From 188bc434af1b93072432686871834aba63173cdd Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Thu, 7 Nov 2024 14:48:15 -0500
Subject: [PATCH 19/23] select all pipeline wrappers - incase multiple builds
selected
---
.../buildpipeline/BuildPipelineView/bpp.jelly | 2 +-
.../build-card-template-onclicks.js | 15 +++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index d50bd9e3..546e01fb 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -124,7 +124,7 @@
-
+
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index 78d6e594..ccad37db 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -83,12 +83,15 @@ const onclickElements = {
};
document.addEventListener("DOMContentLoaded", function () {
- const parentElement = document.querySelector(".main-pipeline-selector");
- if (!parentElement) return;
+ const pipelineWrappers = document.querySelectorAll(".pipeline-wrapper");
- Object.entries(onclickElements).forEach(function(entry) {
- const selector = entry[0];
- const handlerConfig = entry[1];
- createClickHandler(parentElement, selector, handlerConfig.handler);
+ if (!pipelineWrappers.length) return;
+
+ pipelineWrappers.forEach(wrapper => {
+ Object.entries(onclickElements).forEach(function(entry) {
+ const selector = entry[0];
+ const handlerConfig = entry[1];
+ createClickHandler(wrapper, selector, handlerConfig.handler);
+ });
});
});
From b3e23dada97dcf15e0b6c3a94721e041a49af71a Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Sun, 10 Nov 2024 09:29:14 -0500
Subject: [PATCH 20/23] remove redundant parameters span
---
.../build-card-template-onclicks.js | 12 +++-------
.../buildCardTemplate.jelly | 24 +++++++------------
2 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index ccad37db..d100030c 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -45,11 +45,7 @@ function createClickHandler(parentElement, targetSelector, handlerFn) {
const clickTarget = event.target.closest(targetSelector);
if (!clickTarget || !parentElement.contains(clickTarget)) return;
- const buildCard = clickTarget.closest(".build-card");
- if (!buildCard) return;
-
- const dataContainer = buildCard.querySelector(targetSelector + "-params");
- handlerFn(dataContainer);
+ handlerFn(clickTarget);
};
parentElement.addEventListener("click", newHandler);
@@ -88,10 +84,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (!pipelineWrappers.length) return;
pipelineWrappers.forEach(wrapper => {
- Object.entries(onclickElements).forEach(function(entry) {
- const selector = entry[0];
- const handlerConfig = entry[1];
- createClickHandler(wrapper, selector, handlerConfig.handler);
+ Object.entries(onclickElements).forEach(function([selector, { handler }]) {
+ createClickHandler(wrapper, selector, handler);
});
});
});
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
index dbe53222..e41192b8 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.jelly
@@ -61,8 +61,7 @@
{{#unless project.disabled}}
{{#if build.isBuilding}}
-
-
+
@@ -95,8 +94,7 @@
-
-
+
@@ -108,8 +106,7 @@
{{#if build.isSuccess}}
{{#if ${!it.triggerOnlyLatestJob}}}
-
-
+
@@ -118,21 +115,18 @@
{{#if ${it.triggerOnlyLatestJob}}}
{{#if build.isLatestBuild}}
{{#if build.isUpstreamBuildLatest}}
-
-
+
{{/if}}
{{/if}}
{{else}}
{{#if build.isManualTrigger}}
-
-
+
{{else}}
-
-
+
{{/if}}
@@ -143,14 +137,12 @@
{{#if build.isReadyToBeManuallyBuilt}}
{{#if ${it.triggerOnlyLatestJob}}}
{{#if build.isUpstreamBuildLatestSuccess}}
-
-
+
{{/if}}
{{else}}
-
-
+
{{/if}}
From fd147b583ed7243459c0919fc5aa2128e113bf7b Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 12 Nov 2024 14:59:12 -0500
Subject: [PATCH 21/23] simplify dependency ID parsing
---
.../BuildCardExtension/build-card-template-onclicks.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index d100030c..ed6a05ab 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -4,8 +4,7 @@ function parseDataAttributes(container) {
buildExtId: container.dataset.rerunBuildExtId,
dependencyIds: container.dataset.rerunBuildDependencyIds
.split(",")
- .filter(Boolean)
- .map(id => parseInt(id, 10))
+ .map(id => parseInt(id))
};
}
@@ -17,8 +16,7 @@ function parseTriggerAttributes(container) {
projectName: container.dataset.projectName,
dependencyIds: container.dataset.dependencyIds
.split(",")
- .filter(Boolean)
- .map(id => parseInt(id, 10))
+ .map(id => parseInt(id))
};
}
@@ -30,12 +28,14 @@ function handleDialogClick(dataContainer) {
function handleRerunClick(dataContainer) {
const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
+ console.log("dependencyIds", dependencyIds);
buildPipeline.showSpinner(id);
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
}
function handleTriggerBuild(dataContainer) {
const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
+ console.log("dependencyIds", dependencyIds);
buildPipeline.showSpinner(id);
buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
}
From 0a748ce1dc567e4af053e973327a1d92658501c8 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Mon, 25 Nov 2024 09:19:10 -0500
Subject: [PATCH 22/23] simplify/cleanup
---
.../build-card-template-onclicks.js | 38 +++++--------------
1 file changed, 10 insertions(+), 28 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index ed6a05ab..a3b495df 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -28,14 +28,12 @@ function handleDialogClick(dataContainer) {
function handleRerunClick(dataContainer) {
const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
- console.log("dependencyIds", dependencyIds);
buildPipeline.showSpinner(id);
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
}
function handleTriggerBuild(dataContainer) {
const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
- console.log("dependencyIds", dependencyIds);
buildPipeline.showSpinner(id);
buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
}
@@ -52,30 +50,14 @@ function createClickHandler(parentElement, targetSelector, handlerFn) {
}
const onclickElements = {
- ".bct-progress-bar-onclick": {
- handler: handleDialogClick
- },
- ".bct-console-icon-onclick": {
- handler: handleDialogClick
- },
- ".bct-rerun-successful-build-onclick": {
- handler: handleRerunClick
- },
- ".bct-rerun-failed-latest-build-onclick": {
- handler: handleRerunClick
- },
- ".bct-rerun-failed-manual-build-onclick": {
- handler: handleTriggerBuild
- },
- ".bct-rerun-failed-build-onclick": {
- handler: handleRerunClick
- },
- ".bct-trigger-manual-build-latest-onclick": {
- handler: handleTriggerBuild
- },
- ".bct-trigger-manual-build-onclick": {
- handler: handleTriggerBuild
- }
+ ".bct-progress-bar-onclick": handleDialogClick,
+ ".bct-console-icon-onclick": handleDialogClick,
+ ".bct-rerun-successful-build-onclick": handleRerunClick,
+ ".bct-rerun-failed-latest-build-onclick": handleRerunClick,
+ ".bct-rerun-failed-manual-build-onclick": handleTriggerBuild,
+ ".bct-rerun-failed-build-onclick": handleRerunClick,
+ ".bct-trigger-manual-build-latest-onclick": handleTriggerBuild,
+ ".bct-trigger-manual-build-onclick": handleTriggerBuild
};
document.addEventListener("DOMContentLoaded", function () {
@@ -84,8 +66,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (!pipelineWrappers.length) return;
pipelineWrappers.forEach(wrapper => {
- Object.entries(onclickElements).forEach(function([selector, { handler }]) {
+ Object.entries(onclickElements).forEach(function([selector, handler]) {
createClickHandler(wrapper, selector, handler);
});
});
-});
+});
\ No newline at end of file
From e501c9e7713c8e965566978b92895c64279ef453 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Mon, 25 Nov 2024 09:19:38 -0500
Subject: [PATCH 23/23] simplify/cleanup
---
.../BuildCardExtension/build-card-template-onclicks.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
index a3b495df..68530e91 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
@@ -70,4 +70,4 @@ document.addEventListener("DOMContentLoaded", function () {
createClickHandler(wrapper, selector, handler);
});
});
-});
\ No newline at end of file
+});