Skip to content

Commit

Permalink
simplify/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomomdahan committed Nov 25, 2024
1 parent fd147b5 commit 0a748ce
Showing 1 changed file with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 () {
Expand All @@ -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);
});
});
});
});

0 comments on commit 0a748ce

Please sign in to comment.