Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use responsive columns for all tables #1290

Merged
merged 8 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 3 additions & 48 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<plugin-util-api.version>2.17.0</plugin-util-api.version>
<pull-request-monitoring.version>1.7.8</pull-request-monitoring.version>
<prism-api.version>1.28.0-2</prism-api.version>
<data-tables-api.version>1.11.4-4</data-tables-api.version>
<data-tables-api.version>1.12.1-1</data-tables-api.version>

<eclipse-collections.version>9.2.0</eclipse-collections.version>

Expand Down Expand Up @@ -127,6 +127,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>data-tables-api</artifactId>
<version>${data-tables-api.version}</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
Expand Down Expand Up @@ -604,53 +605,7 @@
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<configuration>
<failBuildOnProblemsFound>true</failBuildOnProblemsFound>
<!-- Including provided-scope dependencies like Jenkins core results in too many false positives -->
<checkDependencies>false</checkDependencies>
<analysisConfiguration>
<revapi.ignore combine.children="append">
<item>
<regex>true</regex>
<code>java.field.serialVersionUIDUnchanged</code>
<classQualifiedName>io.jenkins.plugins.analysis.core.steps.*Step</classQualifiedName>
<justification>Serialization is only used in interprocess communication using the same classes
</justification>
</item>
<item>
<regex>true</regex>
<code>java.missing.*</code>
<justification>Dependencies are not being checked, so they are reported as missing</justification>
</item>
<item>
<code>java.annotation.added</code>
<annotationType>org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted</annotationType>
<justification>Annotation should be save to add.</justification>
</item>
<item>
<regex>true</regex>
<code>java.annotation.*</code>
<annotation>@edu.umd.cs.findbugs.annotations.*</annotation>
<justification>Annotation should be save to change.</justification>
</item>
<item>
<regex>true</regex>
<code>java.annotation.*</code>
<annotation>@org.kohsuke.stapler.*</annotation>
<justification>Annotation should be save to change.</justification>
</item>
<item>
<regex>true</regex>
<code>java.method.returnTypeChanged</code>
<methodName>getDescriptionProvider</methodName>
<justification>Return type must be part of the API.</justification>
</item>
<item>
<code>java.method.added</code>
<classSimpleName>Messages</classSimpleName>
<justification>Messages are now external API.</justification>
</item>
</revapi.ignore>
</analysisConfiguration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider.AgeBuilder;
import io.jenkins.plugins.analysis.core.util.Blame;
import io.jenkins.plugins.datatables.TableColumn;
import io.jenkins.plugins.datatables.TableColumn.ColumnBuilder;
import io.jenkins.plugins.datatables.TableColumn.ColumnCss;
import io.jenkins.plugins.forensics.blame.Blames;
import io.jenkins.plugins.forensics.util.CommitDecorator;
Expand All @@ -34,7 +35,6 @@
*/
public class BlamesModel extends DetailsTableModel {
static final String UNDEFINED = "-";
static final int UNDEFINED_DATE = 0;

private final Blames blames;
private final CommitDecorator commitDecorator;
Expand Down Expand Up @@ -67,11 +67,27 @@ public List<TableColumn> getColumns() {
columns.add(createDetailsColumn());
columns.add(createFileColumn());
columns.add(createAgeColumn());
columns.add(new TableColumn(Messages.Table_Column_Author(), "author"));
columns.add(new TableColumn(Messages.Table_Column_Email(), "email"));
columns.add(new TableColumn(Messages.Table_Column_Commit(), "commit"));
columns.add(new TableColumn(Messages.Table_Column_AddedAt(), "addedAt")
.setHeaderClass(ColumnCss.DATE));
TableColumn author = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Author())
.withDataPropertyKey("author")
.withResponsivePriority(1)
.build();
columns.add(author);
TableColumn email = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Email())
.withDataPropertyKey("email")
.withResponsivePriority(50)
.build();
columns.add(email);
TableColumn commit = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Commit())
.withDataPropertyKey("commit")
.withResponsivePriority(10)
.build();
columns.add(commit);
TableColumn addedAt = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_AddedAt())
.withDataPropertyKey("addedAt")
.withResponsivePriority(25)
.withHeaderClass(ColumnCss.DATE)
.build();
columns.add(addedAt);
columns.add(createHiddenDetailsColumn());

return columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider.AgeBuilder;
import io.jenkins.plugins.analysis.core.util.LocalizedSeverity;
import io.jenkins.plugins.datatables.DetailedCell;
import io.jenkins.plugins.datatables.TableColumn;
import io.jenkins.plugins.datatables.TableColumn.ColumnBuilder;
import io.jenkins.plugins.datatables.TableColumn.ColumnCss;
import io.jenkins.plugins.datatables.TableColumn.ColumnType;
import io.jenkins.plugins.datatables.TableConfiguration;
import io.jenkins.plugins.datatables.TableModel;
import io.jenkins.plugins.prism.Sanitizer;
import io.jenkins.plugins.util.JenkinsFacade;
Expand Down Expand Up @@ -55,10 +59,9 @@ public abstract class DetailsTableModel extends TableModel {
* @param jenkinsFacade
* Jenkins facade to replaced with a stub during unit tests
*/
protected DetailsTableModel(final Report report,
final FileNameRenderer fileNameRenderer,
final AgeBuilder ageBuilder,
final DescriptionProvider descriptionProvider, final JenkinsFacade jenkinsFacade) {
protected DetailsTableModel(final Report report, final FileNameRenderer fileNameRenderer,
final AgeBuilder ageBuilder, final DescriptionProvider descriptionProvider,
final JenkinsFacade jenkinsFacade) {
super();

this.report = report;
Expand All @@ -68,6 +71,13 @@ protected DetailsTableModel(final Report report,
this.jenkinsFacade = jenkinsFacade;
}

@Override
public TableConfiguration getTableConfiguration() {
TableConfiguration tableConfiguration = new TableConfiguration();
tableConfiguration.responsive();
return tableConfiguration;
}

protected JenkinsFacade getJenkinsFacade() {
return jenkinsFacade;
}
Expand Down Expand Up @@ -103,25 +113,48 @@ public List<Object> getRows() {
}

protected TableColumn createDetailsColumn() {
return new TableColumn(Messages.Table_Column_Details(), "description").setHeaderClass(ColumnCss.NO_SORT);
return new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Details())
.withDataPropertyKey("description")
.withResponsivePriority(1)
.withHeaderClass(ColumnCss.NO_SORT)
.build();
}

protected TableColumn createHiddenDetailsColumn() {
return new TableColumn("Hiddendetails", "message")
.setHeaderClass(ColumnCss.HIDDEN)
.setWidth(0);
return new ColumnBuilder().withHeaderLabel("Hiddendetails")
.withDataPropertyKey("message")
.withHeaderClass(ColumnCss.HIDDEN)
.build();
}

protected TableColumn createFileColumn() {
return new TableColumn(Messages.Table_Column_File(), "fileName", "string");
return new ColumnBuilder().withHeaderLabel(Messages.Table_Column_File())
.withDataPropertyKey("fileName")
.withResponsivePriority(1)
.withDetailedCell()
.build();
}

protected TableColumn createAgeColumn() {
return new TableColumn(Messages.Table_Column_Age(), "age").setHeaderClass(ColumnCss.NUMBER);
return new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Age())
.withDataPropertyKey("age")
.withType(ColumnType.NUMBER)
.withResponsivePriority(10)
.build();
}

protected TableColumn createSeverityColumn() {
return new TableColumn(Messages.Table_Column_Severity(), "severity");
return new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Severity())
.withDataPropertyKey("severity")
.withResponsivePriority(5)
.build();
}

protected TableColumn createPackageColumn() {
return new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Package())
.withDataPropertyKey("packageName")
.withResponsivePriority(50_000)
.build();
}

/**
Expand All @@ -143,7 +176,7 @@ public static class TableRow {

private final String description;
private final String message;
private final DetailedColumnDefinition fileName;
private final DetailedCell<String> fileName;
private final String age;
private final JenkinsFacade jenkinsFacade;

Expand All @@ -161,10 +194,8 @@ public static class TableRow {
* @param jenkinsFacade
* Jenkins facade to replaced with a stub during unit tests
*/
protected TableRow(final AgeBuilder ageBuilder,
final FileNameRenderer fileNameRenderer,
final DescriptionProvider descriptionProvider,
final Issue issue,
protected TableRow(final AgeBuilder ageBuilder, final FileNameRenderer fileNameRenderer,
final DescriptionProvider descriptionProvider, final Issue issue,
final JenkinsFacade jenkinsFacade) {
this.jenkinsFacade = jenkinsFacade;
message = render(issue.getMessage());
Expand All @@ -173,8 +204,8 @@ protected TableRow(final AgeBuilder ageBuilder,
fileName = createFileName(fileNameRenderer, issue);
}

private DetailedColumnDefinition createFileName(final FileNameRenderer fileNameRenderer, final Issue issue) {
return new DetailedColumnDefinition(fileNameRenderer.renderAffectedFileLink(issue),
private DetailedCell<String> createFileName(final FileNameRenderer fileNameRenderer, final Issue issue) {
return new DetailedCell<>(fileNameRenderer.renderAffectedFileLink(issue),
String.format("%s:%07d", issue.getFileName(), issue.getLineStart()));
}

Expand Down Expand Up @@ -262,7 +293,7 @@ public String getMessage() {
return message;
}

public DetailedColumnDefinition getFileName() {
public DetailedCell<String> getFileName() {
return fileName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider.AgeBuilder;
import io.jenkins.plugins.datatables.TableColumn;
import io.jenkins.plugins.datatables.TableColumn.ColumnBuilder;
import io.jenkins.plugins.datatables.TableColumn.ColumnCss;
import io.jenkins.plugins.datatables.TableColumn.ColumnType;
import io.jenkins.plugins.forensics.miner.FileStatistics;
import io.jenkins.plugins.forensics.miner.RepositoryStatistics;
import io.jenkins.plugins.util.JenkinsFacade;
Expand Down Expand Up @@ -64,22 +66,45 @@ public List<TableColumn> getColumns() {
List<TableColumn> columns = new ArrayList<>();

columns.add(createDetailsColumn());
columns.add(createFileColumn().setWidth(2));
columns.add(createFileColumn());
columns.add(createAgeColumn());
columns.add(new TableColumn(Messages.Table_Column_AuthorsSize(), "authorsSize")
.setHeaderClass(ColumnCss.NUMBER));
columns.add(new TableColumn(Messages.Table_Column_CommitsSize(), "commitsSize")
.setHeaderClass(ColumnCss.NUMBER));
columns.add(new TableColumn(Messages.Table_Column_LastCommit(), "modifiedAt")
.setWidth(2)
.setHeaderClass(ColumnCss.DATE));
columns.add(new TableColumn(Messages.Table_Column_AddedAt(), "addedAt")
.setWidth(2)
.setHeaderClass(ColumnCss.DATE));
columns.add(new TableColumn(Messages.Table_Column_LOC(), "linesOfCode")
.setHeaderClass(ColumnCss.NUMBER));
columns.add(new TableColumn(Messages.Table_Column_Churn(), "churn")
.setHeaderClass(ColumnCss.NUMBER));

TableColumn authorsSize = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_AuthorsSize())
.withDataPropertyKey("authorsSize")
.withResponsivePriority(1)
.withType(ColumnType.NUMBER)
.build();
columns.add(authorsSize);
TableColumn commitsSize = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_CommitsSize())
.withDataPropertyKey("commitsSize")
.withResponsivePriority(1)
.withType(ColumnType.NUMBER)
.build();
columns.add(commitsSize);
TableColumn modifiedAt = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_LastCommit())
.withDataPropertyKey("modifiedAt")
.withResponsivePriority(50)
.withHeaderClass(ColumnCss.DATE)
.build();
columns.add(modifiedAt);
TableColumn addedAt = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_AddedAt())
.withDataPropertyKey("addedAt")
.withResponsivePriority(50)
.withHeaderClass(ColumnCss.DATE)
.build();
columns.add(addedAt);
TableColumn linesOfCode = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_LOC())
.withDataPropertyKey("linesOfCode")
.withResponsivePriority(25)
.withType(ColumnType.NUMBER)
.build();
columns.add(linesOfCode);
TableColumn churn = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Churn())
.withDataPropertyKey("churn")
.withResponsivePriority(25)
.withType(ColumnType.NUMBER)
.build();
columns.add(churn);
columns.add(createHiddenDetailsColumn());

return columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider.AgeBuilder;
import io.jenkins.plugins.datatables.TableColumn;
import io.jenkins.plugins.datatables.TableColumn.ColumnBuilder;
import io.jenkins.plugins.util.JenkinsFacade;

/**
Expand Down Expand Up @@ -53,13 +54,21 @@ public List<TableColumn> getColumns() {
columns.add(createDetailsColumn());
columns.add(createFileColumn());
if (getReport().hasPackages()) {
columns.add(new TableColumn(Messages.Table_Column_Package(), "packageName").setWidth(2));
columns.add(createPackageColumn());
}
if (getReport().hasCategories()) {
columns.add(new TableColumn(Messages.Table_Column_Category(), "category"));
TableColumn category = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Category())
.withDataPropertyKey("category")
.withResponsivePriority(100)
.build();
columns.add(category);
}
if (getReport().hasTypes()) {
columns.add(new TableColumn(Messages.Table_Column_Type(), "type"));
TableColumn type = new ColumnBuilder().withHeaderLabel(Messages.Table_Column_Type())
.withDataPropertyKey("type")
.withResponsivePriority(1000)
.build();
columns.add(type);
}
columns.add(createSeverityColumn());
columns.add(createAgeColumn());
Expand Down
Loading