Skip to content

Commit

Permalink
update names, update java method, all working
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomomdahan committed Oct 30, 2024
1 parent ed0c9e5 commit 30476d5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
};

Expand All @@ -45,7 +46,6 @@ const handleTriggerBuild = (dataContainer) => {
};

const createDelegatedHandler = (parentSelector, targetSelector, handlerFn, existingHandler) => {

const parentElement = document.querySelector(parentSelector);

if (existingHandler) {
Expand All @@ -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);
};

Expand All @@ -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
);
}
);
Expand All @@ -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
);
Expand All @@ -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
);
}
);
Expand All @@ -143,7 +159,7 @@ Behaviour.specify(
'.pipelines',
'.bct-trigger-manual-build-latest-onclick',
handleTriggerBuild,
triggerBuildHandler
triggerManualBuildLatestHandler
);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
{{#unless project.disabled}}
<div class="status-bar" id="status-bar-{{id}}">
{{#if build.isBuilding}}
<span class="bct-progress-console-onclick-params" data-fill-dialog-href="${app.rootUrl}{{build.url}}console" data-fill-dialog-title="Console output for {{project.name}} #{{build.number}}" style="display:none"/>
<div class="bct-progress-console-onclick">
<span class="bct-progress-bar-onclick-params" data-fill-dialog-href="${app.rootUrl}{{build.url}}console" data-fill-dialog-title="Console output for {{project.name}} #{{build.number}}" style="display:none"/>
<div class="bct-progress-bar-onclick">
<table class="progress-bar" align="center">
<tbody>
<tr title="Estimated remaining time: {{build.estimatedRemainingTime}}">
Expand Down Expand Up @@ -108,11 +108,10 @@
{{#if build.isSuccess}}
{{#if ${!it.triggerOnlyLatestJob}}}
<j:if test="${it.hasBuildPermission()}">
<span class="bct-rerun-success-icon-onclick-params" data-show-spinner-id="{{id}}" data-rerun-build-ext-id="{{build.extId}}" data-rerun-build-dependency-ids="{{build.dependencyIds}}" style="display: none;" />
<span class="bct-rerun-success-icon-onclick">
<span class="bct-rerun-successful-build-onclick-params" data-show-spinner-id="{{id}}" data-rerun-build-ext-id="{{build.extId}}" data-rerun-build-dependency-ids="{{build.dependencyIds}}" style="display: none;" />
<span class="bct-rerun-successful-build-onclick">
<l:icon src="icon-clock icon-sm" alt="re-run" />
</span>
<h1>test1</h1>
</j:if>
{{/if}}
{{else}}
Expand All @@ -123,21 +122,19 @@
<span class="bct-rerun-failed-latest-build-onclick">
<l:icon src="icon-clock icon-sm" alt="retry" />
</span>
<h1>test2</h1>
{{/if}}
{{/if}}
{{else}}
{{#if build.isManual}}
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.triggerBuild({{id}}, '{{upstream.projectName}}', {{upstream.buildNumber}}, '{{project.name}}', [{{build.dependencyIds}}])">
{{#if build.isManualTrigger}}
<span class="bct-rerun-failed-manual-build-onclick-params" data-show-spinner-id="{{id}}" data-upstream-project-name="{{upstream.projectName}}" data-upstream-build-number="{{upstream.buildNumber}}" data-project-name="{{project.name}}" data-dependency-ids="{{build.dependencyIds}}" style="display: none;" />
<span class="bct-rerun-failed-manual-build-onclick">
<l:icon src="icon-clock icon-sm" alt="retry" />
<h1>test3</h1>
</span>
{{else}}
<span class="bct-rerun-failed-not-manual-build-onclick-params" data-show-spinner-id="{{id}}" data-rerun-build-ext-id="{{build.extId}}" data-rerun-build-dependency-ids="{{build.dependencyIds}}" style="display: none;" />
<span class="bct-rerun-failed-not-manual-build-onclick">
<span class="bct-rerun-failed-build-onclick-params" data-show-spinner-id="{{id}}" data-rerun-build-ext-id="{{build.extId}}" data-rerun-build-dependency-ids="{{build.dependencyIds}}" style="display: none;" />
<span class="bct-rerun-failed-build-onclick">
<l:icon src="icon-clock icon-sm" alt="retry" />
</span>
<h1>test4</h1>
{{/if}}
{{/if}}
{{/if}}
Expand All @@ -150,15 +147,12 @@
<span class="bct-trigger-manual-build-latest-onclick">
<l:icon src="icon-clock icon-sm" alt="trigger" />
</span>
<h1>test5</h1>
{{/if}}
{{else}}

<span class="bct-trigger-manual-build-onclick-params" data-show-spinner-id="{{id}}" data-upstream-project-name="{{upstream.projectName}}" data-upstream-build-number="{{upstream.buildNumber}}" data-project-name="{{project.name}}" data-dependency-ids="{{build.dependencyIds}}" style="display: none;" />
<span class="bct-trigger-manual-build-onclick">
<l:icon src="icon-clock icon-sm" alt="trigger" />
</span>
<h1>test6</h1>
{{/if}}
{{/if}}
</div>
Expand Down

0 comments on commit 30476d5

Please sign in to comment.