The Unified and Autonomous Development Platform
Auto update request activities page via web socket if there are new comments or replies.
robin shine641a360e782c
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketProcessor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketProcessor.javaindex 93edc546a7..86621e64f7 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketProcessor.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketProcessor.java@@ -19,6 +19,7 @@ package com.pmease.commons.wicket.websocket;import java.util.concurrent.Callable;import org.apache.shiro.subject.PrincipalCollection;+import org.apache.shiro.subject.SimplePrincipalCollection;import org.apache.shiro.subject.Subject;import org.apache.shiro.subject.support.DefaultSubjectContext;import org.apache.shiro.util.ThreadContext;@@ -84,6 +85,8 @@ public class WebSocketProcessor extends AbstractWebSocketProcessor implements Wetry {PrincipalCollection principals = (PrincipalCollection) request.getSession().getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);+ if (principals == null)+ principals = new SimplePrincipalCollection(0L, "");WebSecurityManager securityManager = AppLoader.getInstance(WebSecurityManager.class);ThreadContext.bind(new Subject.Builder(securityManager).principals(principals).buildSubject());diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.javaindex 7514ec92a6..794c138e94 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java@@ -98,6 +98,10 @@ public class CoreModule extends AbstractPluginModule {@Overridepublic void onIntegrationPreviewCalculated(PullRequest request) {}++ @Override+ public void onCommented(PullRequest request) {+ }});diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/extensionpoint/PullRequestListener.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/extensionpoint/PullRequestListener.javaindex ccf58a91e3..620bc715ba 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/extensionpoint/PullRequestListener.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/extensionpoint/PullRequestListener.java@@ -9,6 +9,8 @@ public interface PullRequestListener {void onUpdated(PullRequest request);+ void onCommented(PullRequest request);+void onVoted(PullRequest request);void onIntegrated(PullRequest request);diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.javanew file mode 100644index 0000000000..25ff87ac5b--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java@@ -0,0 +1,12 @@+package com.pmease.gitplex.core.manager;++import com.google.inject.ImplementedBy;+import com.pmease.gitplex.core.manager.impl.DefaultPullRequestCommentManager;+import com.pmease.gitplex.core.model.PullRequestComment;++@ImplementedBy(DefaultPullRequestCommentManager.class)+public interface PullRequestCommentManager {++ void save(PullRequestComment comment);++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentReplyManager.javanew file mode 100644index 0000000000..00b8ddc808--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentReplyManager.java@@ -0,0 +1,12 @@+package com.pmease.gitplex.core.manager;++import com.google.inject.ImplementedBy;+import com.pmease.gitplex.core.manager.impl.DefaultPullRequestCommentReplyManager;+import com.pmease.gitplex.core.model.PullRequestCommentReply;++@ImplementedBy(DefaultPullRequestCommentReplyManager.class)+public interface PullRequestCommentReplyManager {++ void save(PullRequestCommentReply reply);++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentManager.javaindex 800017a845..ff335b3f1f 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentManager.java@@ -14,4 +14,6 @@ public interface PullRequestInlineCommentManager {* comment to be updated*/void update(PullRequestInlineComment comment);++ void save(PullRequestInlineComment comment);}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentReplyManager.javanew file mode 100644index 0000000000..70b6ef7242--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestInlineCommentReplyManager.java@@ -0,0 +1,12 @@+package com.pmease.gitplex.core.manager;++import com.google.inject.ImplementedBy;+import com.pmease.gitplex.core.manager.impl.DefaultPullRequestInlineCommentReplyManager;+import com.pmease.gitplex.core.model.PullRequestInlineCommentReply;++@ImplementedBy(DefaultPullRequestInlineCommentReplyManager.class)+public interface PullRequestInlineCommentReplyManager {++ void save(PullRequestInlineCommentReply reply);++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.javanew file mode 100644index 0000000000..d8ffd56350--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java@@ -0,0 +1,51 @@+package com.pmease.gitplex.core.manager.impl;++import javax.inject.Inject;+import javax.inject.Singleton;++import com.pmease.commons.hibernate.Transactional;+import com.pmease.commons.hibernate.dao.Dao;+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;+import com.pmease.gitplex.core.extensionpoint.PullRequestListeners;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;+import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestComment;++@Singleton+public class DefaultPullRequestCommentManager implements PullRequestCommentManager {++ private final Dao dao;++ private final PullRequestListeners pullRequestListeners;++ @Inject+ public DefaultPullRequestCommentManager(Dao dao, PullRequestListeners pullRequestListeners) {+ this.dao = dao;+ this.pullRequestListeners = pullRequestListeners;+ }++ @Transactional+ @Override+ public void save(PullRequestComment comment) {+ dao.persist(comment);++ final Long requestId = comment.getRequest().getId();++ dao.afterCommit(new Runnable() {++ @Override+ public void run() {+ pullRequestListeners.asyncCall(requestId, new PullRequestListeners.Callback() {++ @Override+ protected void call(PullRequestListener listener, PullRequest request) {+ listener.onCommented(request);+ }++ });+ }++ });+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.javanew file mode 100644index 0000000000..3adf5d353c--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentReplyManager.java@@ -0,0 +1,51 @@+package com.pmease.gitplex.core.manager.impl;++import javax.inject.Inject;+import javax.inject.Singleton;++import com.pmease.commons.hibernate.Transactional;+import com.pmease.commons.hibernate.dao.Dao;+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;+import com.pmease.gitplex.core.extensionpoint.PullRequestListeners;+import com.pmease.gitplex.core.manager.PullRequestCommentReplyManager;+import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestCommentReply;++@Singleton+public class DefaultPullRequestCommentReplyManager implements PullRequestCommentReplyManager {++ private final Dao dao;++ private final PullRequestListeners pullRequestListeners;++ @Inject+ public DefaultPullRequestCommentReplyManager(Dao dao, PullRequestListeners pullRequestListeners) {+ this.dao = dao;+ this.pullRequestListeners = pullRequestListeners;+ }++ @Transactional+ @Override+ public void save(PullRequestCommentReply reply) {+ dao.persist(reply);++ final Long requestId = reply.getComment().getRequest().getId();++ dao.afterCommit(new Runnable() {++ @Override+ public void run() {+ pullRequestListeners.asyncCall(requestId, new PullRequestListeners.Callback() {++ @Override+ protected void call(PullRequestListener listener, PullRequest request) {+ listener.onCommented(request);+ }++ });+ }++ });+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentManager.javaindex 6310d45852..058beddc69 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentManager.java@@ -10,13 +10,17 @@ import com.google.common.base.Preconditions;import com.pmease.commons.git.BlobInfo;import com.pmease.commons.git.BlobText;import com.pmease.commons.git.Change;+import com.pmease.commons.hibernate.Transactional;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.diff.AroundContext;import com.pmease.commons.util.diff.DiffLine;import com.pmease.commons.util.diff.DiffUtils;import com.pmease.commons.util.diff.WordSplitter;import com.pmease.gitplex.core.comment.InlineComment;+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;+import com.pmease.gitplex.core.extensionpoint.PullRequestListeners;import com.pmease.gitplex.core.manager.PullRequestInlineCommentManager;+import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestInlineComment;@Singleton@@ -24,9 +28,12 @@ public class DefaultPullRequestInlineCommentManager implements PullRequestInlineprivate final Dao dao;+ private final PullRequestListeners pullRequestListeners;+@Inject- public DefaultPullRequestInlineCommentManager(Dao dao) {+ public DefaultPullRequestInlineCommentManager(Dao dao, PullRequestListeners pullRequestListeners) {this.dao = dao;+ this.pullRequestListeners = pullRequestListeners;}@Override@@ -145,4 +152,28 @@ public class DefaultPullRequestInlineCommentManager implements PullRequestInline}}+ @Transactional+ @Override+ public void save(PullRequestInlineComment comment) {+ dao.persist(comment);++ final Long requestId = comment.getRequest().getId();++ dao.afterCommit(new Runnable() {++ @Override+ public void run() {+ pullRequestListeners.asyncCall(requestId, new PullRequestListeners.Callback() {++ @Override+ protected void call(PullRequestListener listener, PullRequest request) {+ listener.onCommented(request);+ }++ });+ }++ });+ }+}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentReplyManager.javanew file mode 100644index 0000000000..5d0551de20--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestInlineCommentReplyManager.java@@ -0,0 +1,51 @@+package com.pmease.gitplex.core.manager.impl;++import javax.inject.Inject;+import javax.inject.Singleton;++import com.pmease.commons.hibernate.Transactional;+import com.pmease.commons.hibernate.dao.Dao;+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;+import com.pmease.gitplex.core.extensionpoint.PullRequestListeners;+import com.pmease.gitplex.core.manager.PullRequestInlineCommentReplyManager;+import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestInlineCommentReply;++@Singleton+public class DefaultPullRequestInlineCommentReplyManager implements PullRequestInlineCommentReplyManager {++ private final Dao dao;++ private final PullRequestListeners pullRequestListeners;++ @Inject+ public DefaultPullRequestInlineCommentReplyManager(Dao dao, PullRequestListeners pullRequestListeners) {+ this.dao = dao;+ this.pullRequestListeners = pullRequestListeners;+ }++ @Transactional+ @Override+ public void save(PullRequestInlineCommentReply reply) {+ dao.persist(reply);++ final Long requestId = reply.getComment().getRequest().getId();++ dao.afterCommit(new Runnable() {++ @Override+ public void run() {+ pullRequestListeners.asyncCall(requestId, new PullRequestListeners.Callback() {++ @Override+ protected void call(PullRequestListener listener, PullRequest request) {+ listener.onCommented(request);+ }++ });+ }++ });+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.javaindex 912113d62c..b2751bf4a9 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java@@ -35,7 +35,6 @@ import com.pmease.commons.util.FileUtils;import com.pmease.gitplex.core.extensionpoint.PullRequestListener;import com.pmease.gitplex.core.extensionpoint.PullRequestListeners;import com.pmease.gitplex.core.manager.BranchManager;-import com.pmease.gitplex.core.manager.PullRequestInlineCommentManager;import com.pmease.gitplex.core.manager.PullRequestManager;import com.pmease.gitplex.core.manager.PullRequestUpdateManager;import com.pmease.gitplex.core.manager.StorageManager;@@ -47,7 +46,6 @@ import com.pmease.gitplex.core.model.PullRequest.CloseStatus;import com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy;import com.pmease.gitplex.core.model.PullRequestAudit;import com.pmease.gitplex.core.model.PullRequestComment;-import com.pmease.gitplex.core.model.PullRequestInlineComment;import com.pmease.gitplex.core.model.PullRequestOperation;import com.pmease.gitplex.core.model.PullRequestUpdate;import com.pmease.gitplex.core.model.Repository;@@ -68,8 +66,6 @@ public class DefaultPullRequestManager implements PullRequestManager {private final UnitOfWork unitOfWork;- private final PullRequestInlineCommentManager pullRequestInlineCommentManager;-private final PullRequestListeners pullRequestListeners;private final Set<Long> calculatingRequestIds = new ConcurrentHashSet<>();@@ -77,15 +73,13 @@ public class DefaultPullRequestManager implements PullRequestManager {@Injectpublic DefaultPullRequestManager(Dao dao, PullRequestUpdateManager pullRequestUpdateManager,BranchManager branchManager, StorageManager storageManager,- UnitOfWork unitOfWork, PullRequestListeners pullRequestListeners,- PullRequestInlineCommentManager pullRequestInlineCommentManager) {+ UnitOfWork unitOfWork, PullRequestListeners pullRequestListeners) {this.dao = dao;this.pullRequestUpdateManager = pullRequestUpdateManager;this.branchManager = branchManager;this.storageManager = storageManager;this.unitOfWork = unitOfWork;this.pullRequestListeners = pullRequestListeners;- this.pullRequestInlineCommentManager = pullRequestInlineCommentManager;}@Sessional@@ -359,35 +353,6 @@ public class DefaultPullRequestManager implements PullRequestManager {request.getUpdates().add(update);pullRequestUpdateManager.save(update);-- final Long requestId = request.getId();-- dao.afterCommit(new Runnable() {-- @Override- public void run() {- unitOfWork.asyncCall(new Runnable() {-- @Override- public void run() {- PullRequest request = dao.load(PullRequest.class, requestId);- for (PullRequestInlineComment comment: request.getInlineComments())- pullRequestInlineCommentManager.update((PullRequestInlineComment) comment);-- pullRequestListeners.call(request, new PullRequestListeners.Callback() {-- @Override- protected void call(PullRequestListener listener, PullRequest request) {- listener.onUpdated(request);- }-- });- }-- });- }-- });}@Transactionaldiff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.javaindex 475a3c71e8..7606f8df63 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.java@@ -4,11 +4,16 @@ import javax.inject.Inject;import javax.inject.Singleton;import com.pmease.commons.hibernate.Transactional;+import com.pmease.commons.hibernate.UnitOfWork;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.FileUtils;+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;+import com.pmease.gitplex.core.extensionpoint.PullRequestListeners;+import com.pmease.gitplex.core.manager.PullRequestInlineCommentManager;import com.pmease.gitplex.core.manager.PullRequestUpdateManager;import com.pmease.gitplex.core.manager.StorageManager;import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.core.model.PullRequestInlineComment;import com.pmease.gitplex.core.model.PullRequestUpdate;@Singleton@@ -18,10 +23,21 @@ public class DefaultPullRequestUpdateManager implements PullRequestUpdateManagerprivate final StorageManager storageManager;+ private final PullRequestListeners pullRequestListeners;++ private final UnitOfWork unitOfWork;++ private final PullRequestInlineCommentManager pullRequestInlineCommentManager;+@Inject- public DefaultPullRequestUpdateManager(Dao dao, StorageManager storageManager) {+ public DefaultPullRequestUpdateManager(Dao dao, StorageManager storageManager,+ PullRequestListeners pullRequestListeners, UnitOfWork unitOfWork,+ PullRequestInlineCommentManager pullRequestInlineCommentManager) {this.dao = dao;this.storageManager = storageManager;+ this.pullRequestListeners = pullRequestListeners;+ this.unitOfWork = unitOfWork;+ this.pullRequestInlineCommentManager = pullRequestInlineCommentManager;}@Transactional@@ -42,6 +58,36 @@ public class DefaultPullRequestUpdateManager implements PullRequestUpdateManagerrequest.getTarget().getRepository().git().updateRef(update.getHeadRef(),sourceHead, null, null);}++ final Long requestId = request.getId();++ dao.afterCommit(new Runnable() {++ @Override+ public void run() {+ unitOfWork.asyncCall(new Runnable() {++ @Override+ public void run() {+ PullRequest request = dao.load(PullRequest.class, requestId);+ for (PullRequestInlineComment comment: request.getInlineComments())+ pullRequestInlineCommentManager.update((PullRequestInlineComment) comment);++ pullRequestListeners.call(request, new PullRequestListeners.Callback() {++ @Override+ protected void call(PullRequestListener listener, PullRequest request) {+ listener.onUpdated(request);+ }++ });+ }++ });+ }++ });+}@Transactionaldiff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.javaindex 5f2fcc499c..7a0fd3b452 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java@@ -9,9 +9,9 @@ import javax.persistence.Entity;import javax.persistence.OneToMany;import com.google.common.base.Preconditions;-import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.comment.CommentReply;+import com.pmease.gitplex.core.manager.PullRequestCommentReplyManager;import com.pmease.gitplex.core.manager.UserManager;@SuppressWarnings("serial")@@ -39,7 +39,7 @@ public class PullRequestComment extends AbstractPullRequestComment {reply.setDate(new Date());reply.setContent(content);reply.setComment(this);- GitPlex.getInstance(Dao.class).persist(reply);+ GitPlex.getInstance(PullRequestCommentReplyManager.class).save(reply);return reply;}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestInlineComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestInlineComment.javaindex 4b50dcf40e..3a326346c9 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestInlineComment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestInlineComment.java@@ -17,12 +17,12 @@ import javax.persistence.OneToMany;import com.google.common.base.Preconditions;import com.pmease.commons.git.BlobInfo;-import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.Pair;import com.pmease.commons.util.diff.AroundContext;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.comment.CommentReply;import com.pmease.gitplex.core.comment.InlineComment;+import com.pmease.gitplex.core.manager.PullRequestInlineCommentReplyManager;import com.pmease.gitplex.core.manager.UserManager;@Entity@@ -139,7 +139,7 @@ public class PullRequestInlineComment extends AbstractPullRequestComment implemereply.setDate(new Date());reply.setContent(content);reply.setComment(this);- GitPlex.getInstance(Dao.class).persist(reply);+ GitPlex.getInstance(PullRequestInlineCommentReplyManager.class).save(reply);return reply;}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 49184b75ea..2c8a67853d 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@@ -2,9 +2,6 @@ html, body { background: #f0f2f4; }a {color: #09f; cursor: pointer;}a.fa {text-decoration: none;}-a.fa-times {color: #FF2A68;}-a.fa-times:hover {color: #BD2E29;}-span.fa-times {color: #999;}textarea {resize: vertical;}@@ -727,7 +724,7 @@ table.branches td.summary>div, table.branches td.summary>div .name a {font-size:.table-diff .line.diff>td.line-no {color: #999; width: 1%; text-align: right; white-space: nowrap;}.table-diff .line.diff td.text, .table-diff .hunk-head td.content {font-family: Consolas,"Liberation Mono",Menlo,Courier,monospace;}-.table-diff .line.diff td.text {color: #333; overflow: visible; white-space: pre;}+.table-diff .line.diff td.text {overflow: visible; white-space: pre;}.table-diff {font-size: 12px; position:relative;}.table-diff>tbody>tr>td {padding: 2px 8px;}.table-diff>tbody>tr>td.text, .table-diff>tbody>tr>td.detail, .table-diff>tbody>tr>td.new {@@ -772,20 +769,20 @@ ul.diff-alerts {margin: 0 0 0 8px; padding: 4px 8px 4px 12px;}.diff-stat .deletions {color: #c33535; font-style: normal; }/* ACTIVITY */-.activity>div.summary {color: #777; margin-bottom: 8px;}-.activity>div.summary a {color: #777;}+.activity>div.summary {color: #999; margin-bottom: 8px;}+.activity>div.summary a {color: #999;}.activity>div.summary .fa {font-size: 13px;}.activity>div.summary .actions {margin-left: 8px;}-.activity>div.summary .actions a {margin-right: 4px; color: #999;}+.activity>div.summary .actions>a, .activity>div.summary .actions>span {margin-right: 6px; color: #DDD;}+.activity>div.summary .actions a, .activity>div.summary .actions span {color: #DDD;}+.activity:hover>div.summary .actions a, .activity:hover>div.summary .actions span {color: #999;}.activity>div.summary .actions a .fa-times {font-size: 14px;}-.activity>div.summary .actions a .fa-diff {font-size: 16px;}-.activity>div.summary .user a {color: #333; font-weight: bold;}--.collapsed>.avatar img {opacity: 0.5;}-.collapsed>.activity>div.summary {margin-bottom: 0; color: #999;}-.collapsed>.activity>div.summary .user a {color: #777;}-.collapsed>.activity .actions .fa-tick {color: #999;}-.collapsed>.activity .actions a {margin-left: 8px;}+.activity>div.summary .actions a .fa-diff {font-size: 14px;}+.activity>div.summary .user a, .activity>div.summary em {color: #666; font-weight: bold; font-style: normal;}++.collapsed>.avatar img {opacity: 0.3;}+.collapsed>.activity>div.summary {margin-bottom: 0; color: #AAA;}+.collapsed>.activity>div.summary .user a {color: #888;}.collapsed>.activity>div.detail {text-overflow: ellipsis; overflow: hidden;max-width: 600px; color: #777; white-space: nowrap;}@@ -797,10 +794,12 @@ ul.diff-alerts {margin: 0 0 0 8px; padding: 4px 8px 4px 12px;}.comment-input>.tab-pane>.preview {display: none;}div.replies {padding-top: 8px;}-div.replies>table>tbody>tr>td {vertical-align: top; border-top: 1px dashed #DDD; padding: 8px 0 8px 0;}+div.replies>table>tbody>tr>td {vertical-align: top; border-top: 1px dotted #DDD; padding: 8px 0 8px 0;}div.replies>table>tbody>tr>td.avatar {width: 1px; padding: 10px 12px 0 0;}div.replies>table>tbody>tr>td.avatar img {width: 26px; height: 26px;}-div.replies>table>tbody>tr.add-reply>td {padding-top: 12px;}+div.replies>table>tbody>tr.add-reply>td {padding-top: 12px; color: #999;}+div.replies>table>tbody>tr.add-reply>td>div>a {color: #999;}+div.replies>table>tbody>tr.add-reply>td:hover>div>a {color: #333;}table.comments>tbody>tr>td.avatar {width: 1px; padding-right: 16px;}table.comments>tbody>tr>td.avatar img {width: 36px; height: 36px;}table.comments>tbody>tr>td {border-top: 1px solid #E5E5E5; padding: 12px 0 12px 0;}@@ -925,7 +924,8 @@ ul.status-help li:last-child .description {border-bottom: none;}.request-detail>.activities .table-diff>tbody>tr.omit>td .fa {font-size: 24px; color: #888; margin-left: 12px;}.request-detail>.activities .inline-comment.panel>.panel-heading {padding: 8px;}.request-detail>.activities .inline-comment.panel>.panel-heading .actions {margin-left: 12px;}-.request-detail>.activities .inline-comment.panel>.panel-heading .actions a {color: #888; margin-right: 4px;}+.request-detail>.activities .inline-comment.panel>.panel-heading .actions a {color: #BBB; margin-right: 4px;}+.request-detail>.activities .inline-comment.panel>.panel-heading:hover .actions a {color: #666;}.request-detail>.activities .inline-comment.panel {margin-bottom: 4px;}.request-detail>.activities .activity>.summary .fa {background: white;}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 3bb7c63579..d166617005 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@@ -12,7 +12,7 @@</div><div wicket:id="content" class="body"></div></div>- <div class="replies">+ <div class="comment replies"><table><tr wicket:id="replies" class="reply"><td class="avatar"><span wicket:id="avatar"></span></td>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 1366845b0f..e258fef14a 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@@ -3,6 +3,7 @@ package com.pmease.gitplex.web.component.comment;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;+import java.util.Date;import java.util.List;import org.apache.wicket.Component;@@ -10,6 +11,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.markup.html.AjaxLink;import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;import org.apache.wicket.event.Broadcast;+import org.apache.wicket.event.IEvent;import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.form.Form;@@ -28,18 +30,25 @@ 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.core.manager.UserManager;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.PullRequestChanged;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.ModelWrapper;import com.pmease.gitplex.web.model.UserModel;@SuppressWarnings("serial")public class CommentPanel extends Panel {+ private static final String ADD_REPLY_ID = "addReply";+private RepeatingView repliesView;+ private ModelWrapper<CommentReply> replyModelWrapper;+private IModel<List<CommentReply>> repliesModel = new LoadableDetachableModel<List<CommentReply>>() {@Override@@ -58,8 +67,10 @@ public class CommentPanel extends Panel {};- public CommentPanel(String id, IModel<? extends Comment> commentModel) {+ public CommentPanel(String id, IModel<? extends Comment> commentModel, ModelWrapper<CommentReply> replyModelWrapper) {super(id, commentModel);++ this.replyModelWrapper = replyModelWrapper;}private Comment getComment() {@@ -158,7 +169,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;+ AjaxLink<Void> resolveLink;summary.add(resolveLink = new AjaxLink<Void>("resolve") {@Override@@ -199,8 +210,7 @@ public class CommentPanel extends Panel {protected void onConfigure() {super.onConfigure();- resolveLink.configure();- setVisible(!resolveLink.isVisible());+ setVisible(getComment().isResolved() && !GitPlex.getInstance(AuthorizationManager.class).canModify(getComment()));}});@@ -219,11 +229,52 @@ public class CommentPanel extends Panel {add(repliesView = newRepliesView());add(newAddReplyRow());++ setOutputMarkupId(true);}+ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ System.out.println("pull request changed");++ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ List<CommentReply> replies = repliesModel.getObject();+ Date lastReplyDate;+ if (repliesView.size() != 0) {+ Component lastReplyRow = repliesView.get(repliesView.size()-1);+ lastReplyDate = ((CommentReply)lastReplyRow.getDefaultModelObject()).getDate();+ } else {+ lastReplyDate = getComment().getDate();+ }+ for (CommentReply reply: replies) {+ if (reply.getDate().after(lastReplyDate)) {+ Component newReplyRow = newReplyRow(repliesView.newChildId(), reply);+ repliesView.add(newReplyRow);+ String script;+ Component addReplyRow = get(ADD_REPLY_ID);+ if (addReplyRow.isVisible()) {+ script = String.format("$(\"<tr id='%s' class='reply'></tr>\").insertBefore('#%s');",+ newReplyRow.getMarkupId(), addReplyRow.getMarkupId());+ } else {+ script = String.format("$('#%s>.replies>table>tbody').append(\"<tr id='%s' class='reply'></tr>\");",+ getMarkupId(), newReplyRow.getMarkupId());+ }+ target.prependJavaScript(script);+ target.add(newReplyRow);+ }+ }++ }+ }+private Component newAddReplyRow() {- WebMarkupContainer row = new WebMarkupContainer("addReply");- row.setOutputMarkupId(true);+ WebMarkupContainer addReplyRow = new WebMarkupContainer(ADD_REPLY_ID);+ addReplyRow.setOutputMarkupId(true);+ addReplyRow.setVisible(GitPlex.getInstance(UserManager.class).getCurrent() != null);Fragment fragment = new Fragment("content", "addFrag", this);fragment.add(new AjaxLink<Void>("addReply") {@@ -247,15 +298,15 @@ public class CommentPanel extends Panel {@Overrideprotected void onSubmit(AjaxRequestTarget target, Form<?> form) {- Component row = newAddReplyRow();- CommentPanel.this.replace(row);- target.add(row);+ Component addReplyRow = newAddReplyRow();+ CommentPanel.this.replace(addReplyRow);+ target.add(addReplyRow);- getComment().addReply(input.getModelObject());- Component newReplyRow = newReplyRow(repliesView.newChildId(), repliesModel.getObject().size()-1);+ CommentReply reply = getComment().addReply(input.getModelObject());+ Component newReplyRow = newReplyRow(repliesView.newChildId(), reply);repliesView.add(newReplyRow);String script = String.format("$(\"<tr id='%s' class='reply'></tr>\").insertBefore('#%s');",- newReplyRow.getMarkupId(), row.getMarkupId());+ newReplyRow.getMarkupId(), addReplyRow.getMarkupId());target.prependJavaScript(script);target.add(newReplyRow);}@@ -272,9 +323,9 @@ public class CommentPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- Component row = newAddReplyRow();- CommentPanel.this.replace(row);- target.add(row);+ Component addReplyRow = newAddReplyRow();+ CommentPanel.this.replace(addReplyRow);+ target.add(addReplyRow);}});@@ -284,16 +335,16 @@ public class CommentPanel extends Panel {}});- row.add(fragment);+ addReplyRow.add(fragment);- return row;+ return addReplyRow;}private RepeatingView newRepliesView() {RepeatingView repliesView = new RepeatingView("replies");- for (int i=0; i<repliesModel.getObject().size(); i++)- repliesView.add(newReplyRow(repliesView.newChildId(), i));+ for (CommentReply reply: repliesModel.getObject())+ repliesView.add(newReplyRow(repliesView.newChildId(), reply));return repliesView;}@@ -305,11 +356,9 @@ public class CommentPanel extends Panel {super.onBeforeRender();}- private Component newReplyRow(String id, int index) {- final WebMarkupContainer row = new WebMarkupContainer(id, Model.of(index));+ private Component newReplyRow(String id, CommentReply reply) {+ final WebMarkupContainer row = new WebMarkupContainer(id, replyModelWrapper.asModel(reply));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())));@@ -322,7 +371,7 @@ public class CommentPanel extends Panel {Form<?> form = new Form<Void>("form");fragment.add(form);- CommentReply reply = repliesModel.getObject().get((int)row.getDefaultModelObject());+ CommentReply reply = (CommentReply) row.getDefaultModelObject();final MarkdownInput input = new MarkdownInput("input", Model.of(reply.getContent()));input.setRequired(true);form.add(input);@@ -331,7 +380,7 @@ public class CommentPanel extends Panel {@Overrideprotected void onSubmit(AjaxRequestTarget target, Form<?> form) {- CommentReply reply = repliesModel.getObject().get((int)row.getDefaultModelObject());+ CommentReply reply = (CommentReply) row.getDefaultModelObject();reply.saveContent(input.getModelObject());Fragment fragment = renderForView(reply.getContent());@@ -351,7 +400,7 @@ public class CommentPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- CommentReply reply = repliesModel.getObject().get((int)row.getDefaultModelObject());+ CommentReply reply = (CommentReply) row.getDefaultModelObject();Fragment fragment = renderForView(reply.getContent());row.replace(fragment);target.add(fragment);@@ -377,16 +426,9 @@ 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);+ CommentReply reply = (CommentReply) row.getDefaultModelObject();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()));}@@ -403,7 +445,7 @@ public class CommentPanel extends Panel {@Overridepublic CommentReply getObject() {- return repliesModel.getObject().get((int)row.getDefaultModelObject());+ return (CommentReply) row.getDefaultModelObject();}}));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/PullRequestChanged.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/PullRequestChanged.javanew file mode 100644index 0000000000..6c44673d88--- /dev/null+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/PullRequestChanged.java@@ -0,0 +1,22 @@+package com.pmease.gitplex.web.component.comment.event;++import org.apache.wicket.ajax.AjaxRequestTarget;++import com.pmease.gitplex.core.model.PullRequest;+import com.pmease.gitplex.web.common.wicket.event.AjaxEvent;++public class PullRequestChanged extends AjaxEvent {++ private final PullRequest request;++ public PullRequestChanged(AjaxRequestTarget target, PullRequest request) {+ super(target);++ this.request = request;+ }++ public PullRequest getRequest() {+ return request;+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.javaindex 4178d675ec..e498357dc7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java@@ -61,9 +61,11 @@ import com.pmease.commons.wicket.behavior.menu.MenuItem;import com.pmease.commons.wicket.behavior.menu.MenuPanel;import com.pmease.commons.wicket.component.markdown.MarkdownInput;import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.comment.CommentReply;import com.pmease.gitplex.core.comment.InlineComment;import com.pmease.gitplex.core.comment.InlineCommentSupport;import com.pmease.gitplex.core.manager.UserManager;+import com.pmease.gitplex.core.model.PullRequestInlineCommentReply;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.core.permission.ObjectPermission;@@ -71,6 +73,8 @@ import com.pmease.gitplex.web.component.comment.CommentPanel;import com.pmease.gitplex.web.component.comment.event.CommentRemoved;import com.pmease.gitplex.web.component.user.AvatarMode;import com.pmease.gitplex.web.component.user.UserLink;+import com.pmease.gitplex.web.model.EntityModel;+import com.pmease.gitplex.web.model.ModelWrapper;import com.pmease.gitplex.web.model.UserModel;@SuppressWarnings("serial")@@ -833,7 +837,14 @@ public class TextDiffPanel extends Panel {@Overrideprotected void populateItem(ListItem<InlineComment> item) {item.add(new UserLink("avatar", new UserModel(item.getModelObject().getUser()), AvatarMode.AVATAR));- item.add(new CommentPanel("comment", item.getModel()).setOutputMarkupId(true));+ item.add(new CommentPanel("comment", item.getModel(), new ModelWrapper<CommentReply>() {++ @Override+ public IModel<PullRequestInlineCommentReply> asModel(CommentReply object) {+ return new EntityModel<PullRequestInlineCommentReply>((PullRequestInlineCommentReply) object);+ }++ }).setOutputMarkupId(true));if (item.getModelObject().equals(commentSupport.getConcernedComment()))item.add(AttributeAppender.append("class", " concerned"));}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/model/ModelWrapper.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/model/ModelWrapper.javanew file mode 100644index 0000000000..7c370849a0--- /dev/null+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/model/ModelWrapper.java@@ -0,0 +1,9 @@+package com.pmease.gitplex.web.model;++import java.io.Serializable;++import org.apache.wicket.model.IModel;++public interface ModelWrapper<T> extends Serializable {+ IModel<? extends T> asModel(T object);+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.htmlindex eb2a6f838a..526553bbba 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.html@@ -15,7 +15,7 @@<div class="summary"><span wicket:id="user" class="user"></span> <span wicket:id="activity"></span> <span wicket:id="age"></span><span class="actions">- <i class="fa fa-tick" title="This comment is marked as resolved"></i>+ <span class="fa fa-tick" title="This comment is marked as resolved"></span><a wicket:id="expand" class="fa fa-expand" title="Expand this comment"></a></span></div>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.javaindex 1e629b3cd5..d729411b2c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestActivitiesPage.java@@ -23,13 +23,12 @@ import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.markup.repeater.RepeatingView;import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.model.Model;-import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;import org.apache.wicket.request.mapper.parameter.PageParameters;import com.google.common.base.Preconditions;-import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.wicket.component.markdown.MarkdownInput;import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;import com.pmease.gitplex.core.manager.UserManager;import com.pmease.gitplex.core.model.AbstractPullRequestComment;import com.pmease.gitplex.core.model.PullRequest;@@ -39,6 +38,7 @@ import com.pmease.gitplex.core.model.PullRequestInlineComment;import com.pmease.gitplex.core.model.PullRequestUpdate;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.PullRequestChanged;import com.pmease.gitplex.web.component.label.AgeLabel;import com.pmease.gitplex.web.component.user.AvatarMode;import com.pmease.gitplex.web.component.user.UserLink;@@ -46,9 +46,9 @@ import com.pmease.gitplex.web.model.UserModel;import com.pmease.gitplex.web.page.repository.pullrequest.activity.AbstractCommentPullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.ApprovePullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.CommentPullRequest;-import com.pmease.gitplex.web.page.repository.pullrequest.activity.InlineCommentPullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.DisapprovePullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.DiscardPullRequest;+import com.pmease.gitplex.web.page.repository.pullrequest.activity.InlineCommentPullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.IntegratePullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.OpenPullRequest;import com.pmease.gitplex.web.page.repository.pullrequest.activity.PullRequestActivity;@@ -222,6 +222,31 @@ public class RequestActivitiesPage extends RequestDetailPage {super.onBeforeRender();}+ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ List<PullRequestActivity> activities = getActivities();+ Component lastActivityRow = activitiesView.get(activitiesView.size()-1);+ PullRequestActivity lastAcvitity = (PullRequestActivity) lastActivityRow.getDefaultModelObject();+ for (PullRequestActivity activity: activities) {+ if (activity.getDate().after(lastAcvitity.getDate())) {+ Component newActivityRow = newActivityRow(activitiesView.newChildId(), activity);+ activitiesView.add(newActivityRow);++ String script = String.format("$(\"<tr id='%s'></tr>\").insertAfter('#%s');",+ newActivityRow.getMarkupId(), lastActivityRow.getMarkupId());+ target.prependJavaScript(script);+ target.add(newActivityRow);+ lastActivityRow = newActivityRow;+ }+ }+ }+ }+@Overrideprotected void onInitialize() {super.onInitialize();@@ -257,7 +282,7 @@ public class RequestActivitiesPage extends RequestDetailPage {comment.setRequest(getPullRequest());comment.setUser(GitPlex.getInstance(UserManager.class).getCurrent());comment.setContent(input.getModelObject());- GitPlex.getInstance(Dao.class).persist(comment);+ GitPlex.getInstance(PullRequestCommentManager.class).save(comment);input.setModelObject("");target.add(addComment);@@ -279,32 +304,6 @@ public class RequestActivitiesPage extends RequestDetailPage {}});-- add(new PullRequestChangeBehavior(getPullRequest().getId()) {-- @Override- protected void onRender(WebSocketRequestHandler handler) {- for (int i=0; i<activitiesView.size(); i++)- handler.add(activitiesView.get(i));-- List<PullRequestActivity> activities = getActivities();- Component lastActivityRow = activitiesView.get(activitiesView.size()-1);- PullRequestActivity lastAcvitity = (PullRequestActivity) lastActivityRow.getDefaultModelObject();- for (PullRequestActivity activity: activities) {- if (activity.getDate().after(lastAcvitity.getDate())) {- Component newActivityRow = newActivityRow(activitiesView.newChildId(), activity);- activitiesView.add(newActivityRow);-- String script = String.format("$(\"<tr id='%s'></tr>\").insertAfter('#%s');",- newActivityRow.getMarkupId(), lastActivityRow.getMarkupId());- handler.prependJavaScript(script);- handler.add(newActivityRow);- lastActivityRow = newActivityRow;- }- }- }-- });}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.javaindex 5981181494..b9c04e7034 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestComparePage.java@@ -23,7 +23,6 @@ import org.apache.wicket.markup.html.list.ListView;import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.apache.wicket.util.visit.IVisit;import org.apache.wicket.util.visit.IVisitor;@@ -48,6 +47,7 @@ import com.pmease.commons.wicket.component.history.HistoryAwarePanel;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.comment.InlineComment;import com.pmease.gitplex.core.comment.InlineCommentSupport;+import com.pmease.gitplex.core.manager.PullRequestInlineCommentManager;import com.pmease.gitplex.core.manager.PullRequestManager;import com.pmease.gitplex.core.manager.UserManager;import com.pmease.gitplex.core.model.IntegrationPreview;@@ -57,6 +57,7 @@ import com.pmease.gitplex.core.model.PullRequestInlineComment;import com.pmease.gitplex.core.model.PullRequestUpdate;import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.web.component.comment.event.CommentRemoved;+import com.pmease.gitplex.web.component.comment.event.PullRequestChanged;import com.pmease.gitplex.web.component.diff.CompareResultPanel;import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;@@ -177,7 +178,19 @@ public class RequestComparePage extends RequestDetailPage {protected void onInitialize() {super.onInitialize();- final WebMarkupContainer optionsContainer = new WebMarkupContainer("compareOptions");+ final WebMarkupContainer optionsContainer = new WebMarkupContainer("compareOptions") {++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ pullRequestChanged.getTarget().add(this);+ }+ }++ };optionsContainer.add(new StickyBehavior());add(optionsContainer);@@ -339,30 +352,31 @@ public class RequestComparePage extends RequestDetailPage {optionsContainer.add(new Link<Void>("refresh") {@Override- protected void onInitialize() {- super.onInitialize();-- add(new PullRequestChangeBehavior(getPullRequest().getId()) {+ public void onEvent(final IEvent<?> event) {+ super.onEvent(event);- @Override- protected void onRender(final WebSocketRequestHandler handler) {- PageParameters params = getPageParameters();- if (params.get(COMMENT_PARAM).toOptionalLong() != null || getPageParameters().get(REVISED_PARAM).toString() == null) {- setVisible(true);- compareResult.visitChildren(new IVisitor<Component, Void>() {+ if (event.getPayload() instanceof PullRequestChanged) {+ PageParameters params = getPageParameters();+ if (params.get(COMMENT_PARAM).toOptionalLong() != null || getPageParameters().get(REVISED_PARAM).toString() == null) {+ setVisible(true);+ compareResult.visitChildren(new IVisitor<Component, Void>() {- @Override- public void component(Component object, IVisit<Void> visit) {- for (StickyBehavior behavior: object.getBehaviors(StickyBehavior.class))- behavior.restick(handler);- }-- });- }- handler.add(optionsContainer);+ @Override+ public void component(Component object, IVisit<Void> visit) {+ AjaxRequestTarget target = ((PullRequestChanged) event.getPayload()).getTarget();+ for (StickyBehavior behavior: object.getBehaviors(StickyBehavior.class))+ behavior.restick(target);+ }++ });}- });+ }+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();setVisible(false);setOutputMarkupPlaceholderTag(true);@@ -432,7 +446,7 @@ public class RequestComparePage extends RequestDetailPage {comment.setCompareWith(compareWith);comment.setLine(line);comment.setContext(commentContext);- GitPlex.getInstance(Dao.class).persist(comment);+ GitPlex.getInstance(PullRequestInlineCommentManager.class).save(comment);return comment;}};diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.javaindex 1af5272501..9a708d1fc0 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestDetailPage.java@@ -31,6 +31,8 @@ import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;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.event.Broadcast;+import org.apache.wicket.event.IEvent;import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;@@ -48,6 +50,7 @@ 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.protocol.ws.api.WebSocketRequestHandler;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.eclipse.jgit.lib.PersonIdent;@@ -74,10 +77,11 @@ import com.pmease.gitplex.core.model.IntegrationPreview;import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy;import com.pmease.gitplex.core.model.PullRequestOperation;-import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.core.model.PullRequestVerification;+import com.pmease.gitplex.core.model.User;import com.pmease.gitplex.core.permission.ObjectPermission;import com.pmease.gitplex.web.component.branch.BranchLink;+import com.pmease.gitplex.web.component.comment.event.PullRequestChanged;import com.pmease.gitplex.web.component.label.AgeLabel;import com.pmease.gitplex.web.component.user.AvatarMode;import com.pmease.gitplex.web.component.user.PersonLink;@@ -252,7 +256,19 @@ public abstract class RequestDetailPage extends RepositoryPage {}));- overviewContainer = new WebMarkupContainer("requestOverview");+ overviewContainer = new WebMarkupContainer("requestOverview") {++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ pullRequestChanged.getTarget().add(this);+ }+ }++ };add(overviewContainer);overviewContainer.add(new Label("title", new AbstractReadOnlyModel<String>() {@@ -306,8 +322,6 @@ public abstract class RequestDetailPage extends RepositoryPage {});- overviewContainer.add(new PullRequestChangeBehavior(getPullRequest().getId()));-List<Tab> tabs = new ArrayList<>();tabs.add(new RequestTab("Discussions", RequestActivitiesPage.class));@@ -324,6 +338,22 @@ public abstract class RequestDetailPage extends RepositoryPage {}.setOutputMarkupId(true));add(new BackToTop("backToTop"));++ add(new WebSocketRenderBehavior(false) {++ @Override+ protected Object getTrait() {+ PullRequestChangeTrait trait = new PullRequestChangeTrait();+ trait.requestId = getPullRequest().getId();+ return trait;+ }++ @Override+ protected void onRender(WebSocketRequestHandler handler) {+ send(getPage(), Broadcast.BREADTH, new PullRequestChanged(handler, getPullRequest()));+ }++ });}private WebMarkupContainer newOperationsContainer() {@@ -952,26 +982,7 @@ public abstract class RequestDetailPage extends RepositoryPage {return requestModel.getObject();}- protected static class PullRequestChangeBehavior extends WebSocketRenderBehavior {-- private final Long requestId;-- public PullRequestChangeBehavior(Long requestId) {- super(false);-- this.requestId = requestId;- }-- @Override- protected Object getTrait() {- PullRequestChangeTrait trait = new PullRequestChangeTrait();- trait.requestId = requestId;- return trait;- }-- }-- protected static class PullRequestChangeTrait {+ private static class PullRequestChangeTrait {private Long requestId;@@ -1037,6 +1048,11 @@ public abstract class RequestDetailPage extends RepositoryPage {trait.requestId = request.getId();WebSocketRenderBehavior.requestToRender(trait);}++ @Override+ public void onCommented(PullRequest request) {+ onChange(request);+ }}}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.htmlindex 38f39f9af6..ddd88162f7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html@@ -2,7 +2,7 @@<ul wicket:id="requestUpdatesContainer" class="updates list-unstyled"><li wicket:id="updates" class="update activity"><div class="summary">- Update #<span wicket:id="updateNo"></span>, pushed <span wicket:id="age"></span>+ <em>Update #<span wicket:id="updateNo"></span></em>, pushed <span wicket:id="age"></span><span class="actions"><a wicket:id="compare"><span class="fa fa-diff"></span></a></span>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.javaindex 4e679c8c64..6ac7dd6e1c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java@@ -10,6 +10,7 @@ import java.util.Set;import org.apache.wicket.AttributeModifier;import org.apache.wicket.Component;import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.event.IEvent;import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;@@ -28,6 +29,7 @@ import com.pmease.gitplex.core.model.PullRequestUpdate;import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.core.model.PullRequestVerification;import com.pmease.gitplex.core.model.PullRequestVote;+import com.pmease.gitplex.web.component.comment.event.PullRequestChanged;import com.pmease.gitplex.web.component.commit.CommitHashLink;import com.pmease.gitplex.web.component.commit.CommitMessagePanel;import com.pmease.gitplex.web.component.label.AgeLabel;@@ -50,8 +52,19 @@ public class RequestUpdatesPage extends RequestDetailPage {protected void onInitialize() {super.onInitialize();- WebMarkupContainer updatesContainer = new WebMarkupContainer("requestUpdatesContainer");- updatesContainer.add(new PullRequestChangeBehavior(getPullRequest().getId()));+ WebMarkupContainer updatesContainer = new WebMarkupContainer("requestUpdatesContainer") {++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ pullRequestChanged.getTarget().add(this);+ }+ }++ };add(updatesContainer);updatesContainer.add(new ListView<PullRequestUpdate>("updates", new LoadableDetachableModel<List<PullRequestUpdate>>() {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/ApproveActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/ApproveActivityPanel.javaindex 7f47eb76f3..9c7f0d5b08 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/ApproveActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/ApproveActivityPanel.java@@ -33,7 +33,7 @@ public class ApproveActivityPanel extends Panel {add(new UserLink("user", userModel));add(new Label("age", Model.of(date)));- add(new SinceChangesPanel("changes", requestModel, date, "Changes since this approval"));+ add(new SinceChangesLink("changes", requestModel, date, "Changes since this approval"));}@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/CommentActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/CommentActivityPanel.javaindex dfdfae5170..4882f9ce33 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/CommentActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/CommentActivityPanel.java@@ -13,8 +13,11 @@ import com.pmease.gitplex.core.comment.Comment;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.core.model.PullRequestCommentReply;import com.pmease.gitplex.web.component.comment.CommentPanel;import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;+import com.pmease.gitplex.web.model.EntityModel;+import com.pmease.gitplex.web.model.ModelWrapper;@SuppressWarnings("serial")public class CommentActivityPanel extends Panel {@@ -31,7 +34,14 @@ public class CommentActivityPanel extends Panel {protected void onInitialize() {super.onInitialize();- add(new CommentPanel("content", commentModel) {+ add(new CommentPanel("content", commentModel, new ModelWrapper<CommentReply>() {++ @Override+ public IModel<PullRequestCommentReply> asModel(CommentReply object) {+ return new EntityModel<PullRequestCommentReply>((PullRequestCommentReply) object);+ }++ }) {@Overrideprotected Component newAdditionalCommentActions(String id, final IModel<Comment> commentModel) {@@ -62,7 +72,7 @@ public class CommentActivityPanel extends Panel {});- fragment.add(new SinceChangesPanel("changes", new AbstractReadOnlyModel<PullRequest>() {+ fragment.add(new SinceChangesLink("changes", new AbstractReadOnlyModel<PullRequest>() {@Overridepublic PullRequest getObject() {@@ -71,12 +81,14 @@ public class CommentActivityPanel extends Panel {}, CommentActivityPanel.this.commentModel.getObject().getDate(), "Changes since this comment"));+ fragment.setRenderBodyOnly(true);+return fragment;}@Overrideprotected Component newAdditionalReplyActions(String id, final IModel<CommentReply> replyModel) {- return new SinceChangesPanel(id, new AbstractReadOnlyModel<PullRequest>() {+ return new SinceChangesLink(id, new AbstractReadOnlyModel<PullRequest>() {@Overridepublic PullRequest getObject() {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/DisapproveActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/DisapproveActivityPanel.javaindex 3f92ed4887..cec8707566 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/DisapproveActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/DisapproveActivityPanel.java@@ -33,7 +33,7 @@ public class DisapproveActivityPanel extends Panel {add(new UserLink("user", userModel));add(new Label("age", Model.of(date)));- add(new SinceChangesPanel("changes", requestModel, date, "Changes since this disapproval"));+ add(new SinceChangesLink("changes", requestModel, date, "Changes since this disapproval"));}@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.htmlindex 02c1cb7ff0..e63e392622 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.html@@ -33,4 +33,7 @@</div><div wicket:id="comment"></div></div>+ <wicket:fragment wicket:id="actionsFrag">+ <a wicket:id="collapse" class="fa fa-collapse" title="Collapse this comment"></a>+ </wicket:fragment></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.javaindex 70775d901d..ecc2e127f1 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/InlineCommentActivityPanel.java@@ -10,7 +10,7 @@ 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.event.IEvent;import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.markup.head.OnDomReadyHeaderItem;import org.apache.wicket.markup.html.WebMarkupContainer;@@ -18,6 +18,7 @@ import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.link.Link;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.html.panel.Panel;import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;@@ -27,13 +28,18 @@ import com.pmease.commons.util.diff.DiffLine;import com.pmease.commons.util.diff.Token;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.PullRequestInlineCommentManager;import com.pmease.gitplex.core.model.PullRequestInlineComment;+import com.pmease.gitplex.core.model.PullRequestInlineCommentReply;import com.pmease.gitplex.web.component.comment.CommentPanel;import com.pmease.gitplex.web.component.comment.event.CommentCollapsing;+import com.pmease.gitplex.web.component.comment.event.PullRequestChanged;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.EntityModel;+import com.pmease.gitplex.web.model.ModelWrapper;import com.pmease.gitplex.web.model.UserModel;import com.pmease.gitplex.web.page.repository.pullrequest.RequestComparePage;@@ -53,12 +59,24 @@ public class InlineCommentActivityPanel extends Panel {super.onInitialize();PullRequestInlineComment comment = commentModel.getObject();- PullRequestInlineComment inlineComment = (PullRequestInlineComment) comment;- GitPlex.getInstance(PullRequestInlineCommentManager.class).update(inlineComment);+ GitPlex.getInstance(PullRequestInlineCommentManager.class).update(comment);add(new UserLink("name", new UserModel(comment.getUser()), AvatarMode.NAME));add(new AgeLabel("age", Model.of(comment.getDate())));- add(new Label("file", inlineComment.getBlobInfo().getPath()));+ add(new Label("file", comment.getBlobInfo().getPath()) {++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ target.add(this);+ }+ }++ }.setOutputMarkupId(true));add(new Link<Void>("compareView") {@@ -83,7 +101,19 @@ public class InlineCommentActivityPanel extends Panel {setVisible(commentModel.getObject().getContext() != null);}+ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ target.add(this);+ }+ }+};+ contextContainer.setOutputMarkupPlaceholderTag(true);add(contextContainer);contextContainer.add(new WebMarkupContainer("aboveOmitted") {@@ -163,13 +193,36 @@ public class InlineCommentActivityPanel extends Panel {setVisible(commentModel.getObject().getContext() == null);}- });+ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ target.add(this);+ }+ }++ }.setOutputMarkupPlaceholderTag(true));- add(new CommentPanel("comment", commentModel) {+ /*+ * Make comment panel independent of context in order not to reset comment content while editing+ * when we update context of the inline comment+ */+ add(new CommentPanel("comment", commentModel, new ModelWrapper<CommentReply>() {++ @Override+ public IModel<PullRequestInlineCommentReply> asModel(CommentReply object) {+ return new EntityModel<PullRequestInlineCommentReply>((PullRequestInlineCommentReply) object);+ }++ }) {@Overrideprotected Component newAdditionalCommentActions(String id, IModel<Comment> comment) {- return new AjaxLink<Void>(id) {+ Fragment fragment = new Fragment(id, "actionsFrag", InlineCommentActivityPanel.this);+ fragment.add(new AjaxLink<Void>("collapse") {@Overridepublic void onClick(AjaxRequestTarget target) {@@ -184,23 +237,25 @@ public class InlineCommentActivityPanel extends Panel {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;");- }-- };-+ });+ fragment.setRenderBodyOnly(true);+ return fragment;}@Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);-- String script = String.format(""+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ target.prependJavaScript(String.format("$('body').append($('#%s'));", getMarkupId(true)));+ target.appendJavaScript(getAppendScript());+ }+ }++ private String getAppendScript() {+ return String.format(""+ "var $beforeComment = $('#%s .before-comment');"+ "if ($beforeComment.hasClass('line')) {"+ " var $tr = $('<tr class=\"line comments\"><td colspan=\"3\"></td></tr>').insertAfter($beforeComment);"@@ -209,7 +264,13 @@ public class InlineCommentActivityPanel extends Panel {+ " $('#%s').insertAfter($beforeComment);"+ "}",InlineCommentActivityPanel.this.getMarkupId(true), getMarkupId(true), getMarkupId(true));- response.render(OnDomReadyHeaderItem.forScript(script));+ }++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);++ response.render(OnDomReadyHeaderItem.forScript(getAppendScript()));}});diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesLink.htmlsimilarity index 100%rename from gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesPanel.htmlrename to gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesLink.htmldiff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesLink.javasimilarity index 76%rename from gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesPanel.javarename to gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesLink.javaindex 2a9dbd56ef..b67a4b23e2 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/SinceChangesLink.java@@ -2,7 +2,9 @@ package com.pmease.gitplex.web.page.repository.pullrequest.activity;import java.util.Date;+import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.event.IEvent;import org.apache.wicket.markup.html.link.Link;import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.model.IModel;@@ -11,10 +13,11 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;import com.pmease.gitplex.core.model.PullRequest;import com.pmease.gitplex.core.model.PullRequestUpdate;+import com.pmease.gitplex.web.component.comment.event.PullRequestChanged;import com.pmease.gitplex.web.page.repository.pullrequest.RequestComparePage;@SuppressWarnings("serial")-public class SinceChangesPanel extends Panel {+public class SinceChangesLink extends Panel {private final IModel<PullRequest> requestModel;@@ -40,7 +43,7 @@ public class SinceChangesPanel extends Panel {private final String tooltip;- public SinceChangesPanel(String id, IModel<PullRequest> requestModel, Date sinceDate, String tooltip) {+ public SinceChangesLink(String id, IModel<PullRequest> requestModel, Date sinceDate, String tooltip) {super(id);this.requestModel = requestModel;@@ -65,6 +68,19 @@ public class SinceChangesPanel extends Panel {};link.add(AttributeAppender.append("title", tooltip));add(link);++ setOutputMarkupPlaceholderTag(true);+ }++ @Override+ public void onEvent(IEvent<?> event) {+ super.onEvent(event);++ if (event.getPayload() instanceof PullRequestChanged) {+ PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();+ AjaxRequestTarget target = pullRequestChanged.getTarget();+ target.add(this);+ }}@Override