forked from geoffbullen/build-pipeline-plugin
-
Notifications
You must be signed in to change notification settings - Fork 161
[JENKINS-73960] Extract event handlers in BuildCardExtension/buildCardTemplate.jelly
#142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shlomomdahan
wants to merge
26
commits into
jenkinsci:master
Choose a base branch
from
shlomomdahan:JENKINS-73960
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+84
−10
Open
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
16aad96
fix: Update jQuery filter removal syntax for 3.x compatibility
shlomomdahan d74f129
address first csp issue: https://github.com/jenkinsci/build-pipeline-…
shlomomdahan 317e0fa
address first csp issue: https://github.com/jenkinsci/build-pipeline-…
shlomomdahan 913d01a
line 97: https://github.com/jenkinsci/build-pipeline-plugin/blob/mast…
shlomomdahan 6537326
Merge branch 'master' into JENKINS-73960
shlomomdahan 31008b1
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan 85d08a3
fix:https://github.com/jenkinsci/build-pipeline-plugin/blob/master/sr…
shlomomdahan f5f7cc7
fix:https://github.com/jenkinsci/build-pipeline-plugin/blob/master/sr…
shlomomdahan 2147df2
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan 047a747
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan 6ef4240
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan a3b8458
dynamic behaviour.specify
shlomomdahan ed0c9e5
dynamic behaviour.specify
shlomomdahan 30476d5
update names, update java method, all working
shlomomdahan 5572051
remove Behaviour.specify \ Use dynamic approach
shlomomdahan ba67a4b
remove Behaviour.specify \ Use dynamic approach
shlomomdahan 9bf83a9
remove Behaviour.specify \ Use dynamic approach
shlomomdahan 59e2952
rerun tests
shlomomdahan 7beca34
specify pipeline wrapper - fixes onclick issues
shlomomdahan 188bc43
select all pipeline wrappers - incase multiple builds selected
shlomomdahan b456e59
Merge branch 'master' into JENKINS-73960
shlomomdahan 8e66cab
Merge branch 'master' into JENKINS-73960
shlomomdahan b3e23da
remove redundant parameters span
shlomomdahan fd147b5
simplify dependency ID parsing
shlomomdahan 0a748ce
simplify/cleanup
shlomomdahan e501c9e
simplify/cleanup
shlomomdahan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
.../hudson/plugin/buildpipeline/extension/BuildCardExtension/build-card-template-onclicks.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| function parseDataAttributes(container) { | ||
| return { | ||
| id: parseInt(container.dataset.showSpinnerId, 10), | ||
| buildExtId: container.dataset.rerunBuildExtId, | ||
| dependencyIds: container.dataset.rerunBuildDependencyIds | ||
| .split(",") | ||
| .map(id => parseInt(id)) | ||
| }; | ||
| } | ||
|
|
||
| function parseTriggerAttributes(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(",") | ||
| .map(id => parseInt(id)) | ||
| }; | ||
| } | ||
|
|
||
| function handleDialogClick(dataContainer) { | ||
| const href = dataContainer.dataset.fillDialogHref; | ||
| const title = dataContainer.dataset.fillDialogTitle; | ||
| buildPipeline.fillDialog(href, title); | ||
| } | ||
|
|
||
| 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); | ||
| } | ||
|
|
||
| function createClickHandler(parentElement, targetSelector, handlerFn) { | ||
| const newHandler = function(event) { | ||
| const clickTarget = event.target.closest(targetSelector); | ||
| if (!clickTarget || !parentElement.contains(clickTarget)) return; | ||
|
|
||
| handlerFn(clickTarget); | ||
| }; | ||
|
|
||
| parentElement.addEventListener("click", newHandler); | ||
| } | ||
|
|
||
| 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 | ||
| } | ||
| }; | ||
|
|
||
| document.addEventListener("DOMContentLoaded", function () { | ||
| const pipelineWrappers = document.querySelectorAll(".pipeline-wrapper"); | ||
|
|
||
| if (!pipelineWrappers.length) return; | ||
|
|
||
| pipelineWrappers.forEach(wrapper => { | ||
| Object.entries(onclickElements).forEach(function([selector, { handler }]) { | ||
shlomomdahan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| createClickHandler(wrapper, selector, handler); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.