Skip to content

Commit 86cdf4e

Browse files
authored
API for hidding delayed errors (#228)
* API for hidding delayed errors * Show job UI only when visible error available
1 parent f7fc17a commit 86cdf4e

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/errors/GitHubError.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ public GitHubError(@Nonnull String description) {
2020
@Nonnull
2121
public abstract String getTitle();
2222

23+
/**
24+
* Whether to show error on job page. Useful when error visibility will be known after delay.
25+
*/
26+
public boolean isVisible() {
27+
return true;
28+
}
29+
2330
/**
2431
* Raw displayed html content as description.
2532
*/

github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/errors/GitHubErrorsAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ public GitHubErrorsAction(@Nonnull String description) {
2323
this.description = description;
2424
}
2525

26+
public boolean hasVisibleErrors() {
27+
boolean hasVisible = false;
28+
for (GitHubError error : errors) {
29+
if (error.isVisible()) {
30+
hasVisible = true;
31+
break;
32+
}
33+
}
34+
return hasVisible;
35+
}
36+
2637
@Nonnull
2738
public String getDescription() {
2839
return description;

github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/generic/errors/GitHubErrorsAction/jobMain.groovy

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
package com.github.kostyasha.github.integration.generic.errors.GitHubErrorsAction
22

3-
import com.github.kostyasha.github.integration.generic.errors.GitHubError
4-
import lib.FormTagLib
5-
import lib.LayoutTagLib
6-
7-
def f = namespace(FormTagLib);
8-
def l = namespace(LayoutTagLib);
93
def t = namespace("/lib/hudson")
104
def st = namespace("jelly:stapler");
11-
def j = namespace("jelly:core");
125

13-
if (!from?.errors?.isEmpty()) {
6+
if (from?.hasVisibleErrors()) {
147
// indent like in hudson/model/AbstractProject/main.jelly
158
table(style: "margin-left:1em;") {
169
t.summary(icon: "warning.png") {
1710
b(from.description)
1811
br()
1912
from.getErrorsSnapshot().eachWithIndex() { error, index ->
20-
b(++index + " " + error.title)
21-
div(style: "margin-left:2em") {
22-
raw(error.getHtmlDescription())
13+
if (error.isVisible()) {
14+
b(++index + " " + error.title)
15+
div(style: "margin-left:2em") {
16+
raw(error.getHtmlDescription())
17+
}
18+
st.include(page: "index.jelly", it: error, optional: true)
2319
}
24-
st.include(page: "index.jelly", it: error, optional: true)
2520
}
2621
}
2722
}

0 commit comments

Comments
 (0)