The Unified and Autonomous Development Platform
Use simple PageableListView instead of DataTable for various report presentation
Robin Shena3937a8f8dc0
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/base.css b/server-core/src/main/java/io/onedev/server/web/page/base/base.cssindex f58bdbc7ce..b6ad945db2 100644--- a/server-core/src/main/java/io/onedev/server/web/page/base/base.css+++ b/server-core/src/main/java/io/onedev/server/web/page/base/base.css@@ -533,7 +533,7 @@ table.norecords {table.norecords thead {display: none;}-table.norecords tfoot td, div.norecords {+table.norecords tfoot td, div.norecords, td.norecords {background: url(/icon/empty.svg) no-repeat scroll center center;background-size: 240px 240px;border-top: none;diff --git a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.html b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.htmlindex e4669e0544..edba7249db 100644--- a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.html+++ b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.html@@ -11,30 +11,49 @@</div><div wicket:id="feedback" class="mt-3"></div></form>- <table wicket:id="files" class="files table"></table>+ <table wicket:id="filesContainer" class="files table">+ <tbody>+ <tr wicket:id="files">+ <td>+ <div class="file d-flex flex-wrap align-items-center">+ <a wicket:id="toggle" class="name mr-2"><wicket:svg href="arrow" class="icon"/> <span wicket:id="label" class="text-break"></span></a>+ <a wicket:id="view" title="Show violations in file view" class="mr-auto"><wicket:svg href="file" class="icon"/></a>+ <span wicket:id="numOfErrors" class="ml-2 text-muted"></span>+ <span wicket:id="numOfWarnings" class="ml-2 text-muted"></span>+ <span wicket:id="numOfInfos" class="ml-2 text-muted"></span>+ </div>+ <wicket:enclosure child="violations">+ <div class="violations mt-2">+ <div wicket:id="tooManyViolations" class="alert alert-notice alert-light-warning"></div>+ <div wicket:id="violations" class="violation d-flex px-3 py-2 rounded bg-hover-light">+ <svg wicket:id="icon" class="icon icon-sm mr-2 mt-1 flex-shrink-0"/>+ <div class="flex-grow-1">+ <div class="d-flex mb-1">+ <div wicket:id="message" class="message mr-auto"></div>+ <a wicket:id="range" title="Show position in file" class="range ml-3 text-nowrap"><span wicket:id="label"></span></a>+ </div>+ <a wicket:id="rule" title="Show all violations of this rule" class="rule link-gray font-size-sm"><span wicket:id="label" class="text-break"></span></a>+ </div>+ </div>+ </div>+ </wicket:enclosure>+ </td>+ </tr>+ </tbody>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="pagingNavigator" class="pt-5"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="noRecords"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ </table></div>- <wicket:fragment wicket:id="fileFrag">- <div class="file d-flex flex-wrap align-items-center">- <a wicket:id="toggle" class="name mr-2"><wicket:svg href="arrow" class="icon"/> <span wicket:id="label" class="text-break"></span></a>- <a wicket:id="view" title="Show violations in file view" class="mr-auto"><wicket:svg href="file" class="icon"/></a>- <span wicket:id="numOfErrors" class="ml-2 text-muted"></span>- <span wicket:id="numOfWarnings" class="ml-2 text-muted"></span>- <span wicket:id="numOfInfos" class="ml-2 text-muted"></span>- </div>- <wicket:enclosure child="violations">- <div class="violations mt-2">- <div wicket:id="tooManyViolations" class="alert alert-notice alert-light-warning"></div>- <div wicket:id="violations" class="violation d-flex px-3 py-2 rounded bg-hover-light">- <svg wicket:id="icon" class="icon icon-sm mr-2 mt-1 flex-shrink-0"/>- <div class="flex-grow-1">- <div class="d-flex mb-1">- <div wicket:id="message" class="message mr-auto"></div>- <a wicket:id="range" title="Show position in file" class="range ml-3 text-nowrap"><span wicket:id="label"></span></a>- </div>- <a wicket:id="rule" title="Show all violations of this rule" class="rule link-gray font-size-sm"><span wicket:id="label" class="text-break"></span></a>- </div>- </div>- </div>- </wicket:enclosure>- </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.java b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.javaindex dacfc256e1..3a1fd5d0aa 100644--- a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.java+++ b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleFilesPage.java@@ -2,7 +2,6 @@ package org.server.plugin.report.checkstyle;import java.io.Serializable;import java.util.ArrayList;-import java.util.Iterator;import java.util.List;import java.util.concurrent.atomic.AtomicBoolean;import java.util.stream.Collectors;@@ -16,24 +15,17 @@ import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.ajax.markup.html.form.AjaxButton;import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;-import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;-import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;import org.apache.wicket.feedback.FencedFeedbackPanel;+import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.form.TextField;import org.apache.wicket.markup.html.link.BookmarkablePageLink;import org.apache.wicket.markup.html.list.ListItem;import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.repeater.Item;+import org.apache.wicket.markup.html.list.PageableListView;import org.apache.wicket.model.AbstractReadOnlyModel;-import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;import org.apache.wicket.model.PropertyModel;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.eclipse.jgit.lib.FileMode;@@ -52,10 +44,10 @@ import io.onedev.server.util.patternset.PatternSet;import io.onedev.server.web.WebConstants;import io.onedev.server.web.ajaxlistener.ConfirmLeaveListener;import io.onedev.server.web.behavior.PatternSetAssistBehavior;-import io.onedev.server.web.component.datatable.OneDataTable;+import io.onedev.server.web.component.NoRecordsPlaceholder;+import io.onedev.server.web.component.pagenavigator.OnePagingNavigator;import io.onedev.server.web.page.project.blob.ProjectBlobPage;import io.onedev.server.web.page.project.blob.render.renderers.source.SourceRendererProvider;-import io.onedev.server.web.util.LoadableDetachableDataProvider;import io.onedev.server.web.util.SuggestionUtils;@SuppressWarnings("serial")@@ -63,26 +55,6 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {private static final String PARAM_FILE = "file";- private final IModel<List<ViolationFile>> filesModel = new LoadableDetachableModel<List<ViolationFile>>() {-- @Override- protected List<ViolationFile> load() {- if (filePatterns != null) {- List<ViolationFile> files = new ArrayList<>(getReportData().getViolationFiles().values());- if (filePatterns.isPresent()) {- Matcher matcher = new PathMatcher();- files = files.stream()- .filter(it->filePatterns.get().matches(matcher, it.getPath()))- .collect(Collectors.toList());- }- return files;- } else {- return new ArrayList<>();- }- }-- };-private String file;private Optional<PatternSet> filePatterns;@@ -91,7 +63,7 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {private Component feedback;- private DataTable<ViolationFile, Void> filesTable;+ private WebMarkupContainer filesContainer;private List<String> filePaths;@@ -105,7 +77,9 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {protected void onInitialize() {super.onInitialize();- filePaths = new ArrayList<>(getReportData().getViolationFiles().keySet());+ filePaths = getReportData().getViolationFiles().stream()+ .map(it->it.getPath())+ .collect(Collectors.toList());form = new Form<Void>("form");@@ -135,7 +109,7 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {pushState(target);parseFilePatterns();target.add(feedback);- target.add(filesTable);+ target.add(filesContainer);}});@@ -157,39 +131,57 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {pushState(target);parseFilePatterns();target.add(feedback);- target.add(filesTable);+ target.add(filesContainer);}});form.setOutputMarkupId(true);add(form);- List<IColumn<ViolationFile, Void>> columns = new ArrayList<>();+ parseFilePatterns();++ filesContainer = new WebMarkupContainer("filesContainer");+ filesContainer.setOutputMarkupId(true);+ add(filesContainer);- columns.add(new AbstractColumn<ViolationFile, Void>(Model.of("")) {+ PageableListView<ViolationFile> filesView;+ filesContainer.add(filesView = new PageableListView<ViolationFile>("files",+ new LoadableDetachableModel<List<ViolationFile>>() {@Override- public void populateItem(Item<ICellPopulator<ViolationFile>> cellItem,- String componentId, IModel<ViolationFile> rowModel) {- Fragment fragment = new Fragment(componentId, "fileFrag", CheckstyleFilesPage.this);- fragment.setOutputMarkupId(true);- cellItem.add(fragment);-- ViolationFile file = rowModel.getObject();+ protected List<ViolationFile> load() {+ if (filePatterns != null) {+ if (filePatterns.isPresent()) {+ Matcher matcher = new PathMatcher();+ return getReportData().getViolationFiles().stream()+ .filter(it->filePatterns.get().matches(matcher, it.getPath()))+ .collect(Collectors.toList());+ } else {+ return getReportData().getViolationFiles();+ }+ } else {+ return new ArrayList<>();+ }+ }++ }, WebConstants.PAGE_SIZE) {- AtomicBoolean showViolations = new AtomicBoolean(- filesTable.getCurrentPage() == 0 && cellItem.findParent(Item.class).getIndex() == 0);+ @Override+ protected void populateItem(ListItem<ViolationFile> item) {+ ViolationFile file = item.getModelObject();+ String filePath = file.getPath();+ AtomicBoolean showViolations = new AtomicBoolean(item.getIndex() == 0);AjaxLink<Void> toggleLink = new AjaxLink<Void>("toggle") {@Overridepublic void onClick(AjaxRequestTarget target) {showViolations.set(!showViolations.get());- target.add(fragment);+ target.add(item);}};- toggleLink.add(new Label("label", file.getPath()));+ toggleLink.add(new Label("label", filePath));toggleLink.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {@Override@@ -199,39 +191,39 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {}));- fragment.add(toggleLink);+ item.add(toggleLink);ProjectBlobPage.State state = new ProjectBlobPage.State();- state.blobIdent = new BlobIdent(getBuild().getCommitHash(), file.getPath(),+ state.blobIdent = new BlobIdent(getBuild().getCommitHash(), filePath,FileMode.REGULAR_FILE.getBits());state.problemReport = getReportName();PageParameters params = ProjectBlobPage.paramsOf(getProject(), state);- fragment.add(new BookmarkablePageLink<Void>("view", ProjectBlobPage.class, params));+ item.add(new BookmarkablePageLink<Void>("view", ProjectBlobPage.class, params));- fragment.add(new Label("numOfErrors", file.getNumOfErrors() + " errors")+ item.add(new Label("numOfErrors", file.getNumOfErrors() + " errors").setVisible(file.getNumOfErrors() != 0));- fragment.add(new Label("numOfWarnings", file.getNumOfWarnings() + " warnings")+ item.add(new Label("numOfWarnings", file.getNumOfWarnings() + " warnings").setVisible(file.getNumOfWarnings() != 0));- fragment.add(new Label("numOfInfos", file.getNumOfInfos() + " infos")+ item.add(new Label("numOfInfos", file.getNumOfInfos() + " infos").setVisible(file.getNumOfInfos() != 0));- fragment.add(new Label("tooManyViolations",+ item.add(new Label("tooManyViolations","Too many violations, displaying first " + MAX_VIOLATIONS_TO_DISPLAY) {@Overrideprotected void onConfigure() {super.onConfigure();setVisible(showViolations.get()- && rowModel.getObject().getViolations().size() > MAX_VIOLATIONS_TO_DISPLAY);+ && item.getModelObject().getViolations().size() > MAX_VIOLATIONS_TO_DISPLAY);}});- fragment.add(new ListView<Violation>("violations", new LoadableDetachableModel<List<Violation>>() {+ item.add(new ListView<Violation>("violations", new LoadableDetachableModel<List<Violation>>() {@Overrideprotected List<Violation> load() {- List<Violation> violations = rowModel.getObject().getViolations();+ List<Violation> violations = item.getModelObject().getViolations();if (violations.size() > MAX_VIOLATIONS_TO_DISPLAY)return violations.subList(0, MAX_VIOLATIONS_TO_DISPLAY);else@@ -248,7 +240,7 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {ProjectBlobPage.State state = new ProjectBlobPage.State();state.blobIdent = new BlobIdent(getBuild().getCommitHash(),- rowModel.getObject().getPath(), FileMode.REGULAR_FILE.getBits());+ filePath, FileMode.REGULAR_FILE.getBits());state.problemReport = getReportName();state.position = SourceRendererProvider.getPosition(violation.getRange());PageParameters params = ProjectBlobPage.paramsOf(getProject(), state);@@ -272,45 +264,12 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {}});- }-- });-- SortableDataProvider<ViolationFile, Void> dataProvider =- new LoadableDetachableDataProvider<ViolationFile, Void>() {-- @Override- public Iterator<? extends ViolationFile> iterator(long first, long count) {- if (getFiles().size() > first+count)- return getFiles().subList((int)first, (int)(first+count)).iterator();- else- return getFiles().subList((int)first, getFiles().size()).iterator();- }-- @Override- public long calcSize() {- return getFiles().size();- }-- @Override- public IModel<ViolationFile> model(ViolationFile object) {- String filePath = object.getPath();- return new LoadableDetachableModel<ViolationFile>() {-- @Override- protected ViolationFile load() {- return getReportData().getViolationFiles().get(filePath);- }-- };+ item.setOutputMarkupId(true);}- };- add(filesTable = new OneDataTable<ViolationFile, Void>("files", columns,- dataProvider, WebConstants.PAGE_SIZE, null));- filesTable.setOutputMarkupId(true);-- parseFilePatterns();+ });+ filesContainer.add(new OnePagingNavigator("pagingNavigator", filesView, null));+ filesContainer.add(new NoRecordsPlaceholder("noRecords", filesView));}private void pushState(AjaxRequestTarget target) {@@ -324,19 +283,9 @@ public class CheckstyleFilesPage extends CheckstyleReportPage {file = (String) data;parseFilePatterns();target.add(form);- target.add(filesTable);+ target.add(filesContainer);}- private List<ViolationFile> getFiles() {- return filesModel.getObject();- }-- @Override- protected void onDetach() {- filesModel.detach();- super.onDetach();- }-private void parseFilePatterns() {if (file != null) {try {diff --git a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleReportData.java b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleReportData.javaindex d2be5f2ce9..95be220eff 100644--- a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleReportData.java+++ b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleReportData.java@@ -26,9 +26,9 @@ public class CheckstyleReportData implements Serializable {private final List<CheckstyleViolation> violations;- private transient Map<String, ViolationFile> violationFiles;+ private transient List<ViolationFile> violationFiles;- private transient Map<String, ViolationRule> violationRules;+ private transient List<ViolationRule> violationRules;public CheckstyleReportData(List<CheckstyleViolation> violations) {this.violations = violations;@@ -38,14 +38,14 @@ public class CheckstyleReportData implements Serializable {return violations;}- public Map<String, ViolationFile> getViolationFiles() {+ public List<ViolationFile> getViolationFiles() {if (violationFiles == null) {- violationFiles = new LinkedHashMap<>();+ Map<String, ViolationFile> filesMap = new LinkedHashMap<>();for (CheckstyleViolation violation: violations) {- ViolationFile file = violationFiles.get(violation.getFile());+ ViolationFile file = filesMap.get(violation.getFile());if (file == null) {file = new ViolationFile(violation.getFile());- violationFiles.put(violation.getFile(), file);+ filesMap.put(violation.getFile(), file);}file.getViolations().add(new ViolationFile.Violation(violation.getSeverity(), violation.getMessage(),@@ -53,8 +53,8 @@ public class CheckstyleReportData implements Serializable {violation.getRule()));}- List<ViolationFile> fileList = new ArrayList<>(violationFiles.values());- for (ViolationFile file: fileList) {+ violationFiles = new ArrayList<>(filesMap.values());+ for (ViolationFile file: violationFiles) {file.getViolations().sort(new Comparator<ViolationFile.Violation>() {@Override@@ -64,7 +64,7 @@ public class CheckstyleReportData implements Serializable {});}- fileList.sort(new Comparator<ViolationFile>() {+ violationFiles.sort(new Comparator<ViolationFile>() {@Overridepublic int compare(ViolationFile o1, ViolationFile o2) {@@ -77,32 +77,27 @@ public class CheckstyleReportData implements Serializable {}});-- violationFiles.clear();-- for (ViolationFile file: fileList)- violationFiles.put(file.getPath(), file);}return violationFiles;}- public Map<String, ViolationRule> getViolationRules() {+ public List<ViolationRule> getViolationRules() {if (violationRules == null) {- violationRules = new LinkedHashMap<>();+ Map<String, ViolationRule> rulesMap = new LinkedHashMap<>();for (CheckstyleViolation violation: violations) {- ViolationRule rule = violationRules.get(violation.getRule());+ ViolationRule rule = rulesMap.get(violation.getRule());if (rule == null) {rule = new ViolationRule(violation.getRule(), violation.getSeverity());- violationRules.put(violation.getRule(), rule);+ rulesMap.put(violation.getRule(), rule);}rule.getViolations().add(new ViolationRule.Violation(violation.getMessage(), violation.getLine(),violation.getColumn(), violation.getFile()));}- List<ViolationRule> ruleList = new ArrayList<>(violationRules.values());+ violationRules = new ArrayList<>(rulesMap.values());- ruleList.sort(new Comparator<ViolationRule>() {+ violationRules.sort(new Comparator<ViolationRule>() {@Overridepublic int compare(ViolationRule o1, ViolationRule o2) {@@ -113,10 +108,6 @@ public class CheckstyleReportData implements Serializable {}});-- violationRules.clear();- for(ViolationRule rule: ruleList)- violationRules.put(rule.getName(), rule);}return violationRules;}diff --git a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.html b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.htmlindex dc6d2c1be2..33546c9c8d 100644--- a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.html+++ b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.html@@ -11,25 +11,44 @@</div><div wicket:id="feedback" class="mt-3"></div></form>- <table wicket:id="rules" class="rules table"></table>+ <table wicket:id="rulesContainer" class="rules table">+ <tbody>+ <tr wicket:id="rules">+ <td>+ <a wicket:id="toggle">+ <wicket:svg href="arrow" class="icon"/>+ <svg wicket:id="icon" class="icon icon-sm mr-1"/>+ <span wicket:id="label" class="text-break"></span>+ </a>+ <wicket:enclosure child="violations">+ <div class="violations mt-2">+ <div wicket:id="tooManyViolations" class="alert alert-notice alert-light-warning"></div>+ <div wicket:id="violations" class="violation px-3 py-2 rounded bg-hover-light">+ <div class="d-flex align-items-center mb-1">+ <div wicket:id="message" class="message mr-auto"></div>+ <a wicket:id="range" title="Show position in file" class="range ml-3 text-nowrap"><span wicket:id="label"></span></a>+ </div>+ <a wicket:id="file" title="Show all violations in this file" class="file link-gray font-size-sm"><span wicket:id="label" class="text-break"></span></a>+ </div>+ </div>+ </wicket:enclosure>+ </td>+ </tr>+ </tbody>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="pagingNavigator" class="pt-5"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="noRecords"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ </table></div>- <wicket:fragment wicket:id="ruleFrag">- <a wicket:id="toggle">- <wicket:svg href="arrow" class="icon"/>- <svg wicket:id="icon" class="icon icon-sm mr-1"/>- <span wicket:id="label" class="text-break"></span>- </a>- <wicket:enclosure child="violations">- <div class="violations mt-2">- <div wicket:id="tooManyViolations" class="alert alert-notice alert-light-warning"></div>- <div wicket:id="violations" class="violation px-3 py-2 rounded bg-hover-light">- <div class="d-flex align-items-center mb-1">- <div wicket:id="message" class="message mr-auto"></div>- <a wicket:id="range" title="Show position in file" class="range ml-3 text-nowrap"><span wicket:id="label"></span></a>- </div>- <a wicket:id="file" title="Show all violations in this file" class="file link-gray font-size-sm"><span wicket:id="label" class="text-break"></span></a>- </div>- </div>- </wicket:enclosure>- </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.java b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.javaindex 78ff45ad4d..c28b95c2e6 100644--- a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.java+++ b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/CheckstyleRulesPage.java@@ -2,7 +2,6 @@ package org.server.plugin.report.checkstyle;import java.io.Serializable;import java.util.ArrayList;-import java.util.Iterator;import java.util.List;import java.util.concurrent.atomic.AtomicBoolean;import java.util.stream.Collectors;@@ -16,24 +15,17 @@ import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.ajax.markup.html.form.AjaxButton;import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;-import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;-import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;import org.apache.wicket.feedback.FencedFeedbackPanel;+import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.form.TextField;import org.apache.wicket.markup.html.link.BookmarkablePageLink;import org.apache.wicket.markup.html.list.ListItem;import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.repeater.Item;+import org.apache.wicket.markup.html.list.PageableListView;import org.apache.wicket.model.AbstractReadOnlyModel;-import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;import org.apache.wicket.model.PropertyModel;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.eclipse.jgit.lib.FileMode;@@ -52,10 +44,10 @@ import io.onedev.server.util.patternset.PatternSet;import io.onedev.server.web.WebConstants;import io.onedev.server.web.ajaxlistener.ConfirmLeaveListener;import io.onedev.server.web.behavior.PatternSetAssistBehavior;-import io.onedev.server.web.component.datatable.OneDataTable;+import io.onedev.server.web.component.NoRecordsPlaceholder;+import io.onedev.server.web.component.pagenavigator.OnePagingNavigator;import io.onedev.server.web.page.project.blob.ProjectBlobPage;import io.onedev.server.web.page.project.blob.render.renderers.source.SourceRendererProvider;-import io.onedev.server.web.util.LoadableDetachableDataProvider;import io.onedev.server.web.util.SuggestionUtils;@SuppressWarnings("serial")@@ -63,26 +55,6 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {private static final String PARAM_RULE = "rule";- private final IModel<List<ViolationRule>> rulesModel = new LoadableDetachableModel<List<ViolationRule>>() {-- @Override- protected List<ViolationRule> load() {- if (rulePatterns != null) {- List<ViolationRule> rules = new ArrayList<>(getReportData().getViolationRules().values());- if (rulePatterns.isPresent()) {- Matcher matcher = new StringMatcher();- rules = rules.stream()- .filter(it->rulePatterns.get().matches(matcher, it.getName()))- .collect(Collectors.toList());- }- return rules;- } else {- return new ArrayList<>();- }- }-- };-private String rule;private Optional<PatternSet> rulePatterns;@@ -91,7 +63,7 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {private Component feedback;- private DataTable<ViolationRule, Void> rulesTable;+ private WebMarkupContainer rulesContainer;private List<String> ruleNames;@@ -105,7 +77,9 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {protected void onInitialize() {super.onInitialize();- ruleNames = new ArrayList<>(getReportData().getViolationRules().keySet());+ ruleNames = getReportData().getViolationRules().stream()+ .map(it->it.getName())+ .collect(Collectors.toList());form = new Form<Void>("form");@@ -135,7 +109,7 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {pushState(target);parseRulePatterns();target.add(feedback);- target.add(rulesTable);+ target.add(rulesContainer);}});@@ -157,35 +131,53 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {pushState(target);parseRulePatterns();target.add(feedback);- target.add(rulesTable);+ target.add(rulesContainer);}});form.setOutputMarkupId(true);add(form);- List<IColumn<ViolationRule, Void>> columns = new ArrayList<>();+ parseRulePatterns();++ rulesContainer = new WebMarkupContainer("rulesContainer");+ rulesContainer.setOutputMarkupId(true);+ add(rulesContainer);- columns.add(new AbstractColumn<ViolationRule, Void>(Model.of("")) {+ PageableListView<ViolationRule> rulesView;+ rulesContainer.add(rulesView = new PageableListView<ViolationRule>("rules",+ new LoadableDetachableModel<List<ViolationRule>>() {@Override- public void populateItem(Item<ICellPopulator<ViolationRule>> cellItem,- String componentId, IModel<ViolationRule> rowModel) {- Fragment fragment = new Fragment(componentId, "ruleFrag", CheckstyleRulesPage.this);- fragment.setOutputMarkupId(true);- cellItem.add(fragment);-- ViolationRule rule = rowModel.getObject();+ protected List<ViolationRule> load() {+ if (rulePatterns != null) {+ if (rulePatterns.isPresent()) {+ Matcher matcher = new StringMatcher();+ return getReportData().getViolationRules().stream()+ .filter(it->rulePatterns.get().matches(matcher, it.getName()))+ .collect(Collectors.toList());+ } else {+ return getReportData().getViolationRules();+ }+ } else {+ return new ArrayList<>();+ }+ }++ }, WebConstants.PAGE_SIZE) {- AtomicBoolean showViolations = new AtomicBoolean(- rulesTable.getCurrentPage() == 0 && cellItem.findParent(Item.class).getIndex() == 0);+ @Override+ protected void populateItem(ListItem<ViolationRule> item) {+ ViolationRule rule = item.getModelObject();++ AtomicBoolean showViolations = new AtomicBoolean(getCurrentPage() == 0 && item.getIndex() == 0);AjaxLink<Void> toggleLink = new AjaxLink<Void>("toggle") {@Overridepublic void onClick(AjaxRequestTarget target) {showViolations.set(!showViolations.get());- target.add(fragment);+ target.add(item);}};@@ -202,25 +194,25 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {}));- fragment.add(toggleLink);+ item.add(toggleLink);- fragment.add(new Label("tooManyViolations",+ item.add(new Label("tooManyViolations","Too many violations, displaying first " + MAX_VIOLATIONS_TO_DISPLAY) {@Overrideprotected void onConfigure() {super.onConfigure();setVisible(showViolations.get()- && rowModel.getObject().getViolations().size() > MAX_VIOLATIONS_TO_DISPLAY);+ && item.getModelObject().getViolations().size() > MAX_VIOLATIONS_TO_DISPLAY);}});- fragment.add(new ListView<Violation>("violations", new LoadableDetachableModel<List<Violation>>() {+ item.add(new ListView<Violation>("violations", new LoadableDetachableModel<List<Violation>>() {@Overrideprotected List<Violation> load() {- List<Violation> violations = rowModel.getObject().getViolations();+ List<Violation> violations = item.getModelObject().getViolations();if (violations.size() > MAX_VIOLATIONS_TO_DISPLAY)return violations.subList(0, MAX_VIOLATIONS_TO_DISPLAY);else@@ -259,46 +251,13 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {setVisible(showViolations.get());}- });- }-- });-- SortableDataProvider<ViolationRule, Void> dataProvider =- new LoadableDetachableDataProvider<ViolationRule, Void>() {-- @Override- public Iterator<? extends ViolationRule> iterator(long first, long count) {- if (getRules().size() > first+count)- return getRules().subList((int)first, (int)(first+count)).iterator();- else- return getRules().subList((int)first, getRules().size()).iterator();- }-- @Override- public long calcSize() {- return getRules().size();- }-- @Override- public IModel<ViolationRule> model(ViolationRule object) {- String ruleName = object.getName();- return new LoadableDetachableModel<ViolationRule>() {-- @Override- protected ViolationRule load() {- return getReportData().getViolationRules().get(ruleName);- }-- };+ });+ item.setOutputMarkupId(true);}- };- add(rulesTable = new OneDataTable<ViolationRule, Void>("rules", columns,- dataProvider, WebConstants.PAGE_SIZE, null));- rulesTable.setOutputMarkupId(true);-- parseRulePatterns();+ });+ rulesContainer.add(new OnePagingNavigator("pagingNavigator", rulesView, null));+ rulesContainer.add(new NoRecordsPlaceholder("noRecords", rulesView));}private void pushState(AjaxRequestTarget target) {@@ -312,19 +271,9 @@ public class CheckstyleRulesPage extends CheckstyleReportPage {rule = (String) data;parseRulePatterns();target.add(form);- target.add(rulesTable);+ target.add(rulesContainer);}- private List<ViolationRule> getRules() {- return rulesModel.getObject();- }-- @Override- protected void onDetach() {- rulesModel.detach();- super.onDetach();- }-private void parseRulePatterns() {if (rule != null) {try {diff --git a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.html b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.htmlindex 1ddc7ed2a3..fcfc37d575 100644--- a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.html+++ b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.html@@ -1,42 +1,58 @@<wicket:extend>- <div wicket:id="testCases"></div>- <wicket:fragment wicket:id="hasDataFrag">- <div class="test-cases">- <div class="d-flex flex-wrap flex-md-nowrap no-autofocus">- <form wicket:id="fileForm" class="w-100 pr-md-2">- <div class="clearable-wrapper">- <div class="input-group">- <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="off" placeholder="Filter by path">- <span class="input-group-append">- <button wicket:id="submit" title="Filter" class="btn btn-icon btn-outline-secondary" type="submit"><wicket:svg href="magnify" class="icon"></wicket:svg></button>- </span>- </div>+ <div class="test-cases">+ <div class="d-flex flex-wrap flex-md-nowrap no-autofocus">+ <form wicket:id="fileForm" class="w-100 pr-md-2">+ <div class="clearable-wrapper">+ <div class="input-group">+ <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="off" placeholder="Filter by path">+ <span class="input-group-append">+ <button wicket:id="submit" title="Filter" class="btn btn-icon btn-outline-secondary" type="submit"><wicket:svg href="magnify" class="icon"></wicket:svg></button>+ </span></div>- <div wicket:id="feedback" class="mt-3"></div>- </form>- <form wicket:id="nameForm" class="w-100 pl-md-2">- <div class="clearable-wrapper">- <div class="input-group">- <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="off" placeholder="Filter by name">- <span class="input-group-append">- <button wicket:id="submit" title="Filter" class="btn btn-icon btn-outline-secondary" type="submit"><wicket:svg href="magnify" class="icon"></wicket:svg></button>- </span>- </div>+ </div>+ <div wicket:id="feedback" class="mt-3"></div>+ </form>+ <form wicket:id="nameForm" class="w-100 pl-md-2">+ <div class="clearable-wrapper">+ <div class="input-group">+ <input wicket:id="input" class="form-control" spellcheck="false" autocomplete="off" placeholder="Filter by name">+ <span class="input-group-append">+ <button wicket:id="submit" title="Filter" class="btn btn-icon btn-outline-secondary" type="submit"><wicket:svg href="magnify" class="icon"></wicket:svg></button>+ </span></div>- <div wicket:id="feedback" class="mt-3"></div>- </form>- </div>- <div wicket:id="summary" class="summary"></div>- <table wicket:id="detail" class="detail table"></table>+ </div>+ <div wicket:id="feedback" class="mt-3"></div>+ </form></div>- </wicket:fragment>- <wicket:fragment wicket:id="testCaseFrag">- <div class="d-flex">- <span wicket:id="status" class="mr-3"></span>- <span wicket:id="name" class="mr-4 text-break"></span>- <a wicket:id="testSuite" class="ml-auto text-break" title="Show test cases of this test suite"><span wicket:id="label"></span></a>- <a wicket:id="viewSource" class="ml-2" title="View source file"><wicket:svg href="file" class="icon"/></a>- </div>- <pre wicket:id="messages" class="text-gray mt-3"></pre>- </wicket:fragment>+ <div wicket:id="summary" class="summary"></div>+ <table wicket:id="detail" class="detail table">+ <tbody>+ <tr wicket:id="testCases">+ <td>+ <div class="d-flex">+ <span wicket:id="status" class="mr-3"></span>+ <span wicket:id="name" class="mr-4 text-break"></span>+ <a wicket:id="testSuite" class="ml-auto text-break" title="Show test cases of this test suite"><span wicket:id="label"></span></a>+ <a wicket:id="viewSource" class="ml-2" title="View source file"><wicket:svg href="file" class="icon"/></a>+ </div>+ <pre wicket:id="messages" class="text-gray mt-3"></pre>+ </td>+ </tr>+ </tbody>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="pagingNavigator" class="pt-5"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="noRecords"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ </table>+ </div></wicket:extend>\ No newline at end of filediff --git a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.java b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.javaindex 377806611e..49613525e1 100644--- a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.java+++ b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestCasesPage.java@@ -4,7 +4,6 @@ import java.io.Serializable;import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;-import java.util.Iterator;import java.util.LinkedHashSet;import java.util.List;import java.util.stream.Collectors;@@ -17,25 +16,16 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.ajax.markup.html.form.AjaxButton;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;-import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;-import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar;-import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;import org.apache.wicket.feedback.FencedFeedbackPanel;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.form.TextField;-import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.repeater.Item;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.PageableListView;import org.apache.wicket.markup.repeater.RepeatingView;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.apache.wicket.util.string.StringValue;import org.eclipse.jgit.lib.FileMode;@@ -55,13 +45,13 @@ import io.onedev.server.util.patternset.PatternSet;import io.onedev.server.web.WebConstants;import io.onedev.server.web.ajaxlistener.ConfirmLeaveListener;import io.onedev.server.web.behavior.PatternSetAssistBehavior;+import io.onedev.server.web.component.NoRecordsPlaceholder;import io.onedev.server.web.component.chart.pie.PieChartPanel;import io.onedev.server.web.component.chart.pie.PieSlice;import io.onedev.server.web.component.link.ViewStateAwareAjaxLink;import io.onedev.server.web.component.link.ViewStateAwarePageLink;import io.onedev.server.web.component.pagenavigator.OnePagingNavigator;import io.onedev.server.web.page.project.blob.ProjectBlobPage;-import io.onedev.server.web.util.LoadableDetachableDataProvider;import io.onedev.server.web.util.SuggestionUtils;@SuppressWarnings("serial")@@ -79,18 +69,6 @@ public class JestTestCasesPage extends JestTestReportPage {private Optional<PatternSet> namePatterns;- private final IModel<List<TestCase>> testCasesModel = new LoadableDetachableModel<List<TestCase>>() {-- @Override- protected List<TestCase> load() {- if (filePatterns != null && namePatterns != null)- return getReportData().getTestCases(filePatterns.orNull(), namePatterns.orNull(), state.statuses);- else- return new ArrayList<>();- }-- };-private Form<?> fileForm;private Form<?> nameForm;@@ -101,7 +79,7 @@ public class JestTestCasesPage extends JestTestReportPage {private Component summary;- private DataTable<TestCase, Void> detail;+ private WebMarkupContainer detail;public JestTestCasesPage(PageParameters params) {super(params);@@ -143,296 +121,263 @@ public class JestTestCasesPage extends JestTestReportPage {protected void onInitialize() {super.onInitialize();- if (getReportData() != null) {- Fragment fragment = new Fragment("testCases", "hasDataFrag", this);-- fileForm = new Form<Void>("fileForm");-- TextField<String> input = new TextField<String>("input", new IModel<String>() {+ fileForm = new Form<Void>("fileForm");++ TextField<String> input = new TextField<String>("input", new IModel<String>() {- @Override- public void detach() {- }+ @Override+ public void detach() {+ }- @Override- public String getObject() {- return state.file;- }+ @Override+ public String getObject() {+ return state.file;+ }- @Override- public void setObject(String object) {- state.file = object;- }-- });- input.add(new PatternSetAssistBehavior() {-- @Override- protected List<InputSuggestion> suggest(String matchWith) {- return SuggestionUtils.suggest(- getReportData().getTestSuites().stream().map(it->it.getName()).collect(Collectors.toList()),- matchWith);- }-- @Override- protected List<String> getHints(TerminalExpect terminalExpect) {- return Lists.newArrayList(- "Path containing spaces or starting with dash needs to be quoted",- "Use '**', '*' or '?' for <a href='$docRoot/pages/path-wildcard.md' target='_blank'>path wildcard match</a>. Prefix with '-' to exclude"- );- }-- });- fileForm.add(input);+ @Override+ public void setObject(String object) {+ state.file = object;+ }- input.add(new AjaxFormComponentUpdatingBehavior("clear") {-- @Override- protected void onUpdate(AjaxRequestTarget target) {- pushState(target);- parseFilePatterns();- target.add(fileFeedback);- target.add(summary);- target.add(detail);- }-- });+ });+ input.add(new PatternSetAssistBehavior() {- fileForm.add(fileFeedback = new FencedFeedbackPanel("feedback", fileForm));- fileFeedback.setOutputMarkupPlaceholderTag(true);-- fileForm.add(new AjaxButton("submit") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(this));- }-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- super.onSubmit(target, form);- pushState(target);- parseFilePatterns();- target.add(fileFeedback);- target.add(summary);- target.add(detail);- }-- });+ @Override+ protected List<InputSuggestion> suggest(String matchWith) {+ return SuggestionUtils.suggest(+ getReportData().getTestSuites().stream().map(it->it.getName()).collect(Collectors.toList()),+ matchWith);+ }- fragment.add(fileForm);+ @Override+ protected List<String> getHints(TerminalExpect terminalExpect) {+ return Lists.newArrayList(+ "Path containing spaces or starting with dash needs to be quoted",+ "Use '**', '*' or '?' for <a href='$docRoot/pages/path-wildcard.md' target='_blank'>path wildcard match</a>. Prefix with '-' to exclude"+ );+ }- nameForm = new Form<Void>("nameForm");+ });+ fileForm.add(input);++ input.add(new AjaxFormComponentUpdatingBehavior("clear") {- input = new TextField<String>("input", new IModel<String>() {-- @Override- public void detach() {- }+ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ pushState(target);+ parseFilePatterns();+ target.add(fileFeedback);+ target.add(summary);+ target.add(detail);+ }++ });++ fileForm.add(fileFeedback = new FencedFeedbackPanel("feedback", fileForm));+ fileFeedback.setOutputMarkupPlaceholderTag(true);- @Override- public String getObject() {- return state.name;- }+ fileForm.add(new AjaxButton("submit") {- @Override- public void setObject(String object) {- state.name = object;- }-- });- input.add(new PatternSetAssistBehavior() {-- @Override- protected List<InputSuggestion> suggest(String matchWith) {- return SuggestionUtils.suggest(- getReportData().getTestCases(null, null, null).stream().map(it->it.getName()).distinct().collect(Collectors.toList()),- matchWith);- }-- @Override- protected List<String> getHints(TerminalExpect terminalExpect) {- return Lists.newArrayList(- "Path containing spaces or starting with dash needs to be quoted",- "Use '**', '*' or '?' for <a href='$docRoot/pages/path-wildcard.md' target='_blank'>path wildcard match</a>. Prefix with '-' to exclude"- );- }-- });- nameForm.add(input);+ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(this));+ }- input.add(new AjaxFormComponentUpdatingBehavior("clear") {-- @Override- protected void onUpdate(AjaxRequestTarget target) {- pushState(target);- parseNamePatterns();- target.add(nameFeedback);- target.add(summary);- target.add(detail);- }-- });+ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ super.onSubmit(target, form);+ pushState(target);+ parseFilePatterns();+ target.add(fileFeedback);+ target.add(summary);+ target.add(detail);+ }- nameForm.add(nameFeedback = new FencedFeedbackPanel("feedback", nameForm));- nameFeedback.setOutputMarkupPlaceholderTag(true);+ });++ add(fileForm);++ nameForm = new Form<Void>("nameForm");++ input = new TextField<String>("input", new IModel<String>() {- nameForm.add(new AjaxButton("submit") {+ @Override+ public void detach() {+ }- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(this));- }-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- super.onSubmit(target, form);- pushState(target);- parseNamePatterns();- target.add(nameFeedback);- target.add(summary);- target.add(detail);- }-- });+ @Override+ public String getObject() {+ return state.name;+ }++ @Override+ public void setObject(String object) {+ state.name = object;+ }- fragment.add(nameForm);+ });+ input.add(new PatternSetAssistBehavior() {- parseFilePatterns();- parseNamePatterns();+ @Override+ protected List<InputSuggestion> suggest(String matchWith) {+ return SuggestionUtils.suggest(+ getReportData().getTestCases(null, null, null).stream().map(it->it.getName()).distinct().collect(Collectors.toList()),+ matchWith);+ }- fragment.add(summary = new PieChartPanel("summary", new LoadableDetachableModel<List<PieSlice>>() {+ @Override+ protected List<String> getHints(TerminalExpect terminalExpect) {+ return Lists.newArrayList(+ "Path containing spaces or starting with dash needs to be quoted",+ "Use '**', '*' or '?' for <a href='$docRoot/pages/path-wildcard.md' target='_blank'>path wildcard match</a>. Prefix with '-' to exclude"+ );+ }++ });+ nameForm.add(input);++ input.add(new AjaxFormComponentUpdatingBehavior("clear") {++ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ pushState(target);+ parseNamePatterns();+ target.add(nameFeedback);+ target.add(summary);+ target.add(detail);+ }++ });++ nameForm.add(nameFeedback = new FencedFeedbackPanel("feedback", nameForm));+ nameFeedback.setOutputMarkupPlaceholderTag(true);- @Override- protected List<PieSlice> load() {- if (filePatterns != null && namePatterns != null) {- List<PieSlice> slices = new ArrayList<>();- for (Status status: Status.values()) {- int numOfTestCases = getReportData().getTestCases(- filePatterns.orNull(), namePatterns.orNull(), Sets.newHashSet(status)).size();- slices.add(new PieSlice(status.name().toLowerCase(), numOfTestCases,- status.getColor(), state.statuses.contains(status)));- }- return slices;- } else {- return null;- }- }-- }) {+ nameForm.add(new AjaxButton("submit") {- @Override- protected void onSelectionChange(AjaxRequestTarget target, String sliceName) {- Status status = Status.valueOf(sliceName.toUpperCase());- if (state.statuses.contains(status))- state.statuses.remove(status);- else- state.statuses.add(status);- pushState(target);- target.add(detail);+ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(this));+ }++ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ super.onSubmit(target, form);+ pushState(target);+ parseNamePatterns();+ target.add(nameFeedback);+ target.add(summary);+ target.add(detail);+ }++ });++ add(nameForm);++ parseFilePatterns();+ parseNamePatterns();++ add(summary = new PieChartPanel("summary", new LoadableDetachableModel<List<PieSlice>>() {++ @Override+ protected List<PieSlice> load() {+ if (filePatterns != null && namePatterns != null) {+ List<PieSlice> slices = new ArrayList<>();+ for (Status status: Status.values()) {+ int numOfTestCases = getReportData().getTestCases(+ filePatterns.orNull(), namePatterns.orNull(), Sets.newHashSet(status)).size();+ slices.add(new PieSlice(status.name().toLowerCase(), numOfTestCases,+ status.getColor(), state.statuses.contains(status)));+ }+ return slices;+ } else {+ return null;}-- });+ }- List<IColumn<TestCase, Void>> columns = new ArrayList<>();+ }) {++ @Override+ protected void onSelectionChange(AjaxRequestTarget target, String sliceName) {+ Status status = Status.valueOf(sliceName.toUpperCase());+ if (state.statuses.contains(status))+ state.statuses.remove(status);+ else+ state.statuses.add(status);+ pushState(target);+ target.add(detail);+ }- columns.add(new AbstractColumn<TestCase, Void>(Model.of("")) {+ });++ detail = new WebMarkupContainer("detail");+ detail.setOutputMarkupId(true);+ add(detail);++ PageableListView<TestCase> testCasesView;+ detail.add(testCasesView = new PageableListView<TestCase>("testCases",+ new LoadableDetachableModel<List<TestCase>>() {++ @Override+ protected List<TestCase> load() {+ if (filePatterns != null && namePatterns != null)+ return getReportData().getTestCases(filePatterns.orNull(), namePatterns.orNull(), state.statuses);+ else+ return new ArrayList<>();+ }++ }, WebConstants.PAGE_SIZE) {- @Override- public void populateItem(Item<ICellPopulator<TestCase>> cellItem,- String componentId, IModel<TestCase> rowModel) {- TestCase testCase = rowModel.getObject();- Fragment fragment = new Fragment(componentId, "testCaseFrag", JestTestCasesPage.this);-- fragment.add(new TestStatusBadge("status", testCase.getStatus()));- fragment.add(new Label("name", testCase.getName()));+ @Override+ protected void populateItem(ListItem<TestCase> item) {+ TestCase testCase = item.getModelObject();+ item.add(new TestStatusBadge("status", testCase.getStatus()));+ item.add(new Label("name", testCase.getName()));++ AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("testSuite") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ state.file = testCase.getTestSuite().getName();+ pushState(target);+ parseFilePatterns();+ target.add(fileForm);+ target.add(summary);+ target.add(detail);+ }- AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("testSuite") {+ };+ link.add(new Label("label", testCase.getTestSuite().getName()));+ item.add(link);++ BlobIdent blobIdent = new BlobIdent(getBuild().getCommitHash(), testCase.getTestSuite().getName(),+ FileMode.REGULAR_FILE.getBits());+ if (SecurityUtils.canReadCode(getProject()) && getProject().getBlob(blobIdent, false) != null) {+ item.add(new ViewStateAwarePageLink<Void>("viewSource", ProjectBlobPage.class,+ ProjectBlobPage.paramsOf(getProject(), blobIdent)));+ } else {+ item.add(new WebMarkupContainer("viewSource").setVisible(false));+ }++ RepeatingView messagesView = new RepeatingView("messages");+ for (String message: testCase.getMessages()) {+ messagesView.add(new TestMessagePanel(messagesView.newChildId(), message) {@Override- public void onClick(AjaxRequestTarget target) {- state.file = testCase.getTestSuite().getName();- pushState(target);- parseFilePatterns();- target.add(fileForm);- target.add(summary);- target.add(detail);+ protected Build getBuild() {+ return JestTestCasesPage.this.getBuild();}- };- link.add(new Label("label", testCase.getTestSuite().getName()));- fragment.add(link);-- BlobIdent blobIdent = new BlobIdent(getBuild().getCommitHash(), testCase.getTestSuite().getName(),- FileMode.REGULAR_FILE.getBits());- if (SecurityUtils.canReadCode(getProject()) && getProject().getBlob(blobIdent, false) != null) {- fragment.add(new ViewStateAwarePageLink<Void>("viewSource", ProjectBlobPage.class,- ProjectBlobPage.paramsOf(getProject(), blobIdent)));- } else {- fragment.add(new WebMarkupContainer("viewSource").setVisible(false));- }-- RepeatingView messagesView = new RepeatingView("messages");- for (String message: testCase.getMessages()) {- messagesView.add(new TestMessagePanel(messagesView.newChildId(), message) {-- @Override- protected Build getBuild() {- return JestTestCasesPage.this.getBuild();- }-- });- }- fragment.add(messagesView);-- cellItem.add(fragment);- }-- });-- SortableDataProvider<TestCase, Void> dataProvider = new LoadableDetachableDataProvider<TestCase, Void>() {-- @Override- public Iterator<? extends TestCase> iterator(long first, long count) {- if (getTestCases().size() > first+count)- return getTestCases().subList((int)first, (int)(first+count)).iterator();- else- return getTestCases().subList((int)first, getTestCases().size()).iterator();- }-- @Override- public long calcSize() {- return getTestCases().size();- }-- @Override- public IModel<TestCase> model(TestCase object) {- return Model.of(object);- }-- };- fragment.add(detail = new DataTable<TestCase, Void>("detail", columns,- dataProvider, WebConstants.PAGE_SIZE));-- detail.addBottomToolbar(new NavigationToolbar(detail) {-- @Override- protected PagingNavigator newPagingNavigator(String navigatorId, DataTable<?, ?> table) {- return new OnePagingNavigator(navigatorId, table, null);+ });}-- });-- fragment.add(detail.setOutputMarkupId(true));+ item.add(messagesView);+ }- add(fragment);- } else {- add(new Label("testCases", "No test suites published")- .add(AttributeAppender.append("class", "alert alert-notice alert-light-warning")));- }+ });+ detail.add(new OnePagingNavigator("pagingNavigator", testCasesView, null));+ detail.add(new NoRecordsPlaceholder("noRecords", testCasesView));}private void parseFilePatterns() {@@ -461,16 +406,6 @@ public class JestTestCasesPage extends JestTestReportPage {}}- private List<TestCase> getTestCases() {- return testCasesModel.getObject();- }-- @Override- protected void onDetach() {- testCasesModel.detach();- super.onDetach();- }-public static PageParameters paramsOf(Build build, String reportName, State state) {PageParameters params = paramsOf(build, reportName);if (state.file != null)diff --git a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestReportData.java b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestReportData.javaindex 0ef9618be6..dc144147be 100644--- a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestReportData.java+++ b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestReportData.java@@ -84,14 +84,10 @@ public class JestTestReportData implements Serializable {@Nullablepublic static JestTestReportData readFrom(File reportDir) {File dataFile = new File(reportDir, FILE_NAME);- if (dataFile.exists()) {- try (InputStream is = new BufferedInputStream(new FileInputStream(dataFile))) {- return (JestTestReportData) SerializationUtils.deserialize(is);- } catch (IOException e) {- throw new RuntimeException(e);- }- } else {- return null;+ try (InputStream is = new BufferedInputStream(new FileInputStream(dataFile))) {+ return (JestTestReportData) SerializationUtils.deserialize(is);+ } catch (IOException e) {+ throw new RuntimeException(e);}}diff --git a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.html b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.htmlindex e7170634cd..e5da085163 100644--- a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.html+++ b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.html@@ -1,37 +1,53 @@<wicket:extend>- <div wicket:id="testSuites"></div>- <wicket:fragment wicket:id="hasDataFrag">- <div class="test-suites">- <form wicket:id="form" class="form no-autofocus">- <div class="clearable-wrapper">- <div class="input-group">- <input wicket:id="file" class="form-control" spellcheck="false" autocomplete="off" placeholder="Filter by path">- <span class="input-group-append">- <button wicket:id="submit" title="Filter" class="btn btn-icon btn-outline-secondary" type="submit"><wicket:svg href="magnify" class="icon"></wicket:svg></button>- </span>- </div>+ <div class="test-suites">+ <form wicket:id="form" class="form no-autofocus">+ <div class="clearable-wrapper">+ <div class="input-group">+ <input wicket:id="file" class="form-control" spellcheck="false" autocomplete="off" placeholder="Filter by path">+ <span class="input-group-append">+ <button wicket:id="submit" title="Filter" class="btn btn-icon btn-outline-secondary" type="submit"><wicket:svg href="magnify" class="icon"></wicket:svg></button>+ </span></div>- <div wicket:id="feedback" class="mt-3"></div>- </form>- <div wicket:id="summary" class="summary"></div>- <div class="d-flex align-items-center mb-2">- <span class="ml-auto mr-3 font-weight-bold">Longest Duration First</span>- <span class="switch switch-sm switch-primary">- <label>- <input wicket:id="longestDurationFirst" type="checkbox">- </label>- </span></div>- <table wicket:id="detail" class="detail table"></table>+ <div wicket:id="feedback" class="mt-3"></div>+ </form>+ <div wicket:id="summary" class="summary"></div>+ <div class="d-flex align-items-center mb-2">+ <span class="ml-auto mr-3 font-weight-bold">Longest Duration First</span>+ <span class="switch switch-sm switch-primary">+ <label>+ <input wicket:id="longestDurationFirst" type="checkbox">+ </label>+ </span></div>- </wicket:fragment>- <wicket:fragment wicket:id="testSuiteFrag">- <div class="d-flex">- <span wicket:id="status" class="mr-3"></span>- <a wicket:id="testCases" class="mr-4 text-break" title="Show test cases of this test suite"><span wicket:id="label"></span></a>- <a wicket:id="viewSource" class="ml-n3 mr-4" title="View source file"><wicket:svg href="file" class="icon"/></a>- <span wicket:id="duration" class="ml-auto"></span>- </div>- <pre wicket:id="message" class="text-gray mt-3"></pre>- </wicket:fragment>+ <table wicket:id="detail" class="detail table">+ <tbody>+ <tr wicket:id="testSuites">+ <td>+ <div class="d-flex">+ <span wicket:id="status" class="mr-3"></span>+ <a wicket:id="testCases" class="mr-4 text-break" title="Show test cases of this test suite"><span wicket:id="label"></span></a>+ <a wicket:id="viewSource" class="ml-n3 mr-4" title="View source file"><wicket:svg href="file" class="icon"/></a>+ <span wicket:id="duration" class="ml-auto"></span>+ </div>+ <pre wicket:id="message" class="text-gray mt-3"></pre>+ </td>+ </tr>+ </tbody>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="pagingNavigator" class="pt-5"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ <wicket:enclosure>+ <tfoot>+ <tr>+ <td wicket:id="noRecords"></td>+ </tr>+ </tfoot>+ </wicket:enclosure>+ </table>+ </div></wicket:extend>\ No newline at end of filediff --git a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.java b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.javaindex 287228a86d..9e99197516 100644--- a/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.java+++ b/server-plugin/server-plugin-report-jest/src/main/java/io/onedev/server/plugin/report/jest/JestTestSuitesPage.java@@ -4,7 +4,6 @@ import java.io.Serializable;import java.util.ArrayList;import java.util.Collection;import java.util.Comparator;-import java.util.Iterator;import java.util.LinkedHashSet;import java.util.List;import java.util.stream.Collectors;@@ -17,25 +16,16 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;import org.apache.wicket.ajax.markup.html.form.AjaxButton;import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;-import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;-import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar;-import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;import org.apache.wicket.feedback.FencedFeedbackPanel;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.form.TextField;import org.apache.wicket.markup.html.link.Link;-import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.repeater.Item;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.PageableListView;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.apache.wicket.util.string.StringValue;import org.eclipse.jgit.lib.FileMode;@@ -56,12 +46,12 @@ import io.onedev.server.util.patternset.PatternSet;import io.onedev.server.web.WebConstants;import io.onedev.server.web.ajaxlistener.ConfirmLeaveListener;import io.onedev.server.web.behavior.PatternSetAssistBehavior;+import io.onedev.server.web.component.NoRecordsPlaceholder;import io.onedev.server.web.component.chart.pie.PieChartPanel;import io.onedev.server.web.component.chart.pie.PieSlice;import io.onedev.server.web.component.link.ViewStateAwarePageLink;import io.onedev.server.web.component.pagenavigator.OnePagingNavigator;import io.onedev.server.web.page.project.blob.ProjectBlobPage;-import io.onedev.server.web.util.LoadableDetachableDataProvider;import io.onedev.server.web.util.SuggestionUtils;@SuppressWarnings("serial")@@ -77,30 +67,6 @@ public class JestTestSuitesPage extends JestTestReportPage {private Optional<PatternSet> filePatterns;- private final IModel<List<TestSuite>> testSuitesModel = new LoadableDetachableModel<List<TestSuite>>() {-- @Override- protected List<TestSuite> load() {- if (filePatterns != null) {- List<TestSuite> testSuites = getReportData().getTestSuites(filePatterns.orNull(), state.statuses);- if (state.longestDurationFirst) {- testSuites.sort(new Comparator<TestSuite>() {-- @Override- public int compare(TestSuite o1, TestSuite o2) {- return (int)(o2.getDuration()/1000 - o1.getDuration()/1000);- }-- });- }- return testSuites;- } else {- return new ArrayList<>();- }- }-- };-private Form<?> form;private Component feedback;@@ -109,7 +75,7 @@ public class JestTestSuitesPage extends JestTestReportPage {private Component orderBy;- private DataTable<TestSuite, Void> detail;+ private WebMarkupContainer detail;public JestTestSuitesPage(PageParameters params) {super(params);@@ -149,233 +115,212 @@ public class JestTestSuitesPage extends JestTestReportPage {protected void onInitialize() {super.onInitialize();- if (getReportData() != null) {- Fragment fragment = new Fragment("testSuites", "hasDataFrag", this);-- form = new Form<Void>("form");- TextField<String> fileFilter = new TextField<String>("file", new IModel<String>() {+ form = new Form<Void>("form");+ TextField<String> fileFilter = new TextField<String>("file", new IModel<String>() {- @Override- public void detach() {- }+ @Override+ public void detach() {+ }- @Override- public String getObject() {- return state.file;- }+ @Override+ public String getObject() {+ return state.file;+ }- @Override- public void setObject(String object) {- state.file = object;- }-- });- fileFilter.add(new PatternSetAssistBehavior() {-- @Override- protected List<InputSuggestion> suggest(String matchWith) {- return SuggestionUtils.suggest(- getReportData().getTestSuites().stream().map(it->it.getName()).collect(Collectors.toList()),- matchWith);- }-- @Override- protected List<String> getHints(TerminalExpect terminalExpect) {- return Lists.newArrayList(- "Path containing spaces or starting with dash needs to be quoted",- "Use '**', '*' or '?' for <a href='$docRoot/pages/path-wildcard.md' target='_blank'>path wildcard match</a>. Prefix with '-' to exclude"- );- }-- });- form.add(fileFilter);+ @Override+ public void setObject(String object) {+ state.file = object;+ }- fileFilter.add(new AjaxFormComponentUpdatingBehavior("clear") {-- @Override- protected void onUpdate(AjaxRequestTarget target) {- pushState(target);- parseFilePatterns();- target.add(feedback);- target.add(summary);- target.add(detail);- }-- });+ });+ fileFilter.add(new PatternSetAssistBehavior() {- form.add(feedback = new FencedFeedbackPanel("feedback", form));- feedback.setOutputMarkupPlaceholderTag(true);-- form.add(new AjaxButton("submit") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(this));- }-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- super.onSubmit(target, form);- pushState(target);- parseFilePatterns();- target.add(feedback);- target.add(summary);- target.add(detail);- }-- });+ @Override+ protected List<InputSuggestion> suggest(String matchWith) {+ return SuggestionUtils.suggest(+ getReportData().getTestSuites().stream().map(it->it.getName()).collect(Collectors.toList()),+ matchWith);+ }- fragment.add(form);+ @Override+ protected List<String> getHints(TerminalExpect terminalExpect) {+ return Lists.newArrayList(+ "Path containing spaces or starting with dash needs to be quoted",+ "Use '**', '*' or '?' for <a href='$docRoot/pages/path-wildcard.md' target='_blank'>path wildcard match</a>. Prefix with '-' to exclude"+ );+ }- parseFilePatterns();+ });+ form.add(fileFilter);++ fileFilter.add(new AjaxFormComponentUpdatingBehavior("clear") {- fragment.add(summary = new PieChartPanel("summary", new LoadableDetachableModel<List<PieSlice>>() {-- @Override- protected List<PieSlice> load() {- if (filePatterns != null) {- List<PieSlice> slices = new ArrayList<>();- for (Status status: Status.values()) {- int numOfTestSuites = getReportData().getTestSuites(- filePatterns.orNull(), Sets.newHashSet(status)).size();- slices.add(new PieSlice(status.name().toLowerCase(), numOfTestSuites,- status.getColor(), state.statuses.contains(status)));- }- return slices;- } else {- return null;- }- }-- }) {-- @Override- protected void onSelectionChange(AjaxRequestTarget target, String sliceName) {- Status status = Status.valueOf(sliceName.toUpperCase());- if (state.statuses.contains(status))- state.statuses.remove(status);- else- state.statuses.add(status);- pushState(target);- target.add(detail);- }-- });+ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ pushState(target);+ parseFilePatterns();+ target.add(feedback);+ target.add(summary);+ target.add(detail);+ }- fragment.add(orderBy = new AjaxCheckBox("longestDurationFirst", new IModel<Boolean>() {-- @Override- public void detach() {- }+ });++ form.add(feedback = new FencedFeedbackPanel("feedback", form));+ feedback.setOutputMarkupPlaceholderTag(true);- @Override- public Boolean getObject() {- return state.longestDurationFirst;- }+ form.add(new AjaxButton("submit") {- @Override- public void setObject(Boolean object) {- state.longestDurationFirst = object;- }-- }) {-- @Override- protected void onUpdate(AjaxRequestTarget target) {- pushState(target);- target.add(detail);+ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(this));+ }++ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ super.onSubmit(target, form);+ pushState(target);+ parseFilePatterns();+ target.add(feedback);+ target.add(summary);+ target.add(detail);+ }++ });++ add(form);++ parseFilePatterns();++ add(summary = new PieChartPanel("summary", new LoadableDetachableModel<List<PieSlice>>() {++ @Override+ protected List<PieSlice> load() {+ if (filePatterns != null) {+ List<PieSlice> slices = new ArrayList<>();+ for (Status status: Status.values()) {+ int numOfTestSuites = getReportData().getTestSuites(+ filePatterns.orNull(), Sets.newHashSet(status)).size();+ slices.add(new PieSlice(status.name().toLowerCase(), numOfTestSuites,+ status.getColor(), state.statuses.contains(status)));+ }+ return slices;+ } else {+ return null;}-- });+ }- List<IColumn<TestSuite, Void>> columns = new ArrayList<>();+ }) {++ @Override+ protected void onSelectionChange(AjaxRequestTarget target, String sliceName) {+ Status status = Status.valueOf(sliceName.toUpperCase());+ if (state.statuses.contains(status))+ state.statuses.remove(status);+ else+ state.statuses.add(status);+ pushState(target);+ target.add(detail);+ }- columns.add(new AbstractColumn<TestSuite, Void>(Model.of("")) {+ });++ add(orderBy = new AjaxCheckBox("longestDurationFirst", new IModel<Boolean>() {- @Override- public void populateItem(Item<ICellPopulator<TestSuite>> cellItem,- String componentId, IModel<TestSuite> rowModel) {- TestSuite testSuite = rowModel.getObject();- Fragment fragment = new Fragment(componentId, "testSuiteFrag", JestTestSuitesPage.this);-- fragment.add(new TestStatusBadge("status", testSuite.getStatus()));-- JestTestCasesPage.State state = new JestTestCasesPage.State();- state.file = testSuite.getName();- state.statuses = JestTestSuitesPage.this.state.statuses;- PageParameters params = JestTestCasesPage.paramsOf(getBuild(), getReportName(), state);- Link<Void> link = new ViewStateAwarePageLink<Void>("testCases",- JestTestCasesPage.class, params);- link.add(new Label("label", testSuite.getName()));-- BlobIdent blobIdent = new BlobIdent(getBuild().getCommitHash(), testSuite.getName(),- FileMode.REGULAR_FILE.getBits());- if (SecurityUtils.canReadCode(getProject()) && getProject().getBlob(blobIdent, false) != null) {- fragment.add(new ViewStateAwarePageLink<Void>("viewSource", ProjectBlobPage.class,- ProjectBlobPage.paramsOf(getProject(), blobIdent)));- } else {- fragment.add(new WebMarkupContainer("viewSource").setVisible(false));- }-- fragment.add(new Label("duration", DateUtils.formatDuration(testSuite.getDuration())));- fragment.add(link);-- fragment.add(new TestMessagePanel("message", testSuite.getMessage()) {+ @Override+ public void detach() {+ }- @Override- protected Build getBuild() {- return JestTestSuitesPage.this.getBuild();- }-- }.setVisible(testSuite.getMessage() != null));-- cellItem.add(fragment);- }+ @Override+ public Boolean getObject() {+ return state.longestDurationFirst;+ }- });+ @Override+ public void setObject(Boolean object) {+ state.longestDurationFirst = object;+ }- SortableDataProvider<TestSuite, Void> dataProvider = new LoadableDetachableDataProvider<TestSuite, Void>() {-- @Override- public Iterator<? extends TestSuite> iterator(long first, long count) {- if (getTestSuites().size() > first+count)- return getTestSuites().subList((int)first, (int)(first+count)).iterator();- else- return getTestSuites().subList((int)first, getTestSuites().size()).iterator();+ }) {++ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ pushState(target);+ target.add(detail);+ }++ });++ detail = new WebMarkupContainer("detail");+ detail.setOutputMarkupId(true);+ add(detail);++ PageableListView<TestSuite> testSuitesView;+ detail.add(testSuitesView = new PageableListView<TestSuite>("testSuites",+ new LoadableDetachableModel<List<TestSuite>>() {++ @Override+ protected List<TestSuite> load() {+ if (filePatterns != null) {+ List<TestSuite> testSuites = getReportData().getTestSuites(filePatterns.orNull(), state.statuses);+ if (state.longestDurationFirst) {+ testSuites.sort(new Comparator<TestSuite>() {++ @Override+ public int compare(TestSuite o1, TestSuite o2) {+ return (int)(o2.getDuration()/1000 - o1.getDuration()/1000);+ }++ });+ }+ return testSuites;+ } else {+ return new ArrayList<>();}+ }- @Override- public long calcSize() {- return getTestSuites().size();- }+ }, WebConstants.PAGE_SIZE) {- @Override- public IModel<TestSuite> model(TestSuite object) {- return Model.of(object);- }+ @Override+ protected void populateItem(ListItem<TestSuite> item) {+ TestSuite testSuite = item.getModelObject();+ item.add(new TestStatusBadge("status", testSuite.getStatus()));- };- fragment.add(detail = new DataTable<TestSuite, Void>("detail", columns,- dataProvider, WebConstants.PAGE_SIZE));-- detail.addBottomToolbar(new NavigationToolbar(detail) {-- @Override- protected PagingNavigator newPagingNavigator(String navigatorId, DataTable<?, ?> table) {- return new OnePagingNavigator(navigatorId, table, null);+ JestTestCasesPage.State state = new JestTestCasesPage.State();+ state.file = testSuite.getName();+ state.statuses = JestTestSuitesPage.this.state.statuses;+ PageParameters params = JestTestCasesPage.paramsOf(getBuild(), getReportName(), state);+ Link<Void> link = new ViewStateAwarePageLink<Void>("testCases",+ JestTestCasesPage.class, params);+ link.add(new Label("label", testSuite.getName()));++ BlobIdent blobIdent = new BlobIdent(getBuild().getCommitHash(), testSuite.getName(),+ FileMode.REGULAR_FILE.getBits());+ if (SecurityUtils.canReadCode(getProject()) && getProject().getBlob(blobIdent, false) != null) {+ item.add(new ViewStateAwarePageLink<Void>("viewSource", ProjectBlobPage.class,+ ProjectBlobPage.paramsOf(getProject(), blobIdent)));+ } else {+ item.add(new WebMarkupContainer("viewSource").setVisible(false));}++ item.add(new Label("duration", DateUtils.formatDuration(testSuite.getDuration())));+ item.add(link);- });-- fragment.add(detail.setOutputMarkupId(true));+ item.add(new TestMessagePanel("message", testSuite.getMessage()) {++ @Override+ protected Build getBuild() {+ return JestTestSuitesPage.this.getBuild();+ }++ }.setVisible(testSuite.getMessage() != null));+ }- add(fragment);- } else {- add(new Label("testSuites", "No test suites published")- .add(AttributeAppender.append("class", "alert alert-notice alert-light-warning")));- }-+ });++ detail.add(new OnePagingNavigator("pagingNavigator", testSuitesView, null));+ detail.add(new NoRecordsPlaceholder("noRecords", testSuitesView));}private void parseFilePatterns() {@@ -391,16 +336,6 @@ public class JestTestSuitesPage extends JestTestReportPage {}}- private List<TestSuite> getTestSuites() {- return testSuitesModel.getObject();- }-- @Override- protected void onDetach() {- testSuitesModel.detach();- super.onDetach();- }-public static PageParameters paramsOf(Build build, String reportName, State state) {PageParameters params = paramsOf(build, reportName);if (state.file != null)