Skip to content

Commit

Permalink
Merge pull request #1119 from jenkinsci/info-messaages
Browse files Browse the repository at this point in the history
Use new messages dialog and improve associated icon link
  • Loading branch information
uhafner authored Nov 21, 2021
2 parents d90b48c + ba01d6b commit a396d74
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 28 deletions.
4 changes: 3 additions & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

<data-tables-api.version>1.11.3-4</data-tables-api.version>
<echarts-api.version>5.2.2-1</echarts-api.version>
<bootstrap5-api.version>5.1.3-2</bootstrap5-api.version>
<bootstrap5-api.version>5.1.3-3</bootstrap5-api.version>
<font-awesome-api.version>5.15.4-3</font-awesome-api.version>
<error_prone_annotations.version>2.9.0</error_prone_annotations.version>
<pull-request-monitoring.version>1.7.8</pull-request-monitoring.version>

Expand Down Expand Up @@ -120,6 +121,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>font-awesome-api</artifactId>
<version>${font-awesome-api.version}</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.jenkins.plugins.analysis.core.util.BuildFolderFacade;
import io.jenkins.plugins.analysis.core.util.ConsoleLogHandler;
import io.jenkins.plugins.analysis.core.util.LocalizedSeverity;
import io.jenkins.plugins.bootstrap5.MessagesViewModel;
import io.jenkins.plugins.util.JenkinsFacade;

/**
Expand Down Expand Up @@ -157,8 +158,9 @@ private Object createNewDetailView(final String link, final Run<?, ?> owner, fin
EMPTY, Messages.Outstanding_Warnings_Header(), url, labelProvider, sourceEncoding);
}
if ("info".equalsIgnoreCase(link)) {
return new InfoErrorDetail(owner, result.getErrorMessages(), result.getInfoMessages(),
labelProvider.getName());
return new MessagesViewModel(owner, labelProvider.getName(),
result.getInfoMessages().castToList(),
result.getErrorMessages().castToList());
}
for (Severity severity : Severity.getPredefinedValues()) {
if (severity.getName().equalsIgnoreCase(link)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
* Result object to visualize the logging messages and errors during a static analysis run.
*
* @author Ullrich Hafner
* @deprecated moved to Bootstrap 5 API plugin
*/
@SuppressWarnings("PMD.DataClass")
@Deprecated
public class InfoErrorDetail implements ModelObject {
private final Run<?, ?> owner;
private final ImmutableList<String> errorMessages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@
</j:if>
</j:choose>
</span>
<a id="${it.id}-info" href="${it.id}/info">
<j:choose>
<j:when test="${size(s.errors) > 0}">
<fa:svg-icon name="exclamation-triangle" class="info-page-decorator"
tooltip="${%Click to open details view to see all error messages}"/>
</j:when>
<j:otherwise>
<fa:svg-icon name="info-circle" class="info-page-decorator"
tooltip="${%Click to open details view to see all information messages}"/>
</j:otherwise>
</j:choose>
</a>

<j:choose>
<j:when test="${size(s.errors) > 0}">
<fa:image-button label="${%Open log messages}" name="exclamation-triangle" tooltip="${%icon.error.tooltip}" url="${it.id}/info" class="fa-image-button-warning"/>
</j:when>
<j:otherwise>
<fa:image-button label="${%Open error messages}" name="info-circle" tooltip="${%icon.info.tooltip}" url="${it.id}/info"/>
</j:otherwise>
</j:choose>

<ul id="${it.id}-details">
<j:if test="${size(s.tools) > 1}">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
icon.error.tooltip=Some errors have been logged during recording, click to see these errors in a details view.
icon.info.tooltip=Click to see all logging messages during recording.
8 changes: 0 additions & 8 deletions plugin/src/main/webapp/css/custom-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
width: 200px;
}

.info-page-decorator {
fill: #b4b4b4;
height: 16px;
width: 16px;
vertical-align: text-bottom;
margin-left: 0.2em;
}

/* ------------------------------------------------------------------------------------------------------------------- */

/* Bar graph in table */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import io.jenkins.plugins.analysis.core.util.BuildFolderFacade;
import io.jenkins.plugins.analysis.core.util.ConsoleLogHandler;
import io.jenkins.plugins.bootstrap5.MessagesViewModel;
import io.jenkins.plugins.util.JenkinsFacade;

import static io.jenkins.plugins.analysis.core.testutil.Assertions.*;
Expand Down Expand Up @@ -154,9 +155,9 @@ private void assertThatPrioritiesAreFiltered(final IssuesDetail details, final S

@Test
void shouldReturnInfoErrorDetailWhenCalledWithInfoLink() {
InfoErrorDetail details = createTrendDetails("info", RUN, createResult(),
MessagesViewModel details = createTrendDetails("info", RUN, createResult(),
ALL_ISSUES, NEW_ISSUES, OUTSTANDING_ISSUES, FIXED_ISSUES, ENCODING, createParent(),
InfoErrorDetail.class);
MessagesViewModel.class);
assertThat(details.getErrorMessages()).containsExactly(ERROR_MESSAGES);
assertThat(details.getDisplayName()).contains(PARENT_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.jenkins.plugins.analysis.core.model;

import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.impl.factory.Lists;
import org.junit.jupiter.api.Test;

import hudson.model.Run;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;

/**
* Tests the class {@link InfoErrorDetail}.
*
* @author Ullrich Hafner
*/
class InfoErrorDetailTest {
private static final String TITLE = "Title";
private static final String DISPLAY_NAME = TITLE + " - Messages";
private static final ImmutableList<String> INFO_MESSAGES = Lists.immutable.of("One", "Two");
private static final ImmutableList<String> ERROR_MESSAGES = Lists.immutable.of("Error One", "Error Two");

@Test
void shouldCreateMessagesAndErrors() {
Run<?, ?> build = mock(Run.class);
InfoErrorDetail model = new InfoErrorDetail(build, ERROR_MESSAGES, INFO_MESSAGES, TITLE);

assertThat(model.getDisplayName()).isEqualTo(DISPLAY_NAME);
assertThat(model.getOwner()).isSameAs(build);
assertThat(model.getInfoMessages()).containsExactlyElementsOf(INFO_MESSAGES);
assertThat(model.getErrorMessages()).containsExactlyElementsOf(ERROR_MESSAGES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public AnalysisSummary(final Build parent, final String id) {
WebElement summary = getElement(By.id(id + "-summary"));
titleElement = summary.findElement(By.id(id + "-title"));

infoElement = summary.findElement(By.id(id + "-info"));
hasErrorIcon = infoElement.getText().contains("error messages");
infoElement = summary.findElement(By.className("fa-image-button"));
hasErrorIcon = !infoElement.findElements(By.className("fa-image-button-warning")).isEmpty();
results = summary.findElements(by.xpath("ul[@id='" + id + "-details']/li"));
}

Expand Down Expand Up @@ -307,7 +307,7 @@ public String findResultEntryTextByNamePart(final String namePart) {
* Determines which icon is shown to represent the info messages view.
*/
public enum InfoType {
INFO, ERROR;
INFO, ERROR
}

/**
Expand Down

0 comments on commit a396d74

Please sign in to comment.