Skip to content

Commit

Permalink
[JENKINS-71435] Make empty properties clickable (#1648)
Browse files Browse the repository at this point in the history
Change `DetailsTableModel` to display '-' for issues with blank properties.
  • Loading branch information
debayangg authored Jan 4, 2024
1 parent 018c572 commit 2a3c046
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected String formatSeverity(final Severity severity) {
}

/**
* Formats the text of the specified property column. T he text actually is a link to the UI representation of
* Formats the text of the specified property column. The text actually is a link to the UI representation of
* the property.
*
* @param property
Expand All @@ -258,7 +258,11 @@ protected String formatSeverity(final Severity severity) {
* @return the formatted column
*/
protected String formatProperty(final String property, final String value) {
return String.format("<a href=\"%s.%d/\">%s</a>", property, value.hashCode(), render(value));
String renderedValue = render(value);
if (StringUtils.isBlank(value)) {
renderedValue = "-";
}
return String.format("<a href=\"%s.%d/\">%s</a>", property, value.hashCode(), renderedValue);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ void shouldCreateSortableFileName() {
createExpectedFileName(issue), "/path/to/file-1:0000015");
}

@Test
void shouldReturnClickableProperties() {
try (IssueBuilder builder = new IssueBuilder()) {
builder.setCategory("");
Issue issue = builder.build();
TableRow model = createRow(issue);
assertThat(model.formatProperty("category", issue.getCategory()))
.isEqualTo("<a href=\"category.0/\">-</a>");
}
}

private TableRow createRow(final Issue issue) {
return new TableRow(createAgeBuilder(), createFileNameRenderer(), i -> DESCRIPTION, issue,
createJenkinsFacade());
Expand Down

0 comments on commit 2a3c046

Please sign in to comment.