forked from maplesteve/JiraTestResultReporter
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-74233] Extract inline JavaScript from `JiraTestDataPublisher…
…/config.jelly` (#181)
- Loading branch information
1 parent
718fe35
commit 742d967
Showing
3 changed files
with
74 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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 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
55 changes: 55 additions & 0 deletions
55
...plugins/JiraTestResultReporter/JiraTestDataPublisher/jira-test-data-publisher-resource.js
This file contains 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,55 @@ | ||
function hideshow(which) { | ||
if (which.style.display == "block") { | ||
which.style.display = "none"; | ||
} else { | ||
which.style.display = "block"; | ||
} | ||
} | ||
|
||
function validateFieldConfigs(event) { | ||
event.preventDefault(); | ||
const button = event.target; | ||
const { descriptorProxyVarName } = button.dataset; | ||
/* | ||
Ugly hack part 1. See JiraTestDataPublisherDescriptor.validateFieldConfigs for part2. | ||
Since Jenkins does not offer a way to send the hetero-list for validation, I'm constructing | ||
the whole form and sending it. | ||
*/ | ||
const errorDiv = document.getElementById("JiraIssueConfigErrors"); | ||
const spinner = document.getElementById("jiraSpinner"); | ||
spinner.style.display = "inline"; | ||
const form = document.getElementsByName("config")[0]; | ||
buildFormTree(form); | ||
let jsonElement = null; | ||
for (let i = 0; i != form.elements.length; i++) { | ||
let e = form.elements[i]; | ||
if (e.name == "json") { | ||
jsonElement = e; | ||
break; | ||
} | ||
} | ||
|
||
const descriptor = window[descriptorProxyVarName]; | ||
const socketTimeout = setTimeout(function () { | ||
spinner.style.display = "none"; | ||
errorDiv.innerHTML = "Validation Failed: Socket Timeout. The issue was probably created, but the server did not respond in a timely manner. Please try again."; | ||
}, 30000); | ||
descriptor.validateFieldConfigs(jsonElement.value, function (rsp) { | ||
clearTimeout(socketTimeout); | ||
spinner.style.display = "none"; | ||
updateValidationArea(errorDiv, rsp.responseText); | ||
}); | ||
} | ||
|
||
window.addEventListener("DOMContentLoaded", () => { | ||
document.querySelectorAll(".validateJiraIssueConfig").forEach((button) => { | ||
button.addEventListener("click", validateFieldConfigs); | ||
}); | ||
|
||
document.querySelectorAll(".show-hide-jira-issue-config").forEach((icon) => { | ||
icon.addEventListener("click", (event) => { | ||
const container = event.target.closest(".jira-validate-issue-config-container"); | ||
hideshow(container.querySelector(".helpValidateJiraIssueConfig")); | ||
}); | ||
}); | ||
}); |