The Unified and Autonomous Development Platform
Add back to top feature. Fix word diff errors.
robin shineb9dbdd4eb112
diff --git a/commons.util/src/main/java/com/pmease/commons/util/diff/DiffUtils.java b/commons.util/src/main/java/com/pmease/commons/util/diff/DiffUtils.javaindex e03b5b1d59..79011652eb 100644--- a/commons.util/src/main/java/com/pmease/commons/util/diff/DiffUtils.java+++ b/commons.util/src/main/java/com/pmease/commons/util/diff/DiffUtils.java@@ -93,11 +93,15 @@ public class DiffUtils {List<DiffLine> diffPartials = diff(getPartials(deletion.getFirst(), partialSplitter, partialsCache),getPartials(addition.getFirst(), partialSplitter, partialsCache), null);int equals = 0;+ int total = 0;for (DiffLine diffPartial: diffPartials) {- if (diffPartial.getAction() == DiffLine.Action.EQUAL)- equals++;+ if (StringUtils.isNotBlank(diffPartial.getPartials().get(0).getContent())) {+ total ++;+ if (diffPartial.getAction() == DiffLine.Action.EQUAL)+ equals++;+ }}- if (equals*3 >= diffPartials.size()) {+ if (equals*3 >= total) {for (int j=0; j<i; j++) {Triple<String, Integer, Integer> prevAddition = additions.get(j);processedAdditions.add(new DiffLine(DiffLine.Action.ADD, prevAddition.getFirst(),diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.javaindex 621d5a56ef..cda30945ae 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java@@ -68,7 +68,7 @@ public abstract class AbstractWicketConfig extends WebApplication {target.appendJavaScript((String.format("$(document).trigger('replace', '%s');", component.getMarkupId())));}- target.appendJavaScript("$(document.body).trigger('sticky_kit:recalc')");+ target.appendJavaScript("$(document.body).trigger('sticky_kit:recalc');");}@Overridediff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.javaindex 468d244ee7..dc733abc34 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java@@ -128,4 +128,5 @@ public abstract class CommonPage extends WebPage {super.renderHead(response);response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(CommonResourceReference.get())));}+}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/back-to-top.png b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/back-to-top.pngnew file mode 100644index 0000000000..dd0c681babBinary files /dev/null and b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/back-to-top.png differdiff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.cssindex 12b96cc248..09962973c0 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.css+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.css@@ -195,4 +195,8 @@ table td, table th {text-align: left;}/* div table */div.table {display: table;}div.tr {display: table-row;}-div.td {display: table-cell;}\ No newline at end of file+div.td {display: table-cell;}++/* BACK TO TOP */+.back-to-top {position: fixed; right: 20px; bottom: 40px; cursor: pointer; padding: 24px;+ background: url("back-to-top.png") no-repeat 0 0; z-index: 100;}\ No newline at end of filediff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.jsindex 2e87ccfadc..6e3e53ca6c 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js@@ -616,7 +616,7 @@ pmease.commons = {}});return prev;- },+ }},@@ -708,7 +708,22 @@ pmease.commons = {}, 5000);}},-++ backToTop: function(backToTop) {+ var $backToTop = $(backToTop);+ $backToTop.hide();+ $(window).scroll(function(){+ if ($(window).scrollTop()>500)+ $backToTop.fadeIn(1000);+ else+ $backToTop.fadeOut(1000);+ });+ $backToTop.click(function(){+ $("body, html").animate({scrollTop:0}, 700);+ return false;+ });+ }+};$(function() {diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/StickyBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/StickyBehavior.javaindex a1ded4feb8..4541897d74 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/StickyBehavior.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/StickyBehavior.java@@ -6,7 +6,7 @@ import org.apache.wicket.Component;import org.apache.wicket.behavior.AttributeAppender;import org.apache.wicket.behavior.Behavior;import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;+import org.apache.wicket.markup.head.OnLoadHeaderItem;@SuppressWarnings("serial")public class StickyBehavior extends Behavior {@@ -42,7 +42,9 @@ public class StickyBehavior extends Behavior {script = String.format("pmease.commons.stick('#%s', undefined);",component.getMarkupId());}- response.render(OnDomReadyHeaderItem.forScript(script));+ // execute this script OnLoad instead of OnDomReady here, as sticky+ // calculation will not be accurate if images are not loaded+ response.render(OnLoadHeaderItem.forScript(script));}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/component/backtotop/BackToTop.html b/commons.wicket/src/main/java/com/pmease/commons/wicket/component/backtotop/BackToTop.htmlnew file mode 100644index 0000000000..fe702db63e--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/component/backtotop/BackToTop.html@@ -0,0 +1,3 @@+<wicket:panel>+ <div wicket:id="backToTop" class="back-to-top" title="Back to top"></div>+</wicket:panel>\ No newline at end of filediff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/component/backtotop/BackToTop.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/component/backtotop/BackToTop.javanew file mode 100644index 0000000000..7eb5033131--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/component/backtotop/BackToTop.java@@ -0,0 +1,31 @@+package com.pmease.commons.wicket.component.backtotop;++import org.apache.wicket.markup.head.IHeaderResponse;+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.panel.Panel;++@SuppressWarnings("serial")+public class BackToTop extends Panel {++ public BackToTop(String id) {+ super(id);+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(new WebMarkupContainer("backToTop") {++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);+ response.render(OnDomReadyHeaderItem.forScript(+ String.format("pmease.commons.backToTop('#%s');", getMarkupId())));+ }++ }.setOutputMarkupId(true));+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.cssindex 80e45307c8..f7d2905046 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css@@ -769,7 +769,6 @@ h2.section-title { margin: 18px 0; font-size: 16px; }/* COMPARE RESULT */.compare-result>tbody>tr>td {border: 1px solid #DDD;}.compare-result>tbody>tr>td.nav {width: 20%; padding: 8px;}-.compare-result>tbody>tr>td.nav>div {overflow-x: auto;}.compare-result>tbody>tr>td.nav a.active {background: #0F89E7; color: white; border-radius: 2px; padding: 2px;}.compare-result>tbody>tr>td.content>div>div.error {padding: 20px; font-size: 24px; font-style: italic;}@@ -803,7 +802,7 @@ h2.section-title { margin: 18px 0; font-size: 16px; }.table-diff table.content {width: 100%;}.table-diff .line.comments>td {padding: 0 12px; border-top: 1px solid #DDD;- border-bottom: 1px solid #DDD; background: #FFFAF5;}+ border-bottom: 1px solid #DDD;}.table-diff .line.comments td.avatar .concerned-comment {margin-top: 12px; font-size: 36px; color: #E7C325;}form#add-comment {margin: 16px 4px;}@@ -946,15 +945,16 @@ ul.status-help li:last-child .description {border-bottom: none;}.request-detail>.tabs {background: white; z-index: 100;}-.request-detail>.activities {margin-bottom: 20px;}+.request-detail>.activities {margin-bottom: 20px; border-bottom: 1px solid #DDD;}.request-detail>.activities>tbody>tr.discussion>td {border-top: 1px solid #DDD; padding: 12px 0;}.request-detail>.activities>tbody>tr.discussion.collapsed>td {padding: 8px 0;}.request-detail>.activities>tbody>tr.discussion>td.avatar {width: 1px; padding-right: 12px;}.request-detail>.activities>tbody>tr.discussion>td.activity {padding-left: 12px;}.request-detail>.activities>tbody>tr.activity>td.avatar {border-right: 1px dashed #CCC;}-.request-detail>.activities>tbody>tr.discussion+.non-discussion>td {border-top: 1px solid #DDD; padding-top: 12px;}+.request-detail>.activities>tbody>tr.discussion+.non-discussion>td {border-top: 1px solid #DDD; padding-top: 8px;}+.request-detail>.activities>tbody>tr.update.pre-discussion>td {padding-bottom: 8px;}.request-detail>.activities>tbody>tr.discussion>.avatar img {width: 40px; height: 40px;}-.request-detail>.activities>tbody>tr.non-discussion>td {padding: 0 6px;}+.request-detail>.activities>tbody>tr.non-discussion>td {padding-left: 6px;}.request-detail>.activities>tbody>tr.non-discussion.non-update>td {padding: 6px;}.request-detail>.activities>tbody>tr.non-discussion>td.avatar img {display: none;}.request-detail>.activities>tbody>tr.non-discussion>.activity>div.summary .user a {font-weight: normal;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.htmlindex f3b1f069bd..d12759cc9e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.html@@ -1,6 +1,6 @@<wicket:panel><div class="comment activity">- <div class="summary">+ <div wicket:id="summary" class="summary"><span wicket:id="user" class="user"></span> commented <span wicket:id="age"></span><span class="actions"><a wicket:id="edit" title="Edit comment"><span class="fa fa-pencil"></span></a>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.javaindex 4fb59dc594..1d15309b23 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java@@ -16,7 +16,9 @@ import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.markup.repeater.RepeatingView;+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 com.pmease.commons.wicket.behavior.ConfirmBehavior;@@ -24,9 +26,9 @@ import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.comment.Comment;import com.pmease.gitplex.core.comment.CommentReply;import com.pmease.gitplex.core.manager.AuthorizationManager;+import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;import com.pmease.gitplex.web.component.comment.event.CommentRemoved;import com.pmease.gitplex.web.component.comment.event.CommentReplied;-import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;import com.pmease.gitplex.web.component.label.AgeLabel;import com.pmease.gitplex.web.component.markdown.MarkdownPanel;import com.pmease.gitplex.web.component.user.AvatarMode;@@ -38,6 +40,24 @@ public class CommentPanel extends Panel {private RepeatingView repliesView;+ private IModel<List<CommentReply>> repliesModel = new LoadableDetachableModel<List<CommentReply>>() {++ @Override+ protected List<CommentReply> load() {+ List<CommentReply> replies = new ArrayList<>(getComment().getReplies());+ Collections.sort(replies, new Comparator<CommentReply>() {++ @Override+ public int compare(CommentReply reply1, CommentReply reply2) {+ return reply1.getDate().compareTo(reply2.getDate());+ }++ });+ return replies;+ }++ };+public CommentPanel(String id, IModel<? extends Comment> commentModel) {super(id, commentModel);}@@ -57,10 +77,14 @@ public class CommentPanel extends Panel {protected void onInitialize() {super.onInitialize();- add(new UserLink("user", new UserModel(getComment().getUser()), AvatarMode.NAME));- add(new AgeLabel("age", Model.of(getComment().getDate())));+ final WebMarkupContainer summary = new WebMarkupContainer("summary");+ summary.setOutputMarkupId(true);+ add(summary);++ summary.add(new UserLink("user", new UserModel(getComment().getUser()), AvatarMode.NAME));+ summary.add(new AgeLabel("age", Model.of(getComment().getDate())));- add(new AjaxLink<Void>("edit") {+ summary.add(new AjaxLink<Void>("edit") {@Overridepublic void onClick(AjaxRequestTarget target) {@@ -117,7 +141,7 @@ public class CommentPanel extends Panel {});- add(new AjaxLink<Void>("delete") {+ summary.add(new AjaxLink<Void>("delete") {@Overridepublic void onClick(AjaxRequestTarget target) {@@ -135,7 +159,7 @@ public class CommentPanel extends Panel {}.add(new ConfirmBehavior("Deleting this comment will also delete all its replies. Do you really want to continue?")));final AjaxLink<Void> resolveLink;- add(resolveLink = new AjaxLink<Void>("resolve") {+ summary.add(resolveLink = new AjaxLink<Void>("resolve") {@Overridepublic void onClick(AjaxRequestTarget target) {@@ -143,7 +167,7 @@ public class CommentPanel extends Panel {if (getComment().isResolved())send(CommentPanel.this, Broadcast.BUBBLE, new CommentCollapsing(target, getComment()));if (findPage() != null) // only render this checkbox if the whole comment panel is not replaced- target.add(this);+ target.add(summary);}@Override@@ -169,7 +193,7 @@ public class CommentPanel extends Panel {});resolveLink.setOutputMarkupId(true);- add(new WebMarkupContainer("resolved") {+ summary.add(new WebMarkupContainer("resolved") {@Overrideprotected void onConfigure() {@@ -181,7 +205,14 @@ public class CommentPanel extends Panel {});- add(newAdditionalCommentActions("additionalActions", getComment()));+ summary.add(newAdditionalCommentActions("additionalActions", new AbstractReadOnlyModel<Comment>() {++ @Override+ public Comment getObject() {+ return getComment();+ }++ }));add(renderForView(getComment().getContent()));@@ -223,7 +254,7 @@ public class CommentPanel extends Panel {CommentReply newReply = getComment().addReply(input.getModelObject());send(CommentPanel.this, Broadcast.BUBBLE, new CommentReplied(target, newReply));- Component newReplyRow = newReplyRow(repliesView.newChildId(), newReply);+ Component newReplyRow = newReplyRow(repliesView.newChildId(), repliesModel.getObject().size()-1);repliesView.add(newReplyRow);String script = String.format("$(\"<tr id='%s' class='reply'></tr>\").insertBefore('#%s');",newReplyRow.getMarkupId(), row.getMarkupId());@@ -263,17 +294,8 @@ public class CommentPanel extends Panel {private RepeatingView newRepliesView() {RepeatingView repliesView = new RepeatingView("replies");- List<CommentReply> replies = new ArrayList<>(getComment().getReplies());- Collections.sort(replies, new Comparator<CommentReply>() {-- @Override- public int compare(CommentReply reply1, CommentReply reply2) {- return reply1.getDate().compareTo(reply2.getDate());- }-- });- for (CommentReply reply: replies)- repliesView.add(newReplyRow(repliesView.newChildId(), reply));+ for (int i=0; i<repliesModel.getObject().size(); i++)+ repliesView.add(newReplyRow(repliesView.newChildId(), i));return repliesView;}@@ -285,10 +307,11 @@ public class CommentPanel extends Panel {super.onBeforeRender();}- private Component newReplyRow(String id, final CommentReply reply) {- final WebMarkupContainer row = new WebMarkupContainer(id);+ private Component newReplyRow(String id, int index) {+ final WebMarkupContainer row = new WebMarkupContainer(id, Model.of(index));row.setOutputMarkupId(true);+ CommentReply reply = repliesModel.getObject().get(index);row.add(new UserLink("avatar", new UserModel(reply.getUser()), AvatarMode.AVATAR));row.add(new UserLink("user", new UserModel(reply.getUser()), AvatarMode.NAME));row.add(new AgeLabel("age", Model.of(reply.getDate())));@@ -301,6 +324,7 @@ public class CommentPanel extends Panel {Form<?> form = new Form<Void>("form");fragment.add(form);+ CommentReply reply = repliesModel.getObject().get((int)row.getDefaultModelObject());final CommentInput input = new CommentInput("input", Model.of(reply.getContent()));input.setRequired(true);form.add(input);@@ -309,6 +333,7 @@ public class CommentPanel extends Panel {@Overrideprotected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ CommentReply reply = repliesModel.getObject().get((int)row.getDefaultModelObject());reply.saveContent(input.getModelObject());Fragment fragment = renderForView(reply.getContent());@@ -328,6 +353,7 @@ public class CommentPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {+ CommentReply reply = repliesModel.getObject().get((int)row.getDefaultModelObject());Fragment fragment = renderForView(reply.getContent());row.replace(fragment);target.add(fragment);@@ -353,8 +379,16 @@ public class CommentPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {+ int index = (int)row.getDefaultModelObject();+ CommentReply reply = repliesModel.getObject().get(index);+ repliesModel.getObject().remove(index);reply.delete();row.remove();+ for (int i=index; i<repliesView.size(); i++) {+ Component child = repliesView.get(i);+ child.setDefaultModelObject((int)child.getDefaultModelObject()-1);+ }+target.appendJavaScript(String.format("$('#%s').remove();", row.getMarkupId()));}@@ -367,19 +401,33 @@ public class CommentPanel extends Panel {}.add(new ConfirmBehavior("Do you really want to delete this reply?")));- row.add(newAdditionalReplyActions("additionalActions", reply));+ row.add(newAdditionalReplyActions("additionalActions", new AbstractReadOnlyModel<CommentReply>() {++ @Override+ public CommentReply getObject() {+ return repliesModel.getObject().get((int)row.getDefaultModelObject());+ }++ }));row.add(renderForView(reply.getContent()));return row;}- protected Component newAdditionalCommentActions(String id, Comment comment) {+ protected Component newAdditionalCommentActions(String id, IModel<Comment> comment) {return new WebMarkupContainer(id);}- protected Component newAdditionalReplyActions(String id, CommentReply reply) {+ protected Component newAdditionalReplyActions(String id, IModel<CommentReply> reply) {return new WebMarkupContainer(id);}++ @Override+ protected void onDetach() {+ repliesModel.detach();++ super.onDetach();+ }}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.htmlindex 65ba575c74..c7f12f9da2 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html@@ -13,14 +13,14 @@<span wicket:id="displayFull" class="btn btn-xs btn-default" title="Expand to display full file"><i class="fa fa-file-txt"></i> </span></div><div class="btn-group pull-right">- <span wicket:id="prevComment" class="btn btn-default btn-xs comments-nav" title="Previous commented line"><i class="fa fa-arrow-up"></i> <i class="fa fa-comments"></i></span>- <span wicket:id="nextComment" class="btn btn-default btn-xs comments-nav" title="Next commented line"><i class="fa fa-arrow-down"></i> <i class="fa fa-comments"></i></span>+ <span wicket:id="prevComment" class="btn btn-default btn-xs comments-nav" title="Previous comment not in view"><i class="fa fa-arrow-up"></i> <i class="fa fa-comments"></i></span>+ <span wicket:id="nextComment" class="btn btn-default btn-xs comments-nav" title="Next comment not in view"><i class="fa fa-arrow-down"></i> <i class="fa fa-comments"></i></span><span wicket:id="showComments" class="btn btn-default btn-xs show-comments" title="Show comments"><i class="fa fa-eye-open"></i> <i class="fa fa-comments"></i></span><span wicket:id="hideComments" class="btn btn-default btn-xs hide-comments" title="Hide comments"><i class="fa fa-eye-slash"></i> <i class="fa fa-comments"></i></span></div><div wicket:id="diffNavs" class="btn-group pull-right">- <span wicket:id="prevDiff" class="btn btn-default btn-xs" title="Previous changed block"><i class="fa fa-arrow-up"></i> <i class="fa fa-diff"></i></span>- <span wicket:id="nextDiff" class="btn btn-default btn-xs" title="Next changed block"><i class="fa fa-arrow-down"></i> <i class="fa fa-diff"></i></span>+ <span wicket:id="prevDiff" class="btn btn-default btn-xs" title="Previous change not in view"><i class="fa fa-arrow-up"></i> <i class="fa fa-diff"></i></span>+ <span wicket:id="nextDiff" class="btn btn-default btn-xs" title="Next change not in view"><i class="fa fa-arrow-down"></i> <i class="fa fa-diff"></i></span></div><div class="pull-right"><span wicket:id="identical" class="label label-warning">Identical Content</span>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestActivitiesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestActivitiesPage.javaindex 0ea4a31acb..929deb8b1f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestActivitiesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestActivitiesPage.java@@ -1,5 +1,8 @@package com.pmease.gitplex.web.page.repository.info.pullrequest;+import java.util.ArrayList;+import java.util.Collections;+import java.util.Comparator;import java.util.List;import org.apache.wicket.Component;@@ -22,7 +25,13 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.manager.UserManager;import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestAction.Approve;+import com.pmease.gitplex.core.model.PullRequestAction.Disapprove;+import com.pmease.gitplex.core.model.PullRequestAction.Discard;+import com.pmease.gitplex.core.model.PullRequestAction.Integrate;+import com.pmease.gitplex.core.model.PullRequestAudit;import com.pmease.gitplex.core.model.PullRequestComment;+import com.pmease.gitplex.core.model.PullRequestUpdate;import com.pmease.gitplex.web.component.comment.CommentInput;import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;import com.pmease.gitplex.web.component.comment.event.CommentRemoved;@@ -30,10 +39,13 @@ import com.pmease.gitplex.web.component.label.AgeLabel;import com.pmease.gitplex.web.component.user.AvatarMode;import com.pmease.gitplex.web.component.user.UserLink;import com.pmease.gitplex.web.model.UserModel;+import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.ApprovePullRequest;import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.CommentPullRequest;+import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.DisapprovePullRequest;+import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.DiscardPullRequest;+import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.IntegratePullRequest;import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.OpenPullRequest;import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.PullRequestActivity;-import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.RequestActivitiesModel;import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.UpdatePullRequest;@SuppressWarnings("serial")@@ -137,16 +149,57 @@ public class RequestActivitiesPage extends RequestDetailPage {activitiesView = new RepeatingView("activities");activitiesView.setOutputMarkupId(true);- List<PullRequestActivity> activities = new RequestActivitiesModel() {-+ PullRequest request = getPullRequest();+ List<PullRequestActivity> activities = new ArrayList<>();++ activities.add(new OpenPullRequest(request));++ for (PullRequestUpdate update: request.getUpdates())+ activities.add(new UpdatePullRequest(update));++ for (PullRequestComment comment: request.getComments())+ activities.add(new CommentPullRequest(comment));++ for (PullRequestAudit audit: request.getAudits()) {+ if (audit.getAction() instanceof Integrate) {+ Integrate integrate = (Integrate) audit.getAction();+ activities.add(new IntegratePullRequest(audit.getUser(), audit.getDate(),+ integrate.getReason()));+ } else if (audit.getAction() instanceof Discard) {+ activities.add(new DiscardPullRequest(audit.getUser(), audit.getDate()));+ } else if (audit.getAction() instanceof Approve) {+ activities.add(new ApprovePullRequest(audit.getRequest(), audit.getUser(), audit.getDate()));+ } else if (audit.getAction() instanceof Disapprove) {+ activities.add(new DisapprovePullRequest(audit.getRequest(), audit.getUser(), audit.getDate()));+ } else {+ throw new IllegalStateException("Unexpected audit action: " + audit.getAction());+ }+ }++ Collections.sort(activities, new Comparator<PullRequestActivity>() {+@Override- protected PullRequest getPullRequest() {- return RequestActivitiesPage.this.getPullRequest();+ public int compare(PullRequestActivity o1, PullRequestActivity o2) {+ if (o1.getDate().before(o2.getDate()))+ return -1;+ else if (o1.getDate().after(o2.getDate()))+ return 1;+ else if (o1 instanceof OpenPullRequest || o1 instanceof CommentPullRequest)+ return -1;+ else+ return 1;}- }.getObject();++ });- for (PullRequestActivity activity: activities)- activitiesView.add(newActivityItem(activitiesView.newChildId(), activity));+ int index = 0;+ for (PullRequestActivity activity: activities) {+ Component activityItem = newActivityItem(activitiesView.newChildId(), activity);+ if (index == activities.size()-1 || activities.get(index+1) instanceof CommentPullRequest)+ activityItem.add(AttributeAppender.append("class", " pre-discussion"));+ activitiesView.add(activityItem);+ index++;+ }return activitiesView;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.javaindex 166105a5ae..4b65a33518 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java@@ -53,7 +53,6 @@ import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.web.component.comment.event.CommentRemoved;import com.pmease.gitplex.web.component.comment.event.CommentReplied;import com.pmease.gitplex.web.component.diff.CompareResultPanel;-import com.pmease.gitplex.web.page.repository.info.pullrequest.activity.RequestActivitiesModel;import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig.Placement;@@ -66,7 +65,7 @@ public class RequestComparePage extends RequestDetailPage {private static final String INTEGRATION_PREVIEW = "Integration Preview";public static final String LATEST_COMMIT = "latest";-+private String file;private String oldCommit;@@ -75,14 +74,6 @@ public class RequestComparePage extends RequestDetailPage {private final IModel<PullRequestComment> concernedCommentModel;- private final RequestActivitiesModel activitiesModel = new RequestActivitiesModel() {-- @Override- protected PullRequest getPullRequest() {- return RequestComparePage.this.getPullRequest();- }- };-private final IModel<Map<String, CommitDescription>> commitsModel =new LoadableDetachableModel<Map<String, CommitDescription>>() {@@ -294,7 +285,7 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect() {PageParameters params = paramsOf(getPullRequest(),- getConcernedComment().getCommit(), null, null,+ getConcernedComment().getCommit(), LATEST_COMMIT, null,getConcernedComment());setResponsePage(RequestComparePage.class, params);}@@ -307,8 +298,7 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect() {PageParameters params = paramsOf(getPullRequest(),- getPullRequest().getBaseCommit(),- getPullRequest().getLatestUpdate().getHeadCommit(),+ getPullRequest().getBaseCommit(), LATEST_COMMIT,file, getConcernedComment());setResponsePage(RequestComparePage.class, params);}@@ -454,7 +444,6 @@ public class RequestComparePage extends RequestDetailPage {public void onDetach() {commitsModel.detach();concernedCommentModel.detach();- activitiesModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.htmlindex 74007d05d6..7f3afe51f3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.html@@ -46,6 +46,7 @@</div><div wicket:id="tabs" class="tabs"></div><wicket:child></wicket:child>+ <div wicket:id="backToTop"></div></div><wicket:fragment wicket:id="integratedFrag"><div class="integrated alert alert-success">diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.javaindex e76b77b1b0..01db4f3fb1 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java@@ -39,6 +39,7 @@ import org.eclipse.jgit.lib.PersonIdent;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.wicket.behavior.dropdown.DropdownBehavior;import com.pmease.commons.wicket.behavior.dropdown.DropdownPanel;+import com.pmease.commons.wicket.component.backtotop.BackToTop;import com.pmease.commons.wicket.component.feedback.FeedbackPanel;import com.pmease.commons.wicket.component.tabbable.PageTab;import com.pmease.commons.wicket.component.tabbable.PageTabLink;@@ -371,6 +372,8 @@ public abstract class RequestDetailPage extends RepositoryInfoPage implements Cotabs.add(new RequestTab("Updates", RequestUpdatesPage.class));tabs.add(new RequestTab("Compare", RequestComparePage.class));add(new Tabbable("tabs", tabs));++ add(new BackToTop("backToTop"));}private Component newStatusComponent(String id) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.htmlindex bfa150670a..b5e6f7f67f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.html@@ -10,10 +10,14 @@<div class="panel-heading"><span wicket:id="file"></span><span class="actions">- <a wicket:id="compareWithLatest" class="fa fa-diff" title="Display comment by comparing with latest commit"></a>+ <a wicket:id="compareView" class="fa fa-diff" title="Display comment in compare view"></a></span></div><div wicket:id="comment"></div></div></wicket:fragment>+ <wicket:fragment wicket:id="commentActionsFrag">+ <a wicket:id="collapse" class="fa fa-collapse" title="Collapse this comment"></a>+ <span wicket:id="changes"></span>+ </wicket:fragment></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.javaindex 5e72a97cd4..aac8007b5e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.java@@ -1,6 +1,9 @@package com.pmease.gitplex.web.page.repository.info.pullrequest.activity;import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.event.Broadcast;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.link.BookmarkablePageLink;import org.apache.wicket.markup.html.panel.Fragment;@@ -15,6 +18,7 @@ import com.pmease.gitplex.core.comment.CommentReply;import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestComment;import com.pmease.gitplex.web.component.comment.CommentPanel;+import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;import com.pmease.gitplex.web.component.label.AgeLabel;import com.pmease.gitplex.web.component.user.AvatarMode;import com.pmease.gitplex.web.component.user.UserLink;@@ -44,8 +48,9 @@ public class CommentActivityPanel extends Panel {fragment.add(new Label("file", comment.getFile()));- PageParameters params = RequestComparePage.paramsOf(comment.getRequest(), comment.getCommit(), null, null, comment);- fragment.add(new BookmarkablePageLink<Void>("compareWithLatest", RequestComparePage.class, params));+ PageParameters params = RequestComparePage.paramsOf(comment.getRequest(), comment.getOldCommit(),+ comment.getNewCommit(), null, comment);+ fragment.add(new BookmarkablePageLink<Void>("compareView", RequestComparePage.class, params));fragment.add(new InlineCommentPanel("comment", commentModel));fragment.setRenderBodyOnly(true);@@ -54,19 +59,48 @@ public class CommentActivityPanel extends Panel {add(new CommentPanel("content", commentModel) {@Override- protected Component newAdditionalCommentActions(String id, Comment comment) {- return new SinceChangesPanel(id, new AbstractReadOnlyModel<PullRequest>() {+ protected Component newAdditionalCommentActions(String id, final IModel<Comment> commentModel) {+ Fragment fragment = new Fragment(id, "commentActionsFrag", CommentActivityPanel.this) {++ @Override+ protected void onDetach() {+ commentModel.detach();+ super.onDetach();+ }++ };++ fragment.add(new AjaxLink<Void>("collapse") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ send(CommentActivityPanel.this, Broadcast.BUBBLE,+ new CommentCollapsing(target, commentModel.getObject()));+ }++ @Override+ protected void onConfigure() {+ super.onConfigure();++ setVisible(commentModel.getObject().isResolved());+ }++ });++ fragment.add(new SinceChangesPanel("changes", new AbstractReadOnlyModel<PullRequest>() {@Overridepublic PullRequest getObject() {- return commentModel.getObject().getRequest();+ return CommentActivityPanel.this.commentModel.getObject().getRequest();}- }, comment.getDate(), "Changes since this comment");+ }, CommentActivityPanel.this.commentModel.getObject().getDate(), "Changes since this comment"));++ return fragment;}@Override- protected Component newAdditionalReplyActions(String id, CommentReply reply) {+ protected Component newAdditionalReplyActions(String id, final IModel<CommentReply> replyModel) {return new SinceChangesPanel(id, new AbstractReadOnlyModel<PullRequest>() {@Override@@ -74,7 +108,15 @@ public class CommentActivityPanel extends Panel {return commentModel.getObject().getRequest();}- }, reply.getDate(), "Changes since this reply");+ }, replyModel.getObject().getDate(), "Changes since this reply") {++ @Override+ protected void onDetach() {+ replyModel.detach();+ super.onDetach();+ }++ };}});diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.javaindex 906d2d7c33..b4e0ac47d9 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.java@@ -5,7 +5,12 @@ import static com.pmease.commons.util.diff.DiffLine.Action.DELETE;import java.util.List;+import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.event.Broadcast;+import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.list.ListItem;@@ -16,8 +21,10 @@ import org.apache.wicket.model.IModel;import com.pmease.commons.util.diff.DiffLine;import com.pmease.commons.util.diff.Partial;+import com.pmease.gitplex.core.comment.Comment;import com.pmease.gitplex.core.comment.InlineComment;import com.pmease.gitplex.web.component.comment.CommentPanel;+import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;@SuppressWarnings("serial")public class InlineCommentPanel extends Panel {@@ -101,10 +108,42 @@ public class InlineCommentPanel extends Panel {});InlineComment comment = commentModel.getObject();- if (item.getIndex() == comment.getContext().getCommentLine())- item.add(new CommentPanel("comment", commentModel));- else+ if (item.getIndex() == comment.getContext().getCommentLine()) {+ item.add(new CommentPanel("comment", commentModel) {++ @Override+ protected Component newAdditionalCommentActions(String id, IModel<Comment> comment) {+ return new AjaxLink<Void>(id) {++ @Override+ public void onClick(AjaxRequestTarget target) {+ send(InlineCommentPanel.this, Broadcast.BUBBLE,+ new CommentCollapsing(target, commentModel.getObject()));+ }++ @Override+ protected void onConfigure() {+ super.onConfigure();++ setVisible(commentModel.getObject().isResolved());+ }++ @Override+ protected void onComponentTag(ComponentTag tag) {+ super.onComponentTag(tag);+ tag.put("class", "fa fa-collapse");+ tag.put("title", "Collapse this comment");+ tag.put("style", "cursor:pointer;");+ }++ };++ }++ });+ } else {item.add(new WebMarkupContainer("comment").setVisible(false));+ }}});diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/RequestActivitiesModel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/RequestActivitiesModel.javadeleted file mode 100644index 019674343c..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/RequestActivitiesModel.java+++ /dev/null@@ -1,70 +0,0 @@-package com.pmease.gitplex.web.page.repository.info.pullrequest.activity;--import java.util.ArrayList;-import java.util.Collections;-import java.util.Comparator;-import java.util.List;--import org.apache.wicket.model.LoadableDetachableModel;--import com.pmease.gitplex.core.model.PullRequest;-import com.pmease.gitplex.core.model.PullRequestAction.Approve;-import com.pmease.gitplex.core.model.PullRequestAction.Disapprove;-import com.pmease.gitplex.core.model.PullRequestAction.Discard;-import com.pmease.gitplex.core.model.PullRequestAction.Integrate;-import com.pmease.gitplex.core.model.PullRequestAudit;-import com.pmease.gitplex.core.model.PullRequestComment;-import com.pmease.gitplex.core.model.PullRequestUpdate;--@SuppressWarnings("serial")-public abstract class RequestActivitiesModel extends LoadableDetachableModel<List<PullRequestActivity>> {-- @Override- protected List<PullRequestActivity> load() {- PullRequest request = getPullRequest();- List<PullRequestActivity> activities = new ArrayList<>();-- activities.add(new OpenPullRequest(request));-- for (PullRequestUpdate update: request.getUpdates())- activities.add(new UpdatePullRequest(update));-- for (PullRequestComment comment: request.getComments())- activities.add(new CommentPullRequest(comment));-- for (PullRequestAudit audit: request.getAudits()) {- if (audit.getAction() instanceof Integrate) {- Integrate integrate = (Integrate) audit.getAction();- activities.add(new IntegratePullRequest(audit.getUser(), audit.getDate(),- integrate.getReason()));- } else if (audit.getAction() instanceof Discard) {- activities.add(new DiscardPullRequest(audit.getUser(), audit.getDate()));- } else if (audit.getAction() instanceof Approve) {- activities.add(new ApprovePullRequest(audit.getRequest(), audit.getUser(), audit.getDate()));- } else if (audit.getAction() instanceof Disapprove) {- activities.add(new DisapprovePullRequest(audit.getRequest(), audit.getUser(), audit.getDate()));- } else {- throw new IllegalStateException("Unexpected audit action: " + audit.getAction());- }- }-- Collections.sort(activities, new Comparator<PullRequestActivity>() {-- @Override- public int compare(PullRequestActivity o1, PullRequestActivity o2) {- if (o1.getDate().before(o2.getDate()))- return -1;- else if (o1.getDate().after(o2.getDate()))- return 1;- else if (o1 instanceof OpenPullRequest || o1 instanceof CommentPullRequest)- return -1;- else- return 1;- }-- });- return activities;- }-- protected abstract PullRequest getPullRequest();-}