Skip to content

Commit

Permalink
fix: 机器人配置测试时 js 报错
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL committed Sep 10, 2022
1 parent da0fd02 commit 73ebe79
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<version>2.4.10-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.346.3</jenkins.version>
<jenkins.version>2.361.1</jenkins.version>
<java.level>8</java.level>
<plugin.minimumJavaVersion>8</plugin.minimumJavaVersion>
<hpi.compatibleSinceVersion>2.0.0</hpi.compatibleSinceVersion>
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/io/jenkins/plugins/DingTalkRobotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ public FormValidation doTest(
String rootUrl = Jenkins.get().getRootUrl();
return FormValidation.respond(
Kind.OK,
"<img src='"
+ rootUrl
+ "/images/16x16/accept.png'>"
+ "<span style='padding-left:4px;color:#52c41a;font-weight:bold;'>测试成功</span>");
"<span style='color:#52c41a;font-weight:bold;'>测试成功</span>");
}
return FormValidation.error(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,5 @@
data-validate-button-with="${with}"
/>
</div>

</div>


</j:jelly>
20 changes: 20 additions & 0 deletions src/main/webapp/scripts/robotConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
$(document).on('click', '.robot-config-validate-btn', validateRobotConfig)
})

function applyErrorMessage(elt, rsp) {
if (rsp.status == 200) {
elt.innerHTML = rsp.responseText;
} else {
var id = 'valerr' + (iota++);
elt.innerHTML = '<a href="" onclick="document.getElementById(\'' + id
+ '\').style.display=\'block\';return false">ERROR</a><div id="'
+ id + '" style="display:none">' + rsp.responseText + '</div>';
var error = document.getElementById('error-description'); // cf. oops.jelly
if (error) {
var div = document.getElementById(id);
while (div.firstElementChild) {
div.removeChild(div.firstElementChild);
}
div.appendChild(error);
}
}
Behaviour.applySubtree(elt);
}

function validateRobotConfig() {
var $btn = $(this)

Expand Down

0 comments on commit 73ebe79

Please sign in to comment.