Skip to content

Commit

Permalink
Make styles work
Browse files Browse the repository at this point in the history
Note, that this contains breaking experimental showcase change, and do
not honour previous colouring setup (due to possible multiple values in
cell)
  • Loading branch information
judovana committed Apr 16, 2024
1 parent a600f22 commit df848f4
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ public static void compareTraces(Map<String, ArrayList<String>> failedMap, Optio
stringToPut = String.valueOf(getTraceSimilarity(reference, second));
}

table[i][jobBuilds.indexOf(value) + 1] =
options.getFormatter().createCell(new JtregPluginServicesLinkWithTooltip(stringToPut));
List<JtregPluginServicesLinkWithTooltip> maybeSeveralComaprisons = new ArrayList<>();
maybeSeveralComaprisons.add(new JtregPluginServicesLinkWithTooltip(stringToPut, null, getLinksTooltip(), true));
//this is just demo
//FIXME repace by real logic

Check warning on line 100 in report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/StackTraceCompare.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

FIXME

HIGH: repace by real logic
if ((jobBuilds.indexOf(value) + i + 1 )%2 == 0){
maybeSeveralComaprisons.add(new JtregPluginServicesLinkWithTooltip("X", "test", getLinksTooltip(), true));
}
table[i][jobBuilds.indexOf(value) + 1] = options.getFormatter().createCell(maybeSeveralComaprisons);
}

// TODO delete, just for debug logging

Check warning on line 107 in report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/StackTraceCompare.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: delete, just for debug logging
Expand All @@ -108,6 +114,15 @@ public static void compareTraces(Map<String, ArrayList<String>> failedMap, Optio
options.getFormatter().printTable(table, failedTests.size() + 1, jobBuilds.size() + 1);
}

private static List<JtregPluginServicesLinkWithTooltip> getLinksTooltip() {
List<JtregPluginServicesLinkWithTooltip> list = new ArrayList<>();
list.add(new JtregPluginServicesLinkWithTooltip("this is tool tip of comparison of $TEST trace of $job1:$X x $job2:$Y"));
list.add(new JtregPluginServicesLinkWithTooltip("use this as base", "some link", null));
list.add(new JtregPluginServicesLinkWithTooltip("show diff agaisnt base", "some otjer link", null));
list.add(new JtregPluginServicesLinkWithTooltip("show diff ind ifferent setup", "other link", null));
return list;
}

private static String getTestTrace(File build, String testName, Options.Side cutSide, int cutLength) {
try {
BuildReportExtended bex = bs.parseBuildReportExtended(new RunWrapperFromDir(build), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public void testHtmlTablePrinting() {
f.printTable(table, 4, 4);

Assertions.assertEquals("<style>\n" +
".tooltip {\n" + " position: relative;\n" + " display: inline-block;\n" + "}\n" + ".tooltip .tooltiptext {\n"
+ " visibility: hidden;\n" + " width: 240px;\n" + " background-color: grey;\n" + " color: #fff;\n"
+ " text-align: left;\n" + " border-radius: 6px;\n" + " padding: 5px 0;\n" + " /* Position the tooltip */\n"
+ " position: absolute;\n" + " z-index: 1;\n" + " top: 100%;\n" + " left: 50%;\n" + " margin-left: -60px;}\n"
+ ".tooltip:hover .tooltiptext {\n" + " visibility: visible;\n" + "}\n" +
".contents {\n" +
" font-family: monospace, monospace;\n" +
"}\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ final public class Constants {
public static final int VAGUE_QUERY_LENGTH_THRESHOLD = 4;
public static final String COMPARATOR_TABLE_CSS =
"<style>\n" +
".tooltip {\n" +
" position: relative;\n" +
" display: inline-block;\n" +
"}\n" +
".tooltip .tooltiptext {\n" +
" visibility: hidden;\n" +
" width: 240px;\n" +
" background-color: grey;\n" +
" color: #fff;\n" +
" text-align: left;\n" +
" border-radius: 6px;\n" +
" padding: 5px 0;\n" +
" /* Position the tooltip */\n" +
" position: absolute;\n" +
" z-index: 1;\n" +
" top: 100%;\n" +
" left: 50%;\n" +
" margin-left: -60px;" +
"}\n" +
".tooltip:hover .tooltiptext {\n" +
" visibility: visible;\n" +
"}\n" +
".contents {\n" +
" font-family: monospace, monospace;\n" +
"}\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ public void printTable(JtregPluginServicesCell[][] table, int rowSize, int colum
// Xs will be red
} else if (table[i][j].contentEquals("X")) {
super.print(Red + table[i][j].renderCell() + ResetAll + " ");
} else if (table[i][j].contentMatches("^[1-9]?[0-9]$|^100$")) {
}
//this will need to be redone per-item
//JtregPluginServicesCell currently do not have method for that, but should be easy to do
else if (table[i][j].contentMatches("^[1-9]?[0-9]$|^100$")) {
// the table is displaying numbers from 0-100 (percentage), color code them
int number = Integer.parseInt(table[i][j].getCellContent());
if (number == 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ public void printTable(JtregPluginServicesCell[][] table, int rowSize, int colum
if (table[i][j] != null) {
if (table[i][j].contentEquals("X")) {
super.println("<td>" + table[i][j].renderCell() + "</td>");
} else if (table[i][j].contentMatches("^[1-9]?[0-9]$|^100$")) {

}
//this will need to be redone per-item
//JtregPluginServicesCell currently do not have method for that, but should be easy to do
else if (table[i][j].contentMatches("^[1-9]?[0-9]$|^100$")) {
// the table is displaying numbers from 0-100 (percentage), color code them
int number = Integer.parseInt(table[i][j].getCellContent());
if (number == 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
import java.util.Collections;
import java.util.List;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* todo, replace dummy content by formatting + text?
* todo replace by interface and have formatter based cell?
*
* todo, rmeove the SuppressWarnings once all ewuals and hashes are identified and fixed
*/

public class JtregPluginServicesCell {

private final List<JtregPluginServicesLinkWithTooltip> content;
Expand Down Expand Up @@ -46,7 +39,7 @@ public String getCellContent() {
}

public String toString() {
throw new RuntimeException("remove usage in favour of renderCell() (or getCellContent)");
return renderCell();
}

public int cellWidth() {
Expand All @@ -63,7 +56,7 @@ public int contetntHashCode() {
return getCellContent().hashCode();
}
public int hashCode() {
throw new RuntimeException("remove usage in favour of contetntHashCode()");
return contetntHashCode();
}

/**
Expand All @@ -74,9 +67,8 @@ public boolean contentEquals(Object obj) {
return getCellContent().equals(obj);
}

@SuppressFBWarnings({"EQ_UNUSUAL"})
public boolean equals(Object obj) {
throw new RuntimeException("remove usage in favour of contentEquals()");
return contentEquals(obj);
}

public boolean contentMatches(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ public String render() {
sb.append(" ");
}
}
sb.append("<span>\n");
sb.append("</span>\n");
}
if (!tooltips.isEmpty()) {
sb.append("<div>\n");
sb.append("</div>\n");
}
return sb.toString();
}
Expand Down

0 comments on commit df848f4

Please sign in to comment.