Skip to content

The Unified and Autonomous Development Platform

Pull request notification and watch.

robin shineab6fb47fa43c
diff --git a/commons.hibernate/pom.xml b/commons.hibernate/pom.xml
index b9b3d8df51..4a00fc7da5 100644
--- a/commons.hibernate/pom.xml
+++ b/commons.hibernate/pom.xml
@@ -52,7 +52,7 @@
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
- <version>2.2.9</version>
+ <version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketRenderBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketRenderBehavior.java
index 84cdcda430..53fdab6f63 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketRenderBehavior.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/websocket/WebSocketRenderBehavior.java
@@ -178,7 +178,7 @@ public abstract class WebSocketRenderBehavior extends WebSocketBehavior {
public static void requestToRender(Object trait, @Nullable PageId pageId) {
String message = asMessage(trait);
-
+
for (Iterator<Map.Entry<IWebSocketConnection, ConnectionData>> it = connections.entrySet().iterator(); it.hasNext();) {
Map.Entry<IWebSocketConnection, ConnectionData> entry = it.next();
IWebSocketConnection connection = entry.getKey();
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.java
index 68292227b7..de43d93580 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
@@ -20,10 +20,11 @@ import com.pmease.gitplex.core.extensionpoint.ConfigChangeListener;
import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
import com.pmease.gitplex.core.manager.AuthorizationManager;
import com.pmease.gitplex.core.manager.BranchManager;
+import com.pmease.gitplex.core.manager.BranchWatchManager;
import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.DataManager;
import com.pmease.gitplex.core.manager.MailManager;
-import com.pmease.gitplex.core.manager.NotificationManager;
+import com.pmease.gitplex.core.manager.PullRequestNotificationManager;
import com.pmease.gitplex.core.manager.OldCommitCommentManager;
import com.pmease.gitplex.core.manager.PullRequestCommentManager;
import com.pmease.gitplex.core.manager.PullRequestCommentReplyManager;
@@ -39,10 +40,11 @@ import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.manager.VerificationManager;
import com.pmease.gitplex.core.manager.impl.DefaultAuthorizationManager;
import com.pmease.gitplex.core.manager.impl.DefaultBranchManager;
+import com.pmease.gitplex.core.manager.impl.DefaultBranchWatchManager;
import com.pmease.gitplex.core.manager.impl.DefaultConfigManager;
import com.pmease.gitplex.core.manager.impl.DefaultDataManager;
import com.pmease.gitplex.core.manager.impl.DefaultMailManager;
-import com.pmease.gitplex.core.manager.impl.DefaultNotificationManager;
+import com.pmease.gitplex.core.manager.impl.DefaultPullRequestNotificationManager;
import com.pmease.gitplex.core.manager.impl.DefaultOldCommitCommentManager;
import com.pmease.gitplex.core.manager.impl.DefaultPullRequestCommentManager;
import com.pmease.gitplex.core.manager.impl.DefaultPullRequestCommentReplyManager;
@@ -57,10 +59,6 @@ import com.pmease.gitplex.core.manager.impl.DefaultTeamManager;
import com.pmease.gitplex.core.manager.impl.DefaultUserManager;
import com.pmease.gitplex.core.manager.impl.DefaultVerificationManager;
import com.pmease.gitplex.core.model.ModelLocator;
-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.core.model.Review;
import com.pmease.gitplex.core.setting.SpecifiedGit;
import com.pmease.gitplex.core.setting.SystemGit;
import com.pmease.gitplex.core.validation.RepositoryNameReservation;
@@ -112,50 +110,6 @@ public class CoreModule extends AbstractPluginModule {
}
});
- contribute(PullRequestListener.class, new PullRequestListener() {
-
- @Override
- public void onOpened(PullRequest request) {
- }
-
- @Override
- public void onUpdated(PullRequest request) {
- }
-
- @Override
- public void onReviewed(Review review) {
- }
-
- @Override
- public void onIntegrated(PullRequest request) {
- }
-
- @Override
- public void onDiscarded(PullRequest request) {
- }
-
- @Override
- public void onIntegrationPreviewCalculated(PullRequest request) {
- }
-
- @Override
- public void onCommented(PullRequestComment comment) {
- }
-
- @Override
- public void onVerified(PullRequest request) {
- }
-
- @Override
- public void onAssigned(PullRequest request) {
- }
-
- @Override
- public void onCommentReplied(PullRequestCommentReply reply) {
- }
-
- });
-
contribute(ServletConfigurator.class, CoreServletConfigurator.class);
contribute(ImplementationProvider.class, new ImplementationProvider() {
@@ -189,18 +143,20 @@ public class CoreModule extends AbstractPluginModule {
bind(PullRequestCommentReplyManager.class).to(DefaultPullRequestCommentReplyManager.class);
bind(PullRequestManager.class).to(DefaultPullRequestManager.class);
bind(PullRequestUpdateManager.class).to(DefaultPullRequestUpdateManager.class);
- bind(PullRequestWatchManager.class).to(DefaultPullRequestWatchManager.class);
bind(RepositoryManager.class).to(DefaultRepositoryManager.class);
bind(TeamManager.class).to(DefaultTeamManager.class);
bind(UserManager.class).to(DefaultUserManager.class);
bind(VerificationManager.class).to(DefaultVerificationManager.class);
bind(ReviewInvitationManager.class).to(DefaultReviewInvitationManager.class);
bind(ReviewManager.class).to(DefaultReviewManager.class);
- bind(NotificationManager.class).to(DefaultNotificationManager.class);
bind(OldCommitCommentManager.class).to(DefaultOldCommitCommentManager.class);
bind(MailManager.class).to(DefaultMailManager.class);
+ bind(BranchWatchManager.class).to(DefaultBranchWatchManager.class);
+ bind(PullRequestWatchManager.class).to(DefaultPullRequestWatchManager.class);
+ bind(PullRequestNotificationManager.class).to(DefaultPullRequestNotificationManager.class);
- contribute(PullRequestListener.class, DefaultNotificationManager.class);
+ contribute(PullRequestListener.class, DefaultPullRequestNotificationManager.class);
+ contribute(PullRequestListener.class, DefaultPullRequestWatchManager.class);
contribute(ConfigChangeListener.class, DefaultPullRequestManager.class);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java
index 78551b029c..3f50e268fd 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java
@@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
+import javax.annotation.Nullable;
+
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -27,4 +29,14 @@ public interface Comment extends Serializable {
Collection<? extends CommentReply> getReplies();
CommentReply addReply(String content);
+
+ /**
+ * Get last visit date of this comment for current user.
+ *
+ * @return
+ * last visit date of this comment for current user, or <tt>null</tt>
+ * if current user is anonymous or has never visited the comment
+ */
+ @Nullable
+ Date getLastVisitDate();
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java
index c979309cc0..bb3eb40d6c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java
@@ -17,4 +17,5 @@ public interface InlineCommentSupport extends Serializable {
AroundContext commentContext, int line, String content);
InlineComment getConcernedComment();
+
}
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.java
index 45ff89020e..3cfcdd7c1d 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
@@ -1,32 +1,49 @@
package com.pmease.gitplex.core.extensionpoint;
+import javax.annotation.Nullable;
+
import com.pmease.commons.loader.ExtensionPoint;
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.core.model.PullRequestUpdate;
import com.pmease.gitplex.core.model.Review;
+import com.pmease.gitplex.core.model.ReviewInvitation;
+import com.pmease.gitplex.core.model.User;
@ExtensionPoint
public interface PullRequestListener {
void onOpened(PullRequest request);
- void onUpdated(PullRequest request);
+ void onReopened(PullRequest request, @Nullable User user, @Nullable String comment);
+
+ void onUpdated(PullRequestUpdate update);
+
+ void onMentioned(PullRequest request, User user, String content);
void onCommented(PullRequestComment comment);
void onCommentReplied(PullRequestCommentReply reply);
- void onReviewed(Review review);
+ void onReviewed(Review review, @Nullable String comment);
void onAssigned(PullRequest request);
void onVerified(PullRequest request);
- void onIntegrated(PullRequest request);
+ void onIntegrated(PullRequest request, @Nullable User user, @Nullable String comment);
- void onDiscarded(PullRequest request);
+ void onDiscarded(PullRequest request, @Nullable User user, @Nullable String comment);
void onIntegrationPreviewCalculated(PullRequest request);
+ void onInvitingReview(ReviewInvitation invitation);
+
+ void pendingIntegration(PullRequest request);
+
+ void pendingUpdate(PullRequest request);
+
+ void pendingApproval(PullRequest request);
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/BranchProtection.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/BranchProtection.java
index 63cccbebd8..63ffdab350 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/BranchProtection.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/BranchProtection.java
@@ -75,6 +75,9 @@ public class BranchProtection extends AbstractGateKeeper {
IfApprovedBySpecifiedTeam ifApprovedBySpecifiedTeam = new IfApprovedBySpecifiedTeam();
ifApprovedBySpecifiedTeam.setTeamId(teamId);
orGateKeeper.getGateKeepers().add(ifApprovedBySpecifiedTeam);
+ IfSubmittedBySpecifiedTeam ifSubmittedBySpecifiedTeam = new IfSubmittedBySpecifiedTeam();
+ ifSubmittedBySpecifiedTeam.setTeamId(teamId);
+ orGateKeeper.getGateKeepers().add(ifSubmittedBySpecifiedTeam);
}
ifThenGate.setThenGate(orGateKeeper);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DirectoryAndFileProtection.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DirectoryAndFileProtection.java
index 5ce34bcd04..a991d95ea1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DirectoryAndFileProtection.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DirectoryAndFileProtection.java
@@ -103,6 +103,9 @@ public class DirectoryAndFileProtection extends AbstractGateKeeper {
IfApprovedBySpecifiedTeam ifApprovedBySpecifiedTeam = new IfApprovedBySpecifiedTeam();
ifApprovedBySpecifiedTeam.setTeamId(teamId);
approvalGate.getGateKeepers().add(ifApprovedBySpecifiedTeam);
+ IfSubmittedBySpecifiedTeam ifSubmittedBySpecifiedTeam = new IfSubmittedBySpecifiedTeam();
+ ifSubmittedBySpecifiedTeam.setTeamId(teamId);
+ approvalGate.getGateKeepers().add(ifSubmittedBySpecifiedTeam);
}
return approvalGate;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java
index 4998827406..4aac3897a1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java
@@ -25,7 +25,7 @@ public interface GateKeeper extends Trimmable, Serializable {
String CATEGROY_COMPOSITION = "Gate Keeper Composition";
- String CATEGROY_OTHERS = "Misc Gate Keepers";
+ String CATEGROY_OTHERS = "Other Gate Keepers";
/**
* Check the gate keeper against specified request. This is typically used to determine
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java
index 9f8faaa848..4bc612e242 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java
@@ -16,7 +16,7 @@ import com.pmease.gitplex.core.model.PullRequestVerification;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
-@Editable(icon="pa-checkbox-checked", order=1000, category=GateKeeper.CATEGORY_COMMONLY_USED,
+@Editable(icon="pa-checkbox-checked", order=1000,
description="This gate keeper will be satisfied if commit is verified successfully "
+ "by specified number of builds. To make this working, your CI system has to "
+ "be configured to build against GitPlex pull requests.")
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitUpdateCallback.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitUpdateCallback.java
index de77c9d670..b7cbe456c1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitUpdateCallback.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitUpdateCallback.java
@@ -29,6 +29,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;
import com.pmease.gitplex.core.manager.BranchManager;
import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.Branch;
+import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.core.permission.ObjectPermission;
@@ -132,6 +133,16 @@ public class GitUpdateCallback extends HttpServlet {
for (String each: checkResult.getReasons())
messages.add(each);
error(output, messages.toArray(new String[messages.size()]));
+ } else {
+ boolean hasOpen = false;
+ for (PullRequest each: branch.getIncomingRequests()) {
+ if (each.isOpen()) {
+ hasOpen = true;
+ break;
+ }
+ }
+ if (hasOpen)
+ error(output, "There are pull requests opening against this branch.");
}
} else {
GateKeeper gateKeeper = repository.getGateKeeper();
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchWatchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchWatchManager.java
new file mode 100644
index 0000000000..1d2ed29ae4
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchWatchManager.java
@@ -0,0 +1,13 @@
+package com.pmease.gitplex.core.manager;
+
+import java.util.Collection;
+
+import com.pmease.gitplex.core.model.BranchWatch;
+import com.pmease.gitplex.core.model.Repository;
+import com.pmease.gitplex.core.model.User;
+
+public interface BranchWatchManager {
+
+ Collection<BranchWatch> findBy(User user, Repository repository);
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/MailManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/MailManager.java
index c62098b8fa..36f1219812 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/MailManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/MailManager.java
@@ -1,12 +1,12 @@
package com.pmease.gitplex.core.manager;
-import java.util.List;
+import java.util.Collection;
import com.pmease.gitplex.core.model.User;
public interface MailManager {
- void sendMail(List<User> toList, String subject, String body);
+ void sendMail(Collection<User> toList, String subject, String body);
void sendMail(User toUser, String subject, String body);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/NotificationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/NotificationManager.java
deleted file mode 100644
index 0380a576fc..0000000000
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/NotificationManager.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.pmease.gitplex.core.manager;
-
-import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
-import com.pmease.gitplex.core.model.PullRequest;
-import com.pmease.gitplex.core.model.ReviewInvitation;
-
-public interface NotificationManager extends PullRequestListener {
-
- void notifyReview(ReviewInvitation invitation);
-
- void notifyIntegration(PullRequest request);
-
- void notifyUpdate(PullRequest request, boolean noMail);
-
- void pendingApproval(PullRequest request);
-}
\ No newline at end of file
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.java
index c6f70c9fe1..9ba5614dfa 100644
--- 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.java
@@ -12,6 +12,6 @@ public interface PullRequestCommentManager {
*/
void updateInline(PullRequestComment comment);
- void save(PullRequestComment comment);
+ void save(PullRequestComment comment, boolean notify);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java
index 5688045059..69824ea915 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java
@@ -1,6 +1,7 @@
package com.pmease.gitplex.core.manager;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import javax.annotation.Nullable;
@@ -12,7 +13,6 @@ 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.Repository;
-import com.pmease.gitplex.core.model.User;
public interface PullRequestManager extends Lifecycle, ConfigChangeListener {
@@ -31,20 +31,18 @@ public interface PullRequestManager extends Lifecycle, ConfigChangeListener {
*
* @param request
* pull request to be integrated
- * @param user
- * user initiating the integration, <tt>null</tt> to indicate system user
* @param comment
* comment for the integration
*/
- void integrate(PullRequest request, @Nullable User user, @Nullable String comment);
+ void integrate(PullRequest request, @Nullable String comment);
- void discard(PullRequest request, @Nullable User user, @Nullable String comment);
+ void discard(PullRequest request, @Nullable String comment);
- void reopen(PullRequest request, User user, @Nullable String comment);
+ void reopen(PullRequest request, @Nullable String comment);
void onTargetBranchUpdate(PullRequest request);
- void onSourceBranchUpdate(PullRequest request);
+ void onSourceBranchUpdate(PullRequest request, boolean notify);
void onAssigneeChange(PullRequest request);
@@ -75,4 +73,14 @@ public interface PullRequestManager extends Lifecycle, ConfigChangeListener {
List<IntegrationStrategy> getApplicableIntegrationStrategies(PullRequest request);
void restoreSource(PullRequest request);
+
+ /**
+ * Get last visit date of specified pull request for current user.
+ *
+ * @return
+ * last visit date of specified pull request for current user, or <tt>null</tt>
+ * if current user is anonymous or has never visited the pull request
+ */
+ @Nullable
+ Date getLastVisitDate(PullRequest request);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestNotificationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestNotificationManager.java
new file mode 100644
index 0000000000..681da26875
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestNotificationManager.java
@@ -0,0 +1,7 @@
+package com.pmease.gitplex.core.manager;
+
+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
+
+public interface PullRequestNotificationManager extends PullRequestListener {
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestUpdateManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestUpdateManager.java
index e26940268a..dbc50bcd1f 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestUpdateManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestUpdateManager.java
@@ -4,7 +4,7 @@ import com.pmease.gitplex.core.model.PullRequestUpdate;
public interface PullRequestUpdateManager {
- void save(PullRequestUpdate update);
+ void save(PullRequestUpdate update, boolean notify);
void delete(PullRequestUpdate update);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestWatchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestWatchManager.java
index d47c947340..67fc790dc2 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestWatchManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestWatchManager.java
@@ -1,13 +1,7 @@
package com.pmease.gitplex.core.manager;
-import java.util.Collection;
+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
-import com.pmease.gitplex.core.model.PullRequestWatch;
-import com.pmease.gitplex.core.model.Repository;
-import com.pmease.gitplex.core.model.User;
-
-public interface PullRequestWatchManager {
-
- Collection<PullRequestWatch> findBy(User user, Repository repository);
+public interface PullRequestWatchManager extends PullRequestListener {
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java
index 0a3ef10830..5b4b6f12fc 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java
@@ -19,6 +19,7 @@ import com.pmease.commons.util.StringUtils;
import com.pmease.gitplex.core.manager.BranchManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.manager.RepositoryManager;
+import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.Repository;
@@ -30,6 +31,8 @@ public class DefaultBranchManager implements BranchManager {
private final PullRequestManager pullRequestManager;
+ private final UserManager userManager;
+
private final RepositoryManager repositoryManager;
private final UnitOfWork unitOfWork;
@@ -39,10 +42,11 @@ public class DefaultBranchManager implements BranchManager {
private final ReadWriteLock idLock = new ReentrantReadWriteLock();
@Inject
- public DefaultBranchManager(Dao dao, PullRequestManager pullRequestManager,
+ public DefaultBranchManager(Dao dao, PullRequestManager pullRequestManager, UserManager userManager,
RepositoryManager repositoryManager, UnitOfWork unitOfWork) {
this.dao = dao;
this.pullRequestManager = pullRequestManager;
+ this.userManager = userManager;
this.repositoryManager = repositoryManager;
this.unitOfWork = unitOfWork;
}
@@ -81,7 +85,7 @@ public class DefaultBranchManager implements BranchManager {
for (PullRequest request: branch.getOutgoingRequests()) {
if (request.isOpen())
- pullRequestManager.discard(request, null, "Source branch is deleted.");
+ pullRequestManager.discard(request, "Source branch is deleted.");
request.setSourceFQN(branch.getFQN());
request.setSource(null);
dao.persist(request);
@@ -122,6 +126,8 @@ public class DefaultBranchManager implements BranchManager {
@Transactional
@Override
public void save(final Branch branch) {
+ branch.setLastUpdater(userManager.getCurrent());
+
dao.persist(branch);
/**
@@ -131,7 +137,7 @@ public class DefaultBranchManager implements BranchManager {
*/
for (PullRequest request: branch.getOutgoingRequests()) {
if (request.isOpen())
- pullRequestManager.onSourceBranchUpdate(request);
+ pullRequestManager.onSourceBranchUpdate(request, true);
}
final Long branchId = branch.getId();
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchWatchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchWatchManager.java
new file mode 100644
index 0000000000..03f86b00d3
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchWatchManager.java
@@ -0,0 +1,37 @@
+package com.pmease.gitplex.core.manager.impl;
+
+import java.util.Collection;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.Sessional;
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.gitplex.core.manager.BranchWatchManager;
+import com.pmease.gitplex.core.model.BranchWatch;
+import com.pmease.gitplex.core.model.Repository;
+import com.pmease.gitplex.core.model.User;
+
+@Singleton
+public class DefaultBranchWatchManager implements BranchWatchManager {
+
+ private final Dao dao;
+
+ @Inject
+ public DefaultBranchWatchManager(Dao dao) {
+ this.dao = dao;
+ }
+
+ @Sessional
+ @Override
+ public Collection<BranchWatch> findBy(User user, Repository repository) {
+ EntityCriteria<BranchWatch> criteria = EntityCriteria.of(BranchWatch.class);
+ criteria.add(Restrictions.eq("user", user));
+ criteria.createCriteria("branch").add(Restrictions.eq("repository", repository));
+ return dao.query(criteria);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultMailManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultMailManager.java
index c06bc1dd1f..5d6d8c7f6e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultMailManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultMailManager.java
@@ -1,11 +1,11 @@
package com.pmease.gitplex.core.manager.impl;
-import java.util.List;
+import java.util.Collection;
import javax.inject.Inject;
import javax.inject.Singleton;
-import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.MailManager;
import com.pmease.gitplex.core.model.User;
@@ -21,13 +21,13 @@ public class DefaultMailManager implements MailManager {
}
@Override
- public void sendMail(List<User> toList, String subject, String body) {
+ public void sendMail(Collection<User> toList, String subject, String body) {
System.out.println("sending email to: " + toList + ", subject: " + subject);
}
@Override
public void sendMail(User toUser, String subject, String body) {
- sendMail(Lists.newArrayList(toUser), subject, body);
+ sendMail(Sets.newHashSet(toUser), subject, body);
}
}
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.java
index 441942df82..5194686f51 100644
--- 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.java
@@ -35,6 +35,7 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag
this.pullRequestListeners = pullRequestListeners;
}
+ @Transactional
@Override
public void updateInline(PullRequestComment comment) {
Preconditions.checkNotNull(comment.getInlineInfo());
@@ -155,11 +156,13 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag
@Transactional
@Override
- public void save(final PullRequestComment comment) {
+ public void save(PullRequestComment comment, boolean notify) {
dao.persist(comment);
- for (PullRequestListener listener: pullRequestListeners)
- listener.onCommented(comment);
+ if (notify) {
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.onCommented(comment);
+ }
}
}
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.java
index 548142fd72..0a6a5676a3 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
@@ -8,6 +8,9 @@ import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERG
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERGE_WITH_SQUASH;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.REBASE_SOURCE_ONTO_TARGET;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.REBASE_TARGET_ONTO_SOURCE;
+import static com.pmease.gitplex.core.model.PullRequest.Status.PENDING_APPROVAL;
+import static com.pmease.gitplex.core.model.PullRequest.Status.PENDING_INTEGRATE;
+import static com.pmease.gitplex.core.model.PullRequest.Status.PENDING_UPDATE;
import java.io.File;
import java.util.Collection;
@@ -44,12 +47,14 @@ import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
import com.pmease.gitplex.core.manager.BranchManager;
import com.pmease.gitplex.core.manager.ConfigManager;
-import com.pmease.gitplex.core.manager.NotificationManager;
+import com.pmease.gitplex.core.manager.PullRequestCommentManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
+import com.pmease.gitplex.core.manager.PullRequestNotificationManager;
import com.pmease.gitplex.core.manager.PullRequestUpdateManager;
import com.pmease.gitplex.core.manager.RepositoryManager;
import com.pmease.gitplex.core.manager.ReviewInvitationManager;
import com.pmease.gitplex.core.manager.StorageManager;
+import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.IntegrationPolicy;
import com.pmease.gitplex.core.model.IntegrationPreview;
@@ -59,6 +64,7 @@ import com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy;
import com.pmease.gitplex.core.model.PullRequestActivity;
import com.pmease.gitplex.core.model.PullRequestComment;
import com.pmease.gitplex.core.model.PullRequestUpdate;
+import com.pmease.gitplex.core.model.PullRequestVisit;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.ReviewInvitation;
import com.pmease.gitplex.core.model.User;
@@ -74,8 +80,12 @@ public class DefaultPullRequestManager implements PullRequestManager {
private final PullRequestUpdateManager pullRequestUpdateManager;
+ private final PullRequestCommentManager pullRequestCommentManager;
+
private final BranchManager branchManager;
+ private final UserManager userManager;
+
private final StorageManager storageManager;
private final UnitOfWork unitOfWork;
@@ -84,8 +94,6 @@ public class DefaultPullRequestManager implements PullRequestManager {
private final ReviewInvitationManager reviewInvitationManager;
- private final NotificationManager notificationManager;
-
private final Set<Long> integrationPreviewRequestIds = new ConcurrentHashSet<>();
private ThreadPoolExecutor integrationPreviewExecutor;
@@ -103,15 +111,17 @@ public class DefaultPullRequestManager implements PullRequestManager {
@Inject
public DefaultPullRequestManager(Dao dao, PullRequestUpdateManager pullRequestUpdateManager,
BranchManager branchManager, StorageManager storageManager,
- ReviewInvitationManager reviewInvitationManager,
- NotificationManager notificationManager, ConfigManager configManager,
+ ReviewInvitationManager reviewInvitationManager, UserManager userManager,
+ PullRequestNotificationManager notificationManager, ConfigManager configManager,
+ PullRequestCommentManager pullRequestCommentManager,
UnitOfWork unitOfWork, Set<PullRequestListener> pullRequestListeners) {
this.dao = dao;
this.pullRequestUpdateManager = pullRequestUpdateManager;
this.branchManager = branchManager;
this.storageManager = storageManager;
this.reviewInvitationManager = reviewInvitationManager;
- this.notificationManager = notificationManager;
+ this.pullRequestCommentManager = pullRequestCommentManager;
+ this.userManager = userManager;
this.unitOfWork = unitOfWork;
this.configManager = configManager;
this.pullRequestListeners = pullRequestListeners;
@@ -178,12 +188,13 @@ public class DefaultPullRequestManager implements PullRequestManager {
@Transactional
@Override
- public void reopen(PullRequest request, User user, String comment) {
+ public void reopen(PullRequest request, String comment) {
Preconditions.checkState(!request.isOpen());
request.setCloseStatus(null);
dao.persist(request);
+ User user = userManager.getCurrent();
PullRequestActivity activity = new PullRequestActivity();
activity.setRequest(request);
activity.setDate(new DateTime().minusSeconds(1).toDate());
@@ -198,15 +209,19 @@ public class DefaultPullRequestManager implements PullRequestManager {
requestComment.setDate(activity.getDate());
requestComment.setRequest(request);
requestComment.setUser(user);
- dao.persist(requestComment);
+ pullRequestCommentManager.save(requestComment, false);
}
- onSourceBranchUpdate(request);
+ onSourceBranchUpdate(request, false);
+
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.onReopened(request, user, comment);
}
@Transactional
@Override
- public void discard(PullRequest request, final User user, final String comment) {
+ public void discard(PullRequest request, final String comment) {
+ User user = userManager.getCurrent();
PullRequestActivity activity = new PullRequestActivity();
activity.setRequest(request);
activity.setDate(new Date());
@@ -221,21 +236,22 @@ public class DefaultPullRequestManager implements PullRequestManager {
requestComment.setDate(activity.getDate());
requestComment.setRequest(request);
requestComment.setUser(user);
- dao.persist(requestComment);
+
+ pullRequestCommentManager.save(requestComment, false);
}
request.setCloseStatus(CloseStatus.DISCARDED);
- request.setUpdateDate(activity.getDate());
+ request.setLastEventDate(activity.getDate());
dao.persist(request);
for (PullRequestListener listener: pullRequestListeners)
- listener.onDiscarded(request);
+ listener.onDiscarded(request, user, comment);
}
@Transactional
@Override
- public void integrate(PullRequest request, User user, String comment) {
- if (request.getStatus() != PullRequest.Status.PENDING_INTEGRATE)
+ public void integrate(PullRequest request, String comment) {
+ if (request.getStatus() != PENDING_INTEGRATE)
throw new IllegalStateException("Gate keeper disallows integration right now.");
IntegrationPreview preview = request.getIntegrationPreview();
@@ -245,6 +261,8 @@ public class DefaultPullRequestManager implements PullRequestManager {
String integrated = preview.getIntegrated();
if (integrated == null)
throw new IllegalStateException("There are integration conflicts.");
+
+ User user = userManager.getCurrent();
Git git = request.getTarget().getRepository().git();
IntegrationStrategy strategy = request.getIntegrationStrategy();
@@ -291,16 +309,16 @@ public class DefaultPullRequestManager implements PullRequestManager {
requestComment.setDate(activity.getDate());
requestComment.setRequest(request);
requestComment.setUser(user);
- dao.persist(requestComment);
+ pullRequestCommentManager.save(requestComment, false);
}
request.setCloseStatus(CloseStatus.INTEGRATED);
- request.setUpdateDate(new Date());
+ request.setLastEventDate(new Date());
dao.persist(request);
for (PullRequestListener listener: pullRequestListeners)
- listener.onIntegrated(request);
+ listener.onIntegrated(request, user, comment);
}
@Transactional
@@ -314,9 +332,9 @@ public class DefaultPullRequestManager implements PullRequestManager {
for (PullRequestUpdate update: request.getUpdates()) {
update.setDate(new Date(System.currentTimeMillis() + 1000));
- pullRequestUpdateManager.save(update);
+ pullRequestUpdateManager.save(update, false);
}
-
+
for (ReviewInvitation invitation: request.getReviewInvitations())
reviewInvitationManager.save(invitation);
@@ -381,18 +399,18 @@ public class DefaultPullRequestManager implements PullRequestManager {
request.setLastIntegrationPreview(null);
request.setCloseStatus(CloseStatus.INTEGRATED);
- request.setUpdateDate(new Date());
+ request.setLastEventDate(new Date());
dao.persist(request);
for (PullRequestListener listener: pullRequestListeners)
- listener.onIntegrated(request);
+ listener.onIntegrated(request, null, null);
}
}
@Transactional
@Override
- public void onSourceBranchUpdate(PullRequest request) {
+ public void onSourceBranchUpdate(PullRequest request, boolean notify) {
if (request.getLatestUpdate().getHeadCommitHash().equals(request.getSource().getHeadCommitHash()))
return;
@@ -400,9 +418,10 @@ public class DefaultPullRequestManager implements PullRequestManager {
update.setRequest(request);
update.setDate(new Date());
update.setHeadCommitHash(request.getSource().getHeadCommitHash());
+ update.setUser(request.getSource().getLastUpdater());
- request.getUpdates().add(update);
- pullRequestUpdateManager.save(update);
+ request.addUpdate(update);
+ pullRequestUpdateManager.save(update, notify);
final Long requestId = request.getId();
dao.afterCommit(new Runnable() {
@@ -434,20 +453,23 @@ public class DefaultPullRequestManager implements PullRequestManager {
if (request.isOpen()) {
closeIfMerged(request);
if (request.isOpen()) {
- if (request.getStatus() == PullRequest.Status.PENDING_UPDATE) {
- notificationManager.notifyUpdate(request, false);
- } else if (request.getStatus() == PullRequest.Status.PENDING_INTEGRATE) {
+ if (request.getStatus() == PENDING_UPDATE) {
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.pendingUpdate(request);
+ } else if (request.getStatus() == PENDING_INTEGRATE) {
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.pendingIntegration(request);
+
IntegrationPreview integrationPreview = request.getIntegrationPreview();
- if (integrationPreview != null) {
- if (integrationPreview.getIntegrated() != null) {
- if (request.getAssignee() != null)
- notificationManager.notifyIntegration(request);
- else
- integrate(request, null, "Integrated automatically by system");
- }
+ if (integrationPreview != null
+ && integrationPreview.getIntegrated() != null
+ && request.getAssignee() == null) {
+ integrate(request, "Integrated automatically by system");
}
- } else if (request.getStatus() == PullRequest.Status.PENDING_APPROVAL) {
- notificationManager.pendingApproval(request);
+ } else if (request.getStatus() == PENDING_APPROVAL) {
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.pendingApproval(request);
+
for (ReviewInvitation invitation: request.getReviewInvitations()) {
if (!invitation.getDate().before(now))
reviewInvitationManager.save(invitation);
@@ -459,7 +481,7 @@ public class DefaultPullRequestManager implements PullRequestManager {
@Override
public boolean canIntegrate(PullRequest request) {
- if (request.getStatus() != PullRequest.Status.PENDING_INTEGRATE) {
+ if (request.getStatus() != PENDING_INTEGRATE) {
return false;
} else {
IntegrationPreview integrationPreview = request.getIntegrationPreview();
@@ -617,12 +639,10 @@ public class DefaultPullRequestManager implements PullRequestManager {
}
dao.persist(request);
- if (request.getStatus() == PullRequest.Status.PENDING_INTEGRATE
- && preview.getIntegrated() != null) {
- if (request.getAssignee() != null)
- notificationManager.notifyIntegration(request);
- else
- integrate(request, null, "Integrated automatically by system");
+ if (request.getStatus() == PENDING_INTEGRATE
+ && preview.getIntegrated() != null
+ && request.getAssignee() == null) {
+ integrate(request, "Integrated automatically by system");
}
for (PullRequestListener listener: pullRequestListeners)
@@ -656,4 +676,18 @@ public class DefaultPullRequestManager implements PullRequestManager {
}
+ @Override
+ public Date getLastVisitDate(PullRequest request) {
+ User user = userManager.getCurrent();
+ if (user != null) {
+ PullRequestVisit visit = request.getVisit(user);
+ if (visit != null)
+ return visit.getDate();
+ else
+ return null;
+ } else {
+ return null;
+ }
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestNotificationManager.java
similarity index 67%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestNotificationManager.java
index c4fcb433f3..33f47385ba 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestNotificationManager.java
@@ -1,5 +1,10 @@
package com.pmease.gitplex.core.manager.impl;
+import static com.pmease.gitplex.core.model.PullRequest.Status.PENDING_INTEGRATE;
+import static com.pmease.gitplex.core.model.PullRequestNotification.Task.INTEGRATE;
+import static com.pmease.gitplex.core.model.PullRequestNotification.Task.REVIEW;
+import static com.pmease.gitplex.core.model.PullRequestNotification.Task.UPDATE;
+
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -11,29 +16,39 @@ import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.hibernate.dao.EntityCriteria;
import com.pmease.gitplex.core.manager.MailManager;
-import com.pmease.gitplex.core.manager.NotificationManager;
+import com.pmease.gitplex.core.manager.PullRequestNotificationManager;
import com.pmease.gitplex.core.model.IntegrationPreview;
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.core.model.PullRequestNotification;
-import com.pmease.gitplex.core.model.PullRequestNotification.Task;
+import com.pmease.gitplex.core.model.PullRequestUpdate;
import com.pmease.gitplex.core.model.Review;
import com.pmease.gitplex.core.model.ReviewInvitation;
-
+import com.pmease.gitplex.core.model.User;
+
+/**
+ * This class manages pull request task notifications and send email to relevant users. This
+ * notification does not correlate with pull request watch notifications and can not be
+ * suppressed.
+ *
+ * @author robin
+ *
+ */
@Singleton
-public class DefaultNotificationManager implements NotificationManager {
+public class DefaultPullRequestNotificationManager implements PullRequestNotificationManager {
private final Dao dao;
private final MailManager mailManager;
@Inject
- public DefaultNotificationManager(Dao dao, MailManager mailManager) {
+ public DefaultPullRequestNotificationManager(Dao dao, MailManager mailManager) {
this.dao = dao;
this.mailManager = mailManager;
}
+ @Transactional
@Override
public void onOpened(PullRequest request) {
if (request.getAssignee() != null && !request.getAssignee().equals(request.getSubmitter()))
@@ -42,32 +57,30 @@ public class DefaultNotificationManager implements NotificationManager {
@Transactional
@Override
- public void onUpdated(PullRequest request) {
+ public void onUpdated(PullRequestUpdate update) {
Query query = dao.getSession().createQuery("delete from PullRequestNotification "
+ "where request=:request and task=:task");
- query.setParameter("request", request);
- query.setParameter("task", PullRequestNotification.Task.UPDATE);
+ query.setParameter("request", update.getRequest());
+ query.setParameter("task", UPDATE);
query.executeUpdate();
}
- @Transactional
@Override
public void onCommented(PullRequestComment comment) {
}
- @Transactional
@Override
public void onCommentReplied(PullRequestCommentReply reply) {
}
@Transactional
@Override
- public void onReviewed(Review review) {
+ public void onReviewed(Review review, String comment) {
Query query = dao.getSession().createQuery("delete from PullRequestNotification "
+ "where request=:request and user=:user and task=:task");
query.setParameter("request", review.getUpdate().getRequest());
query.setParameter("user", review.getReviewer());
- query.setParameter("task", PullRequestNotification.Task.REVIEW);
+ query.setParameter("task", REVIEW);
query.executeUpdate();
}
@@ -76,17 +89,17 @@ public class DefaultNotificationManager implements NotificationManager {
public void onAssigned(PullRequest request) {
Preconditions.checkNotNull(request.getAssignee());
- if (request.getStatus() == PullRequest.Status.PENDING_INTEGRATE) {
+ if (request.getStatus() == PENDING_INTEGRATE) {
Query query = dao.getSession().createQuery("delete from PullRequestNotification "
+ "where request=:request and task=:task");
query.setParameter("request", request);
- query.setParameter("task", PullRequestNotification.Task.INTEGRATE);
+ query.setParameter("task", INTEGRATE);
query.executeUpdate();
PullRequestNotification notification = new PullRequestNotification();
notification.setRequest(request);
notification.setUser(request.getAssignee());
- notification.setTask(PullRequestNotification.Task.INTEGRATE);
+ notification.setTask(INTEGRATE);
dao.persist(notification);
mailManager.sendMail(request.getAssignee(), "Please integrate pull request: " + request.getId(), null);
@@ -101,18 +114,18 @@ public class DefaultNotificationManager implements NotificationManager {
@Transactional
@Override
- public void onIntegrated(PullRequest request) {
+ public void onIntegrated(PullRequest request, User user, String comment) {
Query query = dao.getSession().createQuery("delete from PullRequestNotification "
- + "where request=:request and task is not null");
+ + "where request=:request");
query.setParameter("request", request);
query.executeUpdate();
}
@Transactional
@Override
- public void onDiscarded(PullRequest request) {
+ public void onDiscarded(PullRequest request, User user, String comment) {
Query query = dao.getSession().createQuery("delete from PullRequestNotification "
- + "where request=:request and task is not null");
+ + "where request=:request");
query.setParameter("request", request);
query.executeUpdate();
}
@@ -122,27 +135,30 @@ public class DefaultNotificationManager implements NotificationManager {
public void onIntegrationPreviewCalculated(PullRequest request) {
IntegrationPreview preview = request.getLastIntegrationPreview();
Preconditions.checkNotNull(preview);
- if (preview.getIntegrated() == null) {
- notifyUpdate(request, true);
+
+ if (preview.getIntegrated() != null) {
+ if (request.getStatus() == PENDING_INTEGRATE && request.getAssignee() != null)
+ requestIntegration(request);
+ } else {
mailManager.sendMail(request.getSubmitter(), "Please update pull request to resolve conflicts: " + request.getId(), null);
}
}
@Transactional
@Override
- public void notifyReview(ReviewInvitation invitation) {
+ public void onInvitingReview(ReviewInvitation invitation) {
if (!invitation.isPreferred()) {
Query query = dao.getSession().createQuery("delete from PullRequestNotification "
+ "where request=:request and user=:user and task=:task");
query.setParameter("request", invitation.getRequest());
query.setParameter("user", invitation.getReviewer());
- query.setParameter("task", PullRequestNotification.Task.REVIEW);
+ query.setParameter("task", REVIEW);
query.executeUpdate();
} else {
PullRequestNotification notification = new PullRequestNotification();
notification.setRequest(invitation.getRequest());
notification.setUser(invitation.getReviewer());
- notification.setTask(PullRequestNotification.Task.REVIEW);
+ notification.setTask(REVIEW);
EntityCriteria<PullRequestNotification> criteria = EntityCriteria.of(PullRequestNotification.class);
criteria.add(Restrictions.eq("request", notification.getRequest()))
.add(Restrictions.eq("user", notification.getUser()))
@@ -152,17 +168,38 @@ public class DefaultNotificationManager implements NotificationManager {
mailManager.sendMail(notification.getUser(), "Please review pull request: " + invitation.getRequest().getId(), null);
}
}
+
}
@Transactional
@Override
- public void notifyIntegration(PullRequest request) {
- Preconditions.checkNotNull(request.getAssignee());
-
+ public void pendingApproval(PullRequest request) {
+ Query query = dao.getSession().createQuery("delete from PullRequestNotification "
+ + "where request=:request and (task=:update or task=:integrate)");
+ query.setParameter("request", request);
+ query.setParameter("update", UPDATE);
+ query.setParameter("integrate", INTEGRATE);
+ query.executeUpdate();
+ }
+
+ @Transactional
+ @Override
+ public void onMentioned(PullRequest request, User user, String content) {
+ mailManager.sendMail(user, "You've mentioned in pull request #" + request.getId() + " (" + request.getTitle() + ")", content);
+ }
+
+ @Transactional
+ @Override
+ public void onReopened(PullRequest request, User user, String comment) {
+ if (request.getAssignee() != null && !request.getAssignee().equals(user))
+ onAssigned(request);
+ }
+
+ private void requestIntegration(PullRequest request) {
PullRequestNotification notification = new PullRequestNotification();
notification.setRequest(request);
notification.setUser(request.getAssignee());
- notification.setTask(PullRequestNotification.Task.INTEGRATE);
+ notification.setTask(INTEGRATE);
EntityCriteria<PullRequestNotification> criteria = EntityCriteria.of(PullRequestNotification.class);
criteria.add(Restrictions.eq("request", notification.getRequest()))
.add(Restrictions.eq("user", notification.getUser()))
@@ -172,34 +209,28 @@ public class DefaultNotificationManager implements NotificationManager {
mailManager.sendMail(notification.getUser(), "Please integrate pull request: " + request.getId(), null);
}
}
+
+ @Transactional
+ @Override
+ public void pendingIntegration(PullRequest request) {
+ IntegrationPreview preview = request.getLastIntegrationPreview();
+ if (preview != null && preview.getIntegrated() != null && request.getAssignee() != null)
+ requestIntegration(request);
+ }
@Transactional
@Override
- public void notifyUpdate(PullRequest request, boolean noMail) {
+ public void pendingUpdate(PullRequest request) {
PullRequestNotification notification = new PullRequestNotification();
notification.setRequest(request);
notification.setUser(request.getSubmitter());
- notification.setTask(PullRequestNotification.Task.UPDATE);
+ notification.setTask(UPDATE);
EntityCriteria<PullRequestNotification> criteria = EntityCriteria.of(PullRequestNotification.class);
criteria.add(Restrictions.eq("request", notification.getRequest()))
.add(Restrictions.eq("user", notification.getUser()))
.add(Restrictions.eq("task", notification.getTask()));
- if (dao.find(criteria) == null) {
+ if (dao.find(criteria) == null)
dao.persist(notification);
- if (!noMail)
- mailManager.sendMail(notification.getUser(), "Please update pull request: " + request.getId(), null);
- }
- }
-
- @Transactional
- @Override
- public void pendingApproval(PullRequest request) {
- Query query = dao.getSession().createQuery("delete from PullRequestNotification "
- + "where request=:request and (task=:update or task=:integrate)");
- query.setParameter("request", request);
- query.setParameter("update", Task.UPDATE);
- query.setParameter("integrate", Task.INTEGRATE);
- query.executeUpdate();
}
}
\ No newline at end of file
diff --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.java
index c7830dffa6..e7d9604d2c 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
@@ -6,6 +6,7 @@ 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;
@@ -27,19 +28,22 @@ public class DefaultPullRequestUpdateManager implements PullRequestUpdateManager
private final PullRequestCommentManager pullRequestCommentManager;
+ private final UnitOfWork unitOfWork;
+
@Inject
public DefaultPullRequestUpdateManager(Dao dao, StorageManager storageManager,
- Set<PullRequestListener> pullRequestListeners,
+ Set<PullRequestListener> pullRequestListeners, UnitOfWork unitOfWork,
PullRequestCommentManager pullRequestCommentManager) {
this.dao = dao;
this.storageManager = storageManager;
this.pullRequestListeners = pullRequestListeners;
+ this.unitOfWork = unitOfWork;
this.pullRequestCommentManager = pullRequestCommentManager;
}
@Transactional
@Override
- public void save(PullRequestUpdate update) {
+ public void save(PullRequestUpdate update, boolean notify) {
dao.persist(update);
FileUtils.cleanDir(storageManager.getCacheDir(update));
@@ -56,13 +60,33 @@ public class DefaultPullRequestUpdateManager implements PullRequestUpdateManager
sourceHead, null, null);
}
- for (PullRequestComment comment: request.getComments()) {
- if (comment.getInlineInfo() != null)
- pullRequestCommentManager.updateInline(comment);
+ if (notify) {
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.onUpdated(update);
}
- for (PullRequestListener listener: pullRequestListeners)
- listener.onUpdated(request);
+ // Inline comment update can be time consuming and we do it inside a separate thread
+ // in order not to blocking the push operation
+ 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 (PullRequestComment comment: request.getComments()) {
+ if (comment.getInlineInfo() != null)
+ pullRequestCommentManager.updateInline(comment);
+ }
+ }
+
+ });
+ }
+
+ });
}
@Transactional
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java
index 84f7c44519..2cbc929e1e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java
@@ -1,18 +1,41 @@
package com.pmease.gitplex.core.manager.impl;
+import static com.pmease.gitplex.core.model.PullRequest.Event.COMMENTED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.DISCARDED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.INTEGRATED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.OPENED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.REOPENED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.REVIEWED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.UPDATED;
+import static com.pmease.gitplex.core.model.PullRequest.Event.VERIFIED;
+
import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.hibernate.criterion.Restrictions;
-
-import com.pmease.commons.hibernate.Sessional;
+import com.google.common.collect.Sets;
+import com.pmease.commons.git.Commit;
+import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.gitplex.core.manager.MailManager;
import com.pmease.gitplex.core.manager.PullRequestWatchManager;
+import com.pmease.gitplex.core.manager.UserManager;
+import com.pmease.gitplex.core.model.BranchWatch;
+import com.pmease.gitplex.core.model.PullRequest;
+import com.pmease.gitplex.core.model.PullRequest.Event;
+import com.pmease.gitplex.core.model.PullRequestComment;
+import com.pmease.gitplex.core.model.PullRequestCommentReply;
+import com.pmease.gitplex.core.model.PullRequestUpdate;
+import com.pmease.gitplex.core.model.PullRequestVisit;
import com.pmease.gitplex.core.model.PullRequestWatch;
-import com.pmease.gitplex.core.model.Repository;
+import com.pmease.gitplex.core.model.Review;
+import com.pmease.gitplex.core.model.ReviewInvitation;
import com.pmease.gitplex.core.model.User;
@Singleton
@@ -20,18 +43,203 @@ public class DefaultPullRequestWatchManager implements PullRequestWatchManager {
private final Dao dao;
+ private final UserManager userManager;
+
+ private final MailManager mailManager;
+
@Inject
- public DefaultPullRequestWatchManager(Dao dao) {
+ public DefaultPullRequestWatchManager(Dao dao, UserManager userManager, MailManager mailManager) {
this.dao = dao;
+ this.userManager = userManager;
+ this.mailManager = mailManager;
+ }
+
+ @Transactional
+ @Override
+ public void onOpened(PullRequest request) {
+ for (BranchWatch branchWatch: request.getTarget().getWatches()) {
+ watch(request, branchWatch.getUser(),
+ "You are set to watch this pull request as you are watching the target branch.");
+ }
+
+ watch(request, request.getSubmitter(), "You are set to watch this pull request as you've opened it.");
+
+ addParticipantsToWatchList(request.getLatestUpdate());
+
+ Collection<User> excludingUsers = new HashSet<>();
+ excludingUsers.add(request.getSubmitter());
+ if (request.getAssignee() != null)
+ excludingUsers.add(request.getAssignee());
+
+ notify(request, excludingUsers, OPENED);
+ }
+
+ @Transactional
+ private void addParticipantsToWatchList(PullRequestUpdate update) {
+ if (update.getUser() != null) {
+ watch(update.getRequest(), update.getUser(),
+ "You are set to watch this pull request as you updated it.");
+ }
+ Set<String> emails = new HashSet<>();
+ for (Commit commit: update.getCommits()) {
+ emails.add(commit.getCommitter().getEmailAddress());
+ emails.add(commit.getAuthor().getEmailAddress());
+ }
+ for (String email: emails) {
+ User user = userManager.findByEmail(email);
+ if (user != null)
+ watch(update.getRequest(), user, "You are set to watch this pull request as it contains your commits.");
+ }
+ }
+
+ @Transactional
+ @Override
+ public void onReopened(PullRequest request, User user, String comment) {
+ watch(request, user, "You are set to watch this pull request as you've reopened it.");
+
+ Collection<User> excludingUsers = new HashSet<>();
+ excludingUsers.add(user);
+ if (request.getAssignee() != null)
+ excludingUsers.add(request.getAssignee());
+ notify(request, excludingUsers, REOPENED);
+ }
+
+ @Transactional
+ @Override
+ public void onUpdated(PullRequestUpdate update) {
+ addParticipantsToWatchList(update);
+
+ if (update.getUser() != null)
+ notify(update.getRequest(), Sets.newHashSet(update.getUser()), UPDATED);
+ else
+ notify(update.getRequest(), new HashSet<User>(), UPDATED);
+ }
+
+ @Transactional
+ @Override
+ public void onMentioned(PullRequest request, User user, String content) {
+ watch(request, user, "You are set to watch this pull request as you are mentioned in comment.");
+ }
+
+ @Transactional
+ @Override
+ public void onCommented(PullRequestComment comment) {
+ watch(comment.getRequest(), comment.getUser(),
+ "You are set to watch this pull request as you've commented.");
+ notify(comment.getRequest(), Sets.newHashSet(comment.getUser()), COMMENTED);
+ }
+
+ @Transactional
+ @Override
+ public void onCommentReplied(PullRequestCommentReply reply) {
+ watch(reply.getComment().getRequest(), reply.getUser(),
+ "You are set to watch this pull request as you've commented.");
+ notify(reply.getComment().getRequest(), Sets.newHashSet(reply.getUser()), COMMENTED);
+ }
+
+ @Transactional
+ @Override
+ public void onReviewed(Review review, String comment) {
+ notify(review.getUpdate().getRequest(), Sets.newHashSet(review.getReviewer()), REVIEWED);
}
- @Sessional
+ @Transactional
@Override
- public Collection<PullRequestWatch> findBy(User user, Repository repository) {
- EntityCriteria<PullRequestWatch> criteria = EntityCriteria.of(PullRequestWatch.class);
- criteria.add(Restrictions.eq("user", user));
- criteria.createCriteria("branch").add(Restrictions.eq("repository", repository));
- return dao.query(criteria);
+ public void onAssigned(PullRequest request) {
+ watch(request, request.getAssignee(),
+ "You are set to watch this pull request as you've assigned to integrate it.");
}
+ @Transactional
+ @Override
+ public void onVerified(PullRequest request) {
+ notify(request, new HashSet<User>(), VERIFIED);
+ }
+
+ @Transactional
+ @Override
+ public void onIntegrated(PullRequest request, User user, String comment) {
+ if (user != null)
+ notify(request, Sets.newHashSet(user), INTEGRATED);
+ else
+ notify(request, new HashSet<User>(), INTEGRATED);
+ }
+
+ @Transactional
+ @Override
+ public void onDiscarded(PullRequest request, User user, String comment) {
+ if (user != null)
+ notify(request, Sets.newHashSet(user), DISCARDED);
+ else
+ notify(request, new HashSet<User>(), DISCARDED);
+ }
+
+ @Override
+ public void onIntegrationPreviewCalculated(PullRequest request) {
+ }
+
+ @Transactional
+ @Override
+ public void onInvitingReview(ReviewInvitation invitation) {
+ watch(invitation.getRequest(), invitation.getReviewer(),
+ "You are set to watch this pull request as you are invited to review it.");
+ }
+
+ @Override
+ public void pendingIntegration(PullRequest request) {
+ }
+
+ @Override
+ public void pendingUpdate(PullRequest request) {
+ }
+
+ @Override
+ public void pendingApproval(PullRequest request) {
+ }
+
+ @Transactional
+ private void watch(PullRequest request, User user, String reason) {
+ PullRequestWatch watch = request.getWatch(user);
+ if (watch == null) {
+ watch = new PullRequestWatch();
+ watch.setRequest(request);
+ watch.setUser(user);
+ watch.setReason(reason);
+ request.getWatches().add(watch);
+ dao.persist(watch);
+ }
+ }
+
+ @Transactional
+ private void notify(PullRequest request, Collection<User> excludingUsers, Event event) {
+ Map<User, Date> visitDates = new HashMap<>();
+ for (PullRequestVisit visit: request.getVisits())
+ visitDates.put(visit.getUser(), visit.getDate());
+
+ Collection<User> usersToNotify = new HashSet<>();
+
+ for (PullRequestWatch watch: request.getWatches()) {
+ if (!watch.isIgnore() && !excludingUsers.contains(watch.getUser())) {
+ if (event == OPENED || event != request.getLastEvent()) {
+ usersToNotify.add(watch.getUser());
+ } else {
+ Date visitDate = visitDates.get(watch.getUser());
+ if (visitDate != null && visitDate.after(request.getLastEventDate()))
+ usersToNotify.add(watch.getUser());
+ }
+ }
+ }
+
+ if (!usersToNotify.isEmpty()) {
+ mailManager.sendMail(usersToNotify,
+ event + ": Pull request #" + request.getId() + " (" + request.getTitle() + ")",
+ "Visit url for details");
+ }
+
+ request.setLastEventDate(new Date());
+ request.setLastEvent(event);
+
+ dao.persist(request);
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java
index ec2b572085..4c867ba487 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java
@@ -35,7 +35,6 @@ import com.pmease.gitplex.core.manager.RepositoryManager;
import com.pmease.gitplex.core.manager.StorageManager;
import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.Branch;
-import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -109,13 +108,8 @@ public class DefaultRepositoryManager implements RepositoryManager {
@Transactional
@Override
public void delete(final Repository repository) {
- for (Branch branch: repository.getBranches()) {
- for (PullRequest request: branch.getOutgoingRequests()) {
- request.setSource(null);
- request.setSourceFQN(branch.getFQN());
- dao.persist(request);
- }
- }
+ for (Branch branch: repository.getBranches())
+ branchManager.delete(branch);
for (Repository each: repository.getForks()) {
each.setForkedFrom(null);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewInvitationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewInvitationManager.java
index 783084c7e8..87dbbc3d03 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewInvitationManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewInvitationManager.java
@@ -1,5 +1,7 @@
package com.pmease.gitplex.core.manager.impl;
+import java.util.Set;
+
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -9,7 +11,7 @@ import com.pmease.commons.hibernate.Sessional;
import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.hibernate.dao.EntityCriteria;
-import com.pmease.gitplex.core.manager.NotificationManager;
+import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
import com.pmease.gitplex.core.manager.ReviewInvitationManager;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.ReviewInvitation;
@@ -20,12 +22,12 @@ public class DefaultReviewInvitationManager implements ReviewInvitationManager {
private final Dao dao;
- private final NotificationManager notificationManager;
+ private final Set<PullRequestListener> pullRequestListeners;
@Inject
- public DefaultReviewInvitationManager(Dao dao, NotificationManager notificationManager) {
+ public DefaultReviewInvitationManager(Dao dao, Set<PullRequestListener> pullRequestListeners) {
this.dao = dao;
- this.notificationManager = notificationManager;
+ this.pullRequestListeners = pullRequestListeners;
}
@Sessional
@@ -40,7 +42,9 @@ public class DefaultReviewInvitationManager implements ReviewInvitationManager {
@Override
public void save(ReviewInvitation invitation) {
dao.persist(invitation);
- notificationManager.notifyReview(invitation);
+
+ for (PullRequestListener listener: pullRequestListeners)
+ listener.onInvitingReview(invitation);
}
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java
index 7d882ff675..a60376e33f 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java
@@ -17,6 +17,7 @@ import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.hibernate.dao.EntityCriteria;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.extensionpoint.PullRequestListener;
+import com.pmease.gitplex.core.manager.PullRequestCommentManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.manager.ReviewManager;
import com.pmease.gitplex.core.manager.UserManager;
@@ -34,16 +35,20 @@ public class DefaultReviewManager implements ReviewManager {
private final Dao dao;
private final PullRequestManager pullRequestManager;
+
+ private final PullRequestCommentManager pullRequestCommentManager;
private final UnitOfWork unitOfWork;
private final Set<PullRequestListener> pullRequestListeners;
@Inject
- public DefaultReviewManager(Dao dao, PullRequestManager pullRequestManager,
+ public DefaultReviewManager(Dao dao, PullRequestManager pullRequestManager,
+ PullRequestCommentManager pullRequestCommentManager,
UnitOfWork unitOfWork, Set<PullRequestListener> pullRequestListeners) {
this.dao = dao;
this.pullRequestManager = pullRequestManager;
+ this.pullRequestCommentManager = pullRequestCommentManager;
this.unitOfWork = unitOfWork;
this.pullRequestListeners = pullRequestListeners;
}
@@ -84,11 +89,12 @@ public class DefaultReviewManager implements ReviewManager {
requestComment.setDate(activity.getDate());
requestComment.setUser(reviewer);
requestComment.setContent(comment);
- dao.persist(requestComment);
+
+ pullRequestCommentManager.save(requestComment, false);
}
for (PullRequestListener listener: pullRequestListeners)
- listener.onReviewed(review);
+ listener.onReviewed(review, comment);
final Long requestId = request.getId();
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java
index 781f91265f..c8732398d1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java
@@ -9,6 +9,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.inject.Inject;
import javax.inject.Singleton;
+import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import com.google.common.base.Preconditions;
@@ -112,6 +113,14 @@ public class DefaultUserManager implements UserManager {
@Transactional
@Override
public void delete(final User user) {
+ Query query = dao.getSession().createQuery("update Branch set lastUpdater=null where lastUpdater=:lastUpdater");
+ query.setParameter("lastUpdater", user);
+ query.executeUpdate();
+
+ query = dao.getSession().createQuery("update PullRequestUpdate set user=null where user=:user");
+ query.setParameter("user", user);
+ query.executeUpdate();
+
for (Repository repository: user.getRepositories())
repositoryManager.delete(repository);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java
index 3ce576846d..18598c51a2 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java
@@ -36,20 +36,23 @@ public class Branch extends AbstractEntity {
@JoinColumn(nullable=false)
private Repository repository;
+ @ManyToOne(fetch=FetchType.LAZY)
+ private User lastUpdater;
+
@Column(nullable=false)
private String name;
private boolean isDefault;
- @OneToMany(mappedBy="target", cascade=CascadeType.REMOVE)
+ @OneToMany(mappedBy="target")
private Collection<PullRequest> incomingRequests = new ArrayList<>();
@OneToMany(mappedBy="source")
private Collection<PullRequest> outgoingRequests = new ArrayList<>();
@OneToMany(mappedBy="branch", cascade=CascadeType.REMOVE)
- private Collection<PullRequestWatch> requestWatches = new ArrayList<>();
-
+ private Collection<BranchWatch> watches = new ArrayList<>();
+
private String headCommitHash;
public Repository getRepository() {
@@ -60,6 +63,14 @@ public class Branch extends AbstractEntity {
this.repository = repository;
}
+ public User getLastUpdater() {
+ return lastUpdater;
+ }
+
+ public void setLastUpdater(User lastUpdater) {
+ this.lastUpdater = lastUpdater;
+ }
+
public String getName() {
return name;
}
@@ -84,12 +95,12 @@ public class Branch extends AbstractEntity {
this.outgoingRequests = outgoingRequests;
}
- public Collection<PullRequestWatch> getRequestWatches() {
- return requestWatches;
+ public Collection<BranchWatch> getWatches() {
+ return watches;
}
- public void setRequestWatches(Collection<PullRequestWatch> requestWatches) {
- this.requestWatches = requestWatches;
+ public void setWatches(Collection<BranchWatch> watches) {
+ this.watches = watches;
}
/**
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/BranchWatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/BranchWatch.java
new file mode 100644
index 0000000000..c59678b08e
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/BranchWatch.java
@@ -0,0 +1,42 @@
+package com.pmease.gitplex.core.model;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@SuppressWarnings("serial")
+@Entity
+@Table(uniqueConstraints={
+ @UniqueConstraint(columnNames={"branch", "user"})
+})
+public class BranchWatch extends AbstractEntity {
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Branch branch;
+
+ public Branch getBranch() {
+ return branch;
+ }
+
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private User user;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/InlineInfo.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/InlineInfo.java
index 044e36c484..036db9251a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/InlineInfo.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/InlineInfo.java
@@ -1,5 +1,7 @@
package com.pmease.gitplex.core.model;
+import java.io.Serializable;
+
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
@@ -11,7 +13,9 @@ import com.pmease.commons.git.BlobInfo;
import com.pmease.commons.util.diff.AroundContext;
@Embeddable
-public class InlineInfo {
+public class InlineInfo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
@Embedded
@AttributeOverrides({
@@ -34,6 +38,7 @@ public class InlineInfo {
private Integer line;
@Lob
+ @Column(length=65535)
private AroundContext context;
public BlobInfo getBlobInfo() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java
index f490330f37..f6fd648b8c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java
@@ -39,10 +39,10 @@ import com.pmease.commons.util.LockUtils;
import com.pmease.commons.util.Triple;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.comment.ChangeComments;
+import com.pmease.gitplex.core.gatekeeper.checkresult.Blocking;
import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;
-import com.pmease.gitplex.core.gatekeeper.checkresult.Blocking;
import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.manager.ReviewManager;
import com.pmease.gitplex.core.permission.ObjectPermission;
@@ -72,11 +72,16 @@ public class PullRequest extends AbstractEntity {
}
public enum IntegrationStrategy {
- MERGE_ALWAYS("Merge always", "Always create merge commit when integrate into target branch"),
- MERGE_IF_NECESSARY("Merge if necessary", "Create merge commit only if target branch can not be fast-forwarded to the pull request"),
- MERGE_WITH_SQUASH("Merge with squash", "Squash all commits in the pull request and then merge with target branch"),
- REBASE_SOURCE_ONTO_TARGET("Rebase source onto target", "Rebase source branch onto target branch and then fast-forward target branch to source branch"),
- REBASE_TARGET_ONTO_SOURCE("Rebase target onto source", "Rebase target branch onto source branch");
+ MERGE_ALWAYS("Merge always",
+ "Always create merge commit when integrate into target branch"),
+ MERGE_IF_NECESSARY("Merge if necessary",
+ "Create merge commit only if target branch can not be fast-forwarded to the pull request"),
+ MERGE_WITH_SQUASH("Merge with squash",
+ "Squash all commits in the pull request and then merge with target branch"),
+ REBASE_SOURCE_ONTO_TARGET("Rebase source onto target",
+ "Rebase source branch onto target branch and then fast-forward target branch to source branch"),
+ REBASE_TARGET_ONTO_SOURCE("Rebase target onto source",
+ "Rebase target branch onto source branch");
private final String displayName;
@@ -102,12 +107,15 @@ public class PullRequest extends AbstractEntity {
}
+ public enum Event {OPENED, REVIEWED, VERIFIED, UPDATED, COMMENTED, INTEGRATED, DISCARDED, REOPENED};
+
@Column
private CloseStatus closeStatus;
@Column(nullable=false)
private String title;
+ @Column(length=65535)
private String description;
@ManyToOne(fetch=FetchType.LAZY)
@@ -140,7 +148,10 @@ public class PullRequest extends AbstractEntity {
private Date createDate = new Date();
@Column(nullable=false)
- private Date updateDate = new Date();
+ private Date lastEventDate = new Date();
+
+ @Column(nullable=false)
+ private Event lastEvent = Event.OPENED;
@Column(nullable=false)
private IntegrationStrategy integrationStrategy;
@@ -163,6 +174,12 @@ public class PullRequest extends AbstractEntity {
@OneToMany(mappedBy="request", cascade=CascadeType.REMOVE)
private Collection<PullRequestNotification> notifications = new ArrayList<>();
+ @OneToMany(mappedBy="request", cascade=CascadeType.REMOVE)
+ private Collection<PullRequestVisit> visits = new ArrayList<>();
+
+ @OneToMany(mappedBy="request", cascade=CascadeType.REMOVE)
+ private Collection<PullRequestWatch> watches = new ArrayList<>();
+
private transient CheckResult checkResult;
private transient List<PullRequestUpdate> sortedUpdates;
@@ -303,12 +320,27 @@ public class PullRequest extends AbstractEntity {
this.sandbox = sandbox;
}
+ /**
+ * Get unmodifiable collection of updates of this pull request. To add update
+ * to the pull request, call {@link this#addUpdate(PullRequestUpdate)} instead.
+ *
+ * @return
+ * unmodifiable collection of updates
+ */
public Collection<PullRequestUpdate> getUpdates() {
- return updates;
+ return Collections.unmodifiableCollection(updates);
}
-
+
public void setUpdates(Collection<PullRequestUpdate> updates) {
this.updates = updates;
+ sortedUpdates = null;
+ effectiveUpdates = null;
+ }
+
+ public void addUpdate(PullRequestUpdate update) {
+ updates.add(update);
+ sortedUpdates = null;
+ effectiveUpdates = null;
}
public Collection<ReviewInvitation> getReviewInvitations() {
@@ -351,6 +383,22 @@ public class PullRequest extends AbstractEntity {
this.notifications = notifications;
}
+ public Collection<PullRequestVisit> getVisits() {
+ return visits;
+ }
+
+ public void setVisits(Collection<PullRequestVisit> visits) {
+ this.visits = visits;
+ }
+
+ public Collection<PullRequestWatch> getWatches() {
+ return watches;
+ }
+
+ public void setWatches(Collection<PullRequestWatch> watches) {
+ this.watches = watches;
+ }
+
public Status getStatus() {
if (closeStatus == CloseStatus.INTEGRATED)
return Status.INTEGRATED;
@@ -442,8 +490,8 @@ public class PullRequest extends AbstractEntity {
*/
public List<PullRequestUpdate> getSortedUpdates() {
if (sortedUpdates == null) {
- Preconditions.checkState(getUpdates().size() >= 1);
- sortedUpdates = new ArrayList<PullRequestUpdate>(getUpdates());
+ Preconditions.checkState(updates.size() >= 1);
+ sortedUpdates = new ArrayList<PullRequestUpdate>(updates);
Collections.sort(sortedUpdates);
}
return sortedUpdates;
@@ -637,12 +685,20 @@ public class PullRequest extends AbstractEntity {
this.createDate = createDate;
}
- public Date getUpdateDate() {
- return updateDate;
+ public Date getLastEventDate() {
+ return lastEventDate;
+ }
+
+ public void setLastEventDate(Date lastEventDate) {
+ this.lastEventDate = lastEventDate;
+ }
+
+ public Event getLastEvent() {
+ return lastEvent;
}
- public void setUpdateDate(Date updateDate) {
- this.updateDate = updateDate;
+ public void setLastEvent(Event lastEvent) {
+ this.lastEvent = lastEvent;
}
/**
@@ -724,8 +780,12 @@ public class PullRequest extends AbstractEntity {
}
public List<Review> getReviews() {
- if (reviews == null)
- reviews = GitPlex.getInstance(ReviewManager.class).findBy(this);
+ if (reviews == null) {
+ if (!isNew())
+ reviews = GitPlex.getInstance(ReviewManager.class).findBy(this);
+ else
+ reviews = new ArrayList<>();
+ }
return reviews;
}
@@ -774,6 +834,29 @@ public class PullRequest extends AbstractEntity {
}
return reviewers;
}
+
+ @Nullable
+ public PullRequestWatch getWatch(User user) {
+ for (PullRequestWatch watch: getWatches()) {
+ if (watch.getUser().equals(user))
+ return watch;
+ }
+ return null;
+ }
+
+ @Nullable
+ public PullRequestVisit getVisit(User user) {
+ for (PullRequestVisit visit: getVisits()) {
+ if (visit.getUser().equals(user))
+ return visit;
+ }
+ return null;
+ }
+
+ public String getUrl() {
+ return GitPlex.getInstance().getServerUrl() + "/" + getTarget().getRepository().getFQN()
+ + "/pull_requests/" + getId() + "/overview";
+ }
private static class ChangeKey extends Triple<String, String, String> {
diff --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.java
index b1018b8b8c..07d63547c9 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
@@ -28,6 +28,7 @@ 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.PullRequestCommentReplyManager;
+import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.manager.UserManager;
@SuppressWarnings("serial")
@@ -42,7 +43,7 @@ public class PullRequestComment extends AbstractEntity implements InlineComment
@ManyToOne(fetch=FetchType.LAZY)
private User user;
- @Column(nullable=false)
+ @Column(nullable=false, length=65535)
private String content;
@Column(nullable=false)
@@ -215,5 +216,10 @@ public class PullRequestComment extends AbstractEntity implements InlineComment
inlineInfo = new InlineInfo();
inlineInfo.setContext(context);
}
+
+ @Override
+ public Date getLastVisitDate() {
+ return GitPlex.getInstance(PullRequestManager.class).getLastVisitDate(getRequest());
+ }
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java
index 15bd8d06ff..d27cfca46f 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestCommentReply.java
@@ -2,6 +2,7 @@ package com.pmease.gitplex.core.model;
import java.util.Date;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
@@ -20,8 +21,10 @@ public class PullRequestCommentReply extends AbstractEntity implements CommentRe
@JoinColumn(nullable=false)
private User user;
+ @Column(nullable=false)
private Date date;
+ @Column(nullable=false, length=65535)
private String content;
@ManyToOne
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestNotification.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestNotification.java
index fa3d28501c..77ab55fa06 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestNotification.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestNotification.java
@@ -19,7 +19,22 @@ import com.pmease.commons.hibernate.AbstractEntity;
})
public class PullRequestNotification extends AbstractEntity {
- public enum Task {REVIEW, UPDATE, INTEGRATE};
+ public enum Task {
+ REVIEW("Please review this pull request."),
+ UPDATE("Please update this pull request."),
+ INTEGRATE("Please integrate this pull request.");
+
+ private final String displayName;
+
+ Task(String displayName) {
+ this.displayName = displayName;
+ }
+
+ @Override
+ public String toString() {
+ return displayName;
+ }
+ };
@ManyToOne
@JoinColumn(nullable=false)
@@ -29,6 +44,7 @@ public class PullRequestNotification extends AbstractEntity {
@JoinColumn(nullable=false)
private User user;
+ @Column(nullable=false)
private Task task;
@Column(nullable=false)
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestOperation.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestOperation.java
index 687409c63b..bc237f9a5a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestOperation.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestOperation.java
@@ -27,8 +27,7 @@ public enum PullRequestOperation {
@Override
public void operate(PullRequest request, String comment) {
- User user = GitPlex.getInstance(UserManager.class).getCurrent();
- GitPlex.getInstance(PullRequestManager.class).integrate(request, user, comment);
+ GitPlex.getInstance(PullRequestManager.class).integrate(request, comment);
}
},
@@ -44,8 +43,7 @@ public enum PullRequestOperation {
@Override
public void operate(PullRequest request, String comment) {
- User user = GitPlex.getInstance(UserManager.class).getCurrent();
- GitPlex.getInstance(PullRequestManager.class).discard(request, user, comment);
+ GitPlex.getInstance(PullRequestManager.class).discard(request, comment);
}
},
@@ -101,8 +99,7 @@ public enum PullRequestOperation {
@Override
public void operate(PullRequest request, String comment) {
- User user = GitPlex.getInstance(UserManager.class).getCurrent();
- GitPlex.getInstance(PullRequestManager.class).reopen(request, user, comment);
+ GitPlex.getInstance(PullRequestManager.class).reopen(request, comment);
}
};
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java
index 51dea3a1b4..026668a0dc 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java
@@ -39,6 +39,9 @@ public class PullRequestUpdate extends AbstractEntity {
@JoinColumn(nullable=false)
private PullRequest request;
+ @ManyToOne
+ private User user;
+
@Column(nullable=false)
private String headCommitHash;
@@ -60,6 +63,14 @@ public class PullRequestUpdate extends AbstractEntity {
this.request = request;
}
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
public String getHeadCommitHash() {
return headCommitHash;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestVisit.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestVisit.java
new file mode 100644
index 0000000000..0568794ab6
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestVisit.java
@@ -0,0 +1,55 @@
+package com.pmease.gitplex.core.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@SuppressWarnings("serial")
+@Entity
+@Table(uniqueConstraints={@UniqueConstraint(columnNames={"request", "user"})})
+public class PullRequestVisit extends AbstractEntity {
+
+ @ManyToOne
+ @JoinColumn(nullable=false)
+ private PullRequest request;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private User user;
+
+ @Column(nullable=false)
+ private Date date = new Date();
+
+ public PullRequest getRequest() {
+ return request;
+ }
+
+ public void setRequest(PullRequest request) {
+ this.request = request;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java
index fc5e9f21fe..122e3d45fa 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java
@@ -1,5 +1,6 @@
package com.pmease.gitplex.core.model;
+import javax.annotation.Nullable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
@@ -12,26 +13,30 @@ import com.pmease.commons.hibernate.AbstractEntity;
@SuppressWarnings("serial")
@Entity
@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"branch", "user"})
+ @UniqueConstraint(columnNames={"request", "user"})
})
public class PullRequestWatch extends AbstractEntity {
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(nullable=false)
- private Branch branch;
+ private PullRequest request;
- public Branch getBranch() {
- return branch;
- }
-
- public void setBranch(Branch branch) {
- this.branch = branch;
- }
-
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(nullable=false)
private User user;
+ private String reason;
+
+ private boolean ignore;
+
+ public PullRequest getRequest() {
+ return request;
+ }
+
+ public void setRequest(PullRequest request) {
+ this.request = request;
+ }
+
public User getUser() {
return user;
}
@@ -39,4 +44,22 @@ public class PullRequestWatch extends AbstractEntity {
public void setUser(User user) {
this.user = user;
}
+
+ @Nullable
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public boolean isIgnore() {
+ return ignore;
+ }
+
+ public void setIgnore(boolean ignore) {
+ this.ignore = ignore;
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java
index f37de56b6d..098aa8c908 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java
@@ -80,11 +80,11 @@ public class Repository extends AbstractEntity implements UserBelonging {
private String description;
@Lob
- @Column(nullable=false)
+ @Column(nullable=false, length=65535)
private ArrayList<GateKeeper> gateKeepers = new ArrayList<>();
@Lob
- @Column(nullable=false)
+ @Column(nullable=false, length=65535)
private ArrayList<IntegrationPolicy> integrationPolicies = new ArrayList<>();
@Column(nullable=false)
@@ -93,7 +93,7 @@ public class Repository extends AbstractEntity implements UserBelonging {
@OneToMany(mappedBy="repository", cascade=CascadeType.REMOVE)
private Collection<Authorization> authorizations = new ArrayList<>();
- @OneToMany(mappedBy="repository", cascade=CascadeType.REMOVE)
+ @OneToMany(mappedBy="repository")
private Collection<Branch> branches = new ArrayList<>();
@OneToMany(mappedBy="forkedFrom")
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java
index 2a9640f01f..b6dfd351f1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java
@@ -48,13 +48,13 @@ public class User extends AbstractUser implements ProtectedObject {
@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
private Collection<Membership> memberships = new ArrayList<>();
- @OneToMany(mappedBy="owner", cascade=CascadeType.REMOVE)
+ @OneToMany(mappedBy="owner")
private Collection<Repository> repositories = new ArrayList<>();
@OneToMany(mappedBy="owner", cascade=CascadeType.REMOVE)
private Collection<Team> teams = new ArrayList<Team>();
- @OneToMany(mappedBy="submitter", cascade=CascadeType.REMOVE)
+ @OneToMany(mappedBy="submitter")
private Collection<PullRequest> submittedRequests = new ArrayList<>();
@OneToMany(mappedBy="reviewer", cascade=CascadeType.REMOVE)
@@ -69,12 +69,18 @@ public class User extends AbstractUser implements ProtectedObject {
@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
private Collection<PullRequestCommentReply> requestCommentReplies = new ArrayList<>();
+ @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
+ private Collection<BranchWatch> branchWatches = new ArrayList<>();
+
@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
private Collection<PullRequestWatch> requestWatches = new ArrayList<>();
@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
private Collection<PullRequestNotification> requestNotifications = new ArrayList<>();
+ @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
+ private Collection<PullRequestVisit> requestVisits = new ArrayList<>();
+
@Editable(order=100)
@UserName
@NotEmpty
@@ -190,12 +196,12 @@ public class User extends AbstractUser implements ProtectedObject {
this.requestCommentReplies = requestCommentReplies;
}
- public Collection<PullRequestWatch> getRequestWatches() {
- return requestWatches;
+ public Collection<BranchWatch> getBranchWatches() {
+ return branchWatches;
}
- public void setRequestWatches(Collection<PullRequestWatch> requestWatches) {
- this.requestWatches = requestWatches;
+ public void setBranchWatches(Collection<BranchWatch> branchWatches) {
+ this.branchWatches = branchWatches;
}
public Collection<PullRequestNotification> getRequestNotifications() {
diff --git a/gitplex.core/src/test/java/com/pmease/gitplex/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java b/gitplex.core/src/test/java/com/pmease/gitplex/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java
index da52edd3ad..b19d356189 100644
--- a/gitplex.core/src/test/java/com/pmease/gitplex/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java
+++ b/gitplex.core/src/test/java/com/pmease/gitplex/core/gatekeeper/IfApprovedByMajoritiesOfSpecifiedTeamTest.java
@@ -137,7 +137,7 @@ public class IfApprovedByMajoritiesOfSpecifiedTeamTest extends AbstractGitTest {
update.setHeadCommitHash(git.parseRevision("dev", true));
update.setId(1L);
update.setRequest(request);
- request.getUpdates().add(update);
+ request.addUpdate(update);
Review review = new Review();
review.setId(1L);
diff --git a/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestTest.java b/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestTest.java
index 6a5176338b..15e5d77622 100644
--- a/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestTest.java
+++ b/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestTest.java
@@ -41,7 +41,7 @@ public class PullRequestTest extends AbstractGitTest {
update1.setRequest(request);
git.updateRef(update1.getHeadRef(), "HEAD", null, null);
update1.setHeadCommitHash(git.parseRevision(update1.getHeadRef(), true));
- request.getUpdates().add(update1);
+ request.addUpdate(update1);
addFileAndCommit("c", "", "commit");
@@ -50,7 +50,7 @@ public class PullRequestTest extends AbstractGitTest {
update2.setRequest(request);
git.updateRef(update2.getHeadRef(), "HEAD", null, null);
update2.setHeadCommitHash(git.parseRevision(update2.getHeadRef(), true));
- request.getUpdates().add(update2);
+ request.addUpdate(update2);
Assert.assertEquals(request.getEffectiveUpdates().size(), 2);
}
@@ -79,7 +79,7 @@ public class PullRequestTest extends AbstractGitTest {
git.updateRef(update1.getHeadRef(), "HEAD", null, null);
update1.setHeadCommitHash(git.parseRevision(update1.getHeadRef(), true));
String secondRef = update1.getHeadRef();
- request.getUpdates().add(update1);
+ request.addUpdate(update1);
addFileAndCommit("d", "", "dev:4");
@@ -88,7 +88,7 @@ public class PullRequestTest extends AbstractGitTest {
update2.setRequest(request);
git.updateRef(update2.getHeadRef(), "HEAD", null, null);
update2.setHeadCommitHash(git.parseRevision(update2.getHeadRef(), true));
- request.getUpdates().add(update2);
+ request.addUpdate(update2);
git.checkout("master", null);
diff --git a/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestUpdateTest.java b/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestUpdateTest.java
index 92e301c56c..54f81c4428 100644
--- a/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestUpdateTest.java
+++ b/gitplex.core/src/test/java/com/pmease/gitplex/core/model/PullRequestUpdateTest.java
@@ -84,14 +84,14 @@ public class PullRequestUpdateTest extends AbstractGitTest {
update1.setRequest(request);
update1.setHeadCommitHash(bareGit.showRevision("dev~1").getHash());
bareGit.updateRef(update1.getHeadRef(), update1.getHeadCommitHash(), null, null);
- request.getUpdates().add(update1);
+ request.addUpdate(update1);
PullRequestUpdate update2 = new PullRequestUpdate();
update2.setId(2L);
update2.setRequest(request);
update2.setHeadCommitHash(bareGit.showRevision("dev").getHash());
bareGit.updateRef(update2.getHeadRef(), update2.getHeadCommitHash(), null, null);
- request.getUpdates().add(update2);
+ request.addUpdate(update2);
target.setHeadCommitHash(bareGit.parseRevision("master", true));
@@ -129,14 +129,14 @@ public class PullRequestUpdateTest extends AbstractGitTest {
update1.setRequest(request);
update1.setHeadCommitHash(bareGit.showRevision("dev~2").getHash());
bareGit.updateRef(update1.getHeadRef(), update1.getHeadCommitHash(), null, null);
- request.getUpdates().add(update1);
+ request.addUpdate(update1);
PullRequestUpdate update2 = new PullRequestUpdate();
update2.setId(2L);
update2.setRequest(request);
update2.setHeadCommitHash(bareGit.showRevision("dev").getHash());
bareGit.updateRef(update2.getHeadRef(), update2.getHeadCommitHash(), null, null);
- request.getUpdates().add(update2);
+ request.addUpdate(update2);
target.setHeadCommitHash(bareGit.parseRevision("master", true));
@@ -174,7 +174,7 @@ public class PullRequestUpdateTest extends AbstractGitTest {
update1.setRequest(request);
update1.setHeadCommitHash(bareGit.showRevision("dev").getHash());
bareGit.updateRef(update1.getHeadRef(), update1.getHeadCommitHash(), null, null);
- request.getUpdates().add(update1);
+ request.addUpdate(update1);
git.merge("master", null, null, null, "merge master to dev");
git.push(bareGit.repoDir().getAbsolutePath(), "dev:dev");
@@ -184,7 +184,7 @@ public class PullRequestUpdateTest extends AbstractGitTest {
update2.setRequest(request);
update2.setHeadCommitHash(bareGit.showRevision("dev").getHash());
bareGit.updateRef(update2.getHeadRef(), update2.getHeadCommitHash(), null, null);
- request.getUpdates().add(update2);
+ request.addUpdate(update2);
target.setHeadCommitHash(bareGit.parseRevision("master", true));
@@ -221,7 +221,7 @@ public class PullRequestUpdateTest extends AbstractGitTest {
update1.setId(1L);
update1.setRequest(request);
update1.setHeadCommitHash(git.showRevision("dev").getHash());
- request.getUpdates().add(update1);
+ request.addUpdate(update1);
addFileAndCommit("d2", "", "d2");
@@ -243,7 +243,7 @@ public class PullRequestUpdateTest extends AbstractGitTest {
update2.setHeadCommitHash(bareGit.showRevision("dev").getHash());
bareGit.updateRef(update2.getHeadRef(), update2.getHeadCommitHash(), null, null);
- request.getUpdates().add(update2);
+ request.addUpdate(update2);
target.setHeadCommitHash(bareGit.parseRevision("master", 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.css
index d36ba8a905..da9703894b 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
@@ -772,7 +772,9 @@ ul.diff-alerts {margin: 0 0 0 8px; padding: 4px 8px 4px 12px;}
max-width: 600px; color: #777; white-space: nowrap;}
/* COMMENTS */
+.reply>.activity {padding-left: 4px;}
.reply>.activity>div.summary {font-size: 13px;}
+.reply.new>.avatar {background: #FCF6D6;}
.comment-input textarea {width: 100%; min-height: 80px;}
.comment-input>.tab-pane {padding: 12px 0;}
.comment-input>.tab-pane>.preview {display: none;}
@@ -889,14 +891,15 @@ ul.status-help li:last-child .description {border-bottom: none;}
.request-detail .activities>table {margin-bottom: 20px; border-bottom: 1px solid #E5E5E5;}
.request-detail .activities>table>tbody>tr.discussion>td {border-top: 1px solid #E5E5E5; padding: 12px 0;}
.request-detail .activities>table>tbody>tr.discussion.collapsed>td {padding: 8px 0;}
-.request-detail .activities>table>tbody>tr.discussion>td.avatar {width: 1px; padding-right: 12px;}
+.request-detail .activities>table>tbody>tr.discussion>td.avatar {width: 1px; padding-left: 12px; padding-right: 12px;}
.request-detail .activities>table>tbody>tr.discussion>td.activity {padding-left: 12px;}
.request-detail .activities>table>tbody>tr.activity>td.avatar {border-right: 1px dashed #DDD;}
+
.request-detail .activities>table>tbody>tr.activity.discussion>td.avatar {border-right: none;}
.request-detail .activities>table>tbody>tr.discussion+.non-discussion>td {border-top: 1px solid #E5E5E5;}
.request-detail .activities>table>tbody>tr.discussion+.non-update>td {padding-top: 8px;}
.request-detail .activities>table>tbody>tr.discussion>.avatar img {width: 40px; height: 40px;}
-.request-detail .activities>table>tbody>tr.non-discussion>td {padding-left: 6px;}
+.request-detail .activities>table>tbody>tr.non-discussion>td {padding-left: 6px; font-size: 13px;}
.request-detail .activities>table>tbody>tr.non-discussion>td.avatar img {display: none;}
.request-detail .activities>table>tbody>tr.non-discussion>.activity>div.summary .user a {font-weight: normal;}
.request-detail .activities>table>tbody>tr.update+.update>td>table {margin-top: -12px;}
@@ -910,33 +913,34 @@ ul.status-help li:last-child .description {border-bottom: none;}
.request-detail .activities .activity>.commits td.detail {padding-left: 15px; padding-right: 8px;}
.request-detail .activities .activity>.commits td.status {text-align: right;}
.request-detail .activities .activity>.commits tr:hover td.detail,
-.request-detail .activities .activity>.commits tr:hover td.status {background: #F7ECB9;}
+.request-detail .activities .activity>.commits tr:hover td.status {background: #F5F5F5;}
.request-detail .activities .activity>.commits tr.rebased td a {color: #AAA;}
.request-detail .activities .activity>.commits tr.rebased td.icon .pa {color: #CCC;}
.request-detail .activities .activity>.commits tr.rebased img.avatar {opacity: 0.5;}
.request-detail .activities .activity>.commits td.status .successful {color: #35A612;}
.request-detail .activities .activity>.commits td.status .failed {color: #F93333;}
.request-detail .activities .activity>.commits td.status .running {color: #AFAD1F;}
+.request-detail .activities .activity.new>.avatar {background: #FCF6D6;}
-.request-detail .others>.branches>.target {padding-bottom: 4px; border-bottom: 1px dotted #BBB; margin-bottom: 4px;}
-.request-detail .others>.branches span, .request-detail .others>.branches a {white-space: nowrap;}
-.request-detail .others>.branches>.source>a {margin-left: 4px;}
+.request-detail .others>div>div {border-bottom: 1px dotted #BBB; margin-bottom: 16px;
+ padding-bottom: 16px; font-size: 13px; color: #666;}
+.request-detail .others>div>div:last-child {border-bottom: none; margin-bottom: 0; padding-bottom: 0;}
+.request-detail .others .help-block {margin-bottom: 0; color: #888}
+.request-detail .others .fa {font-size: 14px; vertical-align: middle;}
.request-detail .others label {margin-right: 4px; font-weight: normal;}
-
-.request-detail .others>.integration>.preview>.alert {border-radius: 0 0 4px 4px; margin: 10px -20px -20px -20px;}
-.request-detail .others>.integration>.preview .detail {margin-left: 6px;}
-.request-detail .others>.integration>.preview img {width: 20px; height: 20px; vertical-align: bottom;}
+.request-detail .others .select2-container {width: 100%;}
+.request-detail .others .avatar {width: 24px; height: 24px;}
+.request-detail .others .select2-container .avatar {width: 20px; height: 20px;}
-.request-detail .others>.assignee>img {width: 32px; height: 32px;}
+.request-detail .others .basic-info .submitter, .request-detail .others .basic-info .target {margin-bottom: 4px;}
+.request-detail .others .basic-info span, .request-detail .others .basic-info a {white-space: nowrap;}
+.request-detail .others .basic-info .source>a {margin-left: 4px;}
-.request-detail .others>.reviewers ul {margin-bottom: 0;}
-.request-detail .others>.reviewers li {margin-right: 20px; margin-bottom: 10px; position: relative;}
-.request-detail .others>.reviewers li a:hover {text-decoration: none;}
-.request-detail .others>.reviewers .review-result {top: 12px;}
+.request-detail .others .reviewers ul {margin-bottom: 0;}
+.request-detail .others .reviewers li {margin-right: 20px; margin-bottom: 10px; position: relative;}
+.request-detail .others .reviewers li a:hover {text-decoration: none;}
+.request-detail .others .reviewers .review-result {top: 12px;}
-.request-detail .others>.assignee>label {margin-right: 8px;}
-.request-detail .others .select2-container {width: 100%;}
-
.request-detail .activities .table-diff>tbody>.line.comments>td {padding: 12px;}
.request-detail .activities .table-diff>tbody>tr.omit>td .pa {font-size: 24px; color: #888; margin-left: 12px;}
.request-detail .activities .inline-comment.panel>.panel-heading {padding: 8px;}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branch/BranchLink.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branch/BranchLink.java
index a2c72b4256..045babd526 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branch/BranchLink.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branch/BranchLink.java
@@ -46,11 +46,15 @@ public class BranchLink extends Panel {
@Override
public String getObject() {
- RepositoryPage page = (RepositoryPage) getPage();
- if (page.getRepository().equals(getBranch().getRepository()))
- return getBranch().getName();
- else
+ if (getPage() instanceof RepositoryPage) {
+ RepositoryPage page = (RepositoryPage) getPage();
+ if (page.getRepository().equals(getBranch().getRepository()))
+ return getBranch().getName();
+ else
+ return getBranch().getFQN();
+ } else {
return getBranch().getFQN();
+ }
}
}));
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.html
index aff8679756..fc7924e2ab 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
@@ -16,7 +16,9 @@
<table>
<tbody>
<tr wicket:id="replies" class="reply">
- <td class="avatar"><span wicket:id="avatar"></span></td>
+ <td wicket:id="avatar" class="avatar">
+ <div wicket:id="avatar"></div>
+ </td>
<td class="detail activity">
<div class="summary">
<span wicket:id="user" class="user"></span> replied <span wicket:id="age"></span>
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.java
index 71528348cb..500a6f3304 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
@@ -10,6 +10,7 @@ import org.apache.wicket.Component;
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.behavior.AttributeAppender;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.ComponentTag;
@@ -40,7 +41,6 @@ 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.event.PullRequestChanged;
-import com.pmease.gitplex.web.model.ModelWrapper;
import com.pmease.gitplex.web.model.UserModel;
@SuppressWarnings("serial")
@@ -50,9 +50,7 @@ public class CommentPanel extends Panel {
private RepeatingView repliesView;
- private ModelWrapper<CommentReply> replyModelWrapper;
-
- private IModel<List<CommentReply>> repliesModel = new LoadableDetachableModel<List<CommentReply>>() {
+ private final IModel<List<CommentReply>> repliesModel = new LoadableDetachableModel<List<CommentReply>>() {
@Override
protected List<CommentReply> load() {
@@ -70,10 +68,8 @@ public class CommentPanel extends Panel {
};
- public CommentPanel(String id, IModel<? extends Comment> commentModel, ModelWrapper<CommentReply> replyModelWrapper) {
+ public CommentPanel(String id, IModel<? extends Comment> commentModel) {
super(id, commentModel);
-
- this.replyModelWrapper = replyModelWrapper;
}
private Comment getComment() {
@@ -358,9 +354,12 @@ public class CommentPanel extends Panel {
}
private Component newReplyRow(String id, CommentReply reply) {
- final WebMarkupContainer row = new WebMarkupContainer(id, replyModelWrapper.asModel(reply));
+ final WebMarkupContainer row = new WebMarkupContainer(id, Model.of(reply));
row.setOutputMarkupId(true);
- row.add(new UserLink("avatar", new UserModel(reply.getUser()), AvatarMode.AVATAR));
+
+ WebMarkupContainer avatarColumn = new WebMarkupContainer("avatar");
+ avatarColumn.add(new UserLink("avatar", new UserModel(reply.getUser()), AvatarMode.AVATAR));
+ row.add(avatarColumn);
row.add(new UserLink("user", new UserModel(reply.getUser()), AvatarMode.NAME));
row.add(new AgeLabel("age", Model.of(reply.getDate())));
@@ -442,17 +441,16 @@ public class CommentPanel extends Panel {
}.add(new ConfirmBehavior("Do you really want to delete this reply?")));
- row.add(newAdditionalReplyActions("additionalActions", new AbstractReadOnlyModel<CommentReply>() {
-
- @Override
- public CommentReply getObject() {
- return (CommentReply) row.getDefaultModelObject();
- }
-
- }));
+ row.add(newAdditionalReplyActions("additionalActions", (CommentReply) row.getDefaultModelObject()));
row.add(renderForView(reply.getContent()));
+ Date lastVisitDate = getComment().getLastVisitDate();
+ if (lastVisitDate != null && lastVisitDate.before(reply.getDate())) {
+ row.add(AttributeAppender.append("class", " new"));
+ avatarColumn.add(AttributeAppender.append("title", "New reply since your last visit"));
+ }
+
return row;
}
@@ -460,7 +458,7 @@ public class CommentPanel extends Panel {
return new WebMarkupContainer(id);
}
- protected Component newAdditionalReplyActions(String id, IModel<CommentReply> reply) {
+ protected Component newAdditionalReplyActions(String id, CommentReply reply) {
return new WebMarkupContainer(id);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/BlobDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/BlobDiffPanel.java
index cc4c1b3309..5fcb0273a0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/BlobDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/BlobDiffPanel.java
@@ -24,7 +24,8 @@ public class BlobDiffPanel extends Panel {
private final InlineCommentSupport commentSupport;
- public BlobDiffPanel(String id, IModel<Repository> repoModel, Change change, InlineCommentSupport commentSupport) {
+ public BlobDiffPanel(String id, IModel<Repository> repoModel,
+ Change change, InlineCommentSupport commentSupport) {
super(id);
this.repoModel = repoModel;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/CompareResultPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/CompareResultPanel.java
index b0efe8ce03..42b17f39dd 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/CompareResultPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/CompareResultPanel.java
@@ -78,10 +78,11 @@ public abstract class CompareResultPanel extends Panel {
add(changeNav = newChangeNav(activeChange == null || activeChange.getStatus() != UNCHANGED));
- if (activeChange != null)
+ if (activeChange != null) {
changeContent = new BlobDiffPanel("content", repoModel, activeChange, getInlineCommentSupport(activeChange));
- else
+ } else {
changeContent = new WebMarkupContainer("content");
+ }
changeContent.setOutputMarkupId(true);
add(changeContent);
}
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.java
index b6da9e484e..09dffcd1b9 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
@@ -62,11 +62,9 @@ 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.PullRequestCommentReply;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.core.permission.ObjectPermission;
@@ -74,8 +72,6 @@ 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")
@@ -122,7 +118,7 @@ public class TextDiffPanel extends Panel {
private AbstractDefaultAjaxBehavior addCommentBehavior;
private String autoScrollScript;
-
+
public TextDiffPanel(String id, final IModel<Repository> repoModel, Change change,
final @Nullable InlineCommentSupport commentSupport) {
super(id);
@@ -839,14 +835,7 @@ public class TextDiffPanel extends Panel {
@Override
protected void populateItem(ListItem<InlineComment> item) {
item.add(new UserLink("avatar", new UserModel(item.getModelObject().getUser()), AvatarMode.AVATAR));
- item.add(new CommentPanel("comment", item.getModel(), new ModelWrapper<CommentReply>() {
-
- @Override
- public IModel<PullRequestCommentReply> asModel(CommentReply object) {
- return new EntityModel<PullRequestCommentReply>((PullRequestCommentReply) object);
- }
-
- }).setOutputMarkupId(true));
+ item.add(new CommentPanel("comment", item.getModel()).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/component/pullrequest/RequestLink.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/RequestLink.html
new file mode 100644
index 0000000000..cb28c75a61
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/RequestLink.html
@@ -0,0 +1,3 @@
+<wicket:panel>
+<a wicket:id="link"><span wicket:id="label"></span></a>
+</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/RequestLink.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/RequestLink.java
index 84414dff6b..fba0245533 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/RequestLink.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/RequestLink.java
@@ -1,38 +1,52 @@
package com.pmease.gitplex.web.component.pullrequest;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.web.page.repository.pullrequest.RequestOverviewPage;
@SuppressWarnings("serial")
-public class RequestLink extends BookmarkablePageLink<Void> {
+public class RequestLink extends Panel {
- private String title;
-
- public RequestLink(String id, PullRequest request) {
- super(id, RequestOverviewPage.class, RequestOverviewPage.paramsOf(request));
-
- title = request.getTitle();
+ public RequestLink(String id, IModel<PullRequest> model) {
+ super(id, model);
}
@Override
- public void onComponentTagBody(final MarkupStream markupStream,
- final ComponentTag openTag) {
-
- // Draw anything before the body?
- if (!isLinkEnabled() && (getBeforeDisabledLink() != null)) {
- getResponse().write(getBeforeDisabledLink());
- }
+ protected void onInitialize() {
+ super.onInitialize();
- replaceComponentTagBody(markupStream, openTag, title);
+ add(new BookmarkablePageLink<Void>("link", RequestOverviewPage.class) {
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new Label("label", new AbstractReadOnlyModel<String>() {
- // Draw anything after the body?
- if (!isLinkEnabled() && (getAfterDisabledLink() != null)) {
- getResponse().write(getAfterDisabledLink());
- }
+ @Override
+ public String getObject() {
+ return getPullRequest().getTitle();
+ }
+
+ }));
+ }
+
+ @Override
+ public PageParameters getPageParameters() {
+ return RequestOverviewPage.paramsOf(getPullRequest());
+ }
+
+ });
}
+ private PullRequest getPullRequest() {
+ return (PullRequest) getDefaultModelObject();
+ }
+
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/user/RemoveableAvatar.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/user/RemoveableAvatar.java
index 89a5440eff..bb464c8984 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/user/RemoveableAvatar.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/user/RemoveableAvatar.java
@@ -45,10 +45,14 @@ public abstract class RemoveableAvatar extends Panel {
// Force nowrap here when display tooltip as otherwise user name will be wrapped inside
// an element with position set to relative
String tooltip;
- if (isEnabled())
- tooltip = actionName!=null?actionName:"" + " " + userModel.getObject().getDisplayName();
- else
+ if (isEnabled()) {
+ if (actionName != null)
+ tooltip = actionName + " " + userModel.getObject().getDisplayName();
+ else
+ tooltip = userModel.getObject().getDisplayName();
+ } else {
tooltip = userModel.getObject().getDisplayName();
+ }
return "<span style='white-space: nowrap;'>" + StringEscapeUtils.escapeHtml4(tooltip) + "</span>";
}
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.java
deleted file mode 100644
index 7c370849a0..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/model/ModelWrapper.java
+++ /dev/null
@@ -1,9 +0,0 @@
-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/LayoutPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.html
index 2d8a332dae..afdaa2a371 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.html
@@ -27,6 +27,7 @@
<li><a class="has-tip" data-toggle="tooltip" title="Create a new repository" wicket:id="newRepoLink"><i class="pa pa-repo-add"></i></a></li>
<li><a class="has-tip" data-toggle="tooltip" title="Sign out" wicket:id="logoutLink"><i class="pa pa-sign-out"></i></a></li>
<li class="separator"></li>
+ <li><a class="has-tip" data-toggle="tooltip" title="You've got tasks" wicket:id="notificationLink"><i class="fa fa-circle"></i></a></li>
<li class="avatar-user"><wicket:container wicket:id="userLink"></wicket:container></li>
</wicket:enclosure>
</ul>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.java
index 7701357a26..cc7729720b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/LayoutPage.java
@@ -14,6 +14,7 @@ import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.core.permission.ObjectPermission;
import com.pmease.gitplex.web.component.user.UserLink;
import com.pmease.gitplex.web.model.UserModel;
+import com.pmease.gitplex.web.page.account.AccountNotificationsPage;
import com.pmease.gitplex.web.page.account.AccountProfilePage;
import com.pmease.gitplex.web.page.account.RegisterPage;
import com.pmease.gitplex.web.page.account.repository.NewRepositoryPage;
@@ -29,13 +30,28 @@ public abstract class LayoutPage extends BasePage {
super.onInitialize();
User currentUser = GitPlex.getInstance(UserManager.class).getCurrent();
- boolean signedIn = currentUser != null;
+ final boolean signedIn = currentUser != null;
add(new BookmarkablePageLink<Void>("homeLink", getApplication().getHomePage()));
add(new BookmarkablePageLink<Void>("loginLink", LoginPage.class).setVisible(!signedIn));
add(new BookmarkablePageLink<Void>("registerLink", RegisterPage.class).setVisible(!signedIn));
add(new BookmarkablePageLink<Void>("logoutLink", LogoutPage.class).setVisible(signedIn));
+ if (currentUser != null) {
+ add(new BookmarkablePageLink<Void>("notificationLink",
+ AccountNotificationsPage.class,
+ AccountNotificationsPage.paramsOf(currentUser)) {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(!getCurrentUser().getRequestNotifications().isEmpty());
+ }
+
+ });
+ } else {
+ add(new WebMarkupContainer("notificationLink").setVisible(false));
+ }
if (signedIn) {
add(new UserLink("userLink", new UserModel(currentUser)));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountNotificationsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountNotificationsPage.java
index b3981028da..269ebb3bf1 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountNotificationsPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountNotificationsPage.java
@@ -23,9 +23,13 @@ import com.pmease.commons.wicket.component.datatable.DefaultDataTable;
import com.pmease.commons.wicket.component.datatable.EntityDataProvider;
import com.pmease.commons.wicket.component.datatable.SelectionColumn;
import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.model.Branch;
+import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.PullRequestNotification;
import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.branch.BranchLink;
import com.pmease.gitplex.web.component.pullrequest.RequestLink;
+import com.pmease.gitplex.web.model.EntityModel;
import com.pmease.gitplex.web.util.DateUtils;
@SuppressWarnings("serial")
@@ -67,7 +71,7 @@ public class AccountNotificationsPage extends AccountPage {
Item<ICellPopulator<PullRequestNotification>> cellItem,
String componentId, IModel<PullRequestNotification> rowModel) {
PullRequestNotification notification = rowModel.getObject();
- cellItem.add(new RequestLink(componentId, notification.getRequest()) {
+ cellItem.add(new RequestLink(componentId, new EntityModel<PullRequest>(notification.getRequest())) {
@Override
protected void onComponentTag(ComponentTag tag) {
@@ -79,25 +83,60 @@ public class AccountNotificationsPage extends AccountPage {
}
});
- columns.add(new AbstractColumn<PullRequestNotification, String>(Model.of("Message"), "task") {
+ columns.add(new AbstractColumn<PullRequestNotification, String>(Model.of("To Branch")) {
+
+ @Override
+ public void populateItem(
+ Item<ICellPopulator<PullRequestNotification>> cellItem,
+ String componentId, IModel<PullRequestNotification> rowModel) {
+ PullRequest request = rowModel.getObject().getRequest();
+ cellItem.add(new BranchLink(componentId, new EntityModel<Branch>(request.getTarget())) {
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ tag.setName("a");
+ }
+
+ });
+ }
+
+ });
+ columns.add(new AbstractColumn<PullRequestNotification, String>(Model.of("From Branch")) {
+
+ @Override
+ public void populateItem(
+ Item<ICellPopulator<PullRequestNotification>> cellItem,
+ String componentId, IModel<PullRequestNotification> rowModel) {
+ PullRequest request = rowModel.getObject().getRequest();
+ if (request.getSource() != null) {
+ cellItem.add(new BranchLink(componentId, new EntityModel<Branch>(request.getSource())) {
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ tag.setName("a");
+ }
+
+ });
+ } else {
+ cellItem.add(new Label(componentId, request.getSourceFQN()));
+ }
+ }
+
+ });
+ columns.add(new AbstractColumn<PullRequestNotification, String>(Model.of("Task"), "task") {
@Override
public void populateItem(
Item<ICellPopulator<PullRequestNotification>> cellItem,
String componentId, IModel<PullRequestNotification> rowModel) {
PullRequestNotification notification = rowModel.getObject();
- if (notification.getTask() == PullRequestNotification.Task.INTEGRATE)
- cellItem.add(new Label(componentId, "Integration required"));
- else if (notification.getTask() == PullRequestNotification.Task.REVIEW)
- cellItem.add(new Label(componentId, "Review required"));
- else if (notification.getTask() == PullRequestNotification.Task.UPDATE)
- cellItem.add(new Label(componentId, "Update required"));
- else
- cellItem.add(new Label(componentId, "There are new comments/updates"));
+ cellItem.add(new Label(componentId, notification.getTask().toString()));
}
});
- columns.add(new AbstractColumn<PullRequestNotification, String>(Model.of("Date"), "date") {
+ columns.add(new AbstractColumn<PullRequestNotification, String>(Model.of("When"), "date") {
@Override
public void populateItem(
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java
index b7088d2cb7..cac198c7b2 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/RepoBranchesPage.java
@@ -49,10 +49,10 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;
import com.pmease.gitplex.core.manager.AuthorizationManager;
import com.pmease.gitplex.core.manager.BranchManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
-import com.pmease.gitplex.core.manager.PullRequestWatchManager;
+import com.pmease.gitplex.core.manager.BranchWatchManager;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.PullRequest;
-import com.pmease.gitplex.core.model.PullRequestWatch;
+import com.pmease.gitplex.core.model.BranchWatch;
import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.web.Constants;
import com.pmease.gitplex.web.component.branch.BranchChoiceProvider;
@@ -172,13 +172,13 @@ public class RepoBranchesPage extends RepositoryPage {
};
- private final IModel<Map<String, PullRequestWatch>> requestWatchesModel =
- new LoadableDetachableModel<Map<String, PullRequestWatch>>() {
+ private final IModel<Map<String, BranchWatch>> branchWatchesModel =
+ new LoadableDetachableModel<Map<String, BranchWatch>>() {
@Override
- protected Map<String, PullRequestWatch> load() {
- Map<String, PullRequestWatch> requestWatches = new HashMap<>();
- for (PullRequestWatch watch: GitPlex.getInstance(PullRequestWatchManager.class).findBy(
+ protected Map<String, BranchWatch> load() {
+ Map<String, BranchWatch> requestWatches = new HashMap<>();
+ for (BranchWatch watch: GitPlex.getInstance(BranchWatchManager.class).findBy(
Preconditions.checkNotNull(getCurrentUser()), getRepository()))
requestWatches.put(watch.getBranch().getName(), watch);
return requestWatches;
@@ -439,10 +439,10 @@ public class RepoBranchesPage extends RepositoryPage {
@Override
public void onClick(AjaxRequestTarget target) {
String branchName = item.getModelObject().getName();
- PullRequestWatch watch = requestWatchesModel.getObject().get(branchName);
+ BranchWatch watch = branchWatchesModel.getObject().get(branchName);
if (watch != null) {
GitPlex.getInstance(Dao.class).remove(watch);
- requestWatchesModel.getObject().remove(branchName);
+ branchWatchesModel.getObject().remove(branchName);
}
target.add(actionsContainer);
}
@@ -451,7 +451,7 @@ public class RepoBranchesPage extends RepositoryPage {
protected void onConfigure() {
super.onConfigure();
setVisible(getCurrentUser() != null
- && requestWatchesModel.getObject().containsKey(item.getModelObject().getName()));
+ && branchWatchesModel.getObject().containsKey(item.getModelObject().getName()));
}
});
@@ -459,7 +459,7 @@ public class RepoBranchesPage extends RepositoryPage {
@Override
public void onClick(AjaxRequestTarget target) {
- PullRequestWatch watch = new PullRequestWatch();
+ BranchWatch watch = new BranchWatch();
watch.setBranch(item.getModelObject());
watch.setUser(getCurrentUser());
GitPlex.getInstance(Dao.class).persist(watch);
@@ -470,7 +470,7 @@ public class RepoBranchesPage extends RepositoryPage {
protected void onConfigure() {
super.onConfigure();
setVisible(getCurrentUser() != null
- && !requestWatchesModel.getObject().containsKey(item.getModelObject().getName()));
+ && !branchWatchesModel.getObject().containsKey(item.getModelObject().getName()));
}
});
@@ -548,7 +548,7 @@ public class RepoBranchesPage extends RepositoryPage {
lastCommitsModel.detach();
aheadOpenRequestsModel.detach();
behindOpenRequestsModel.detach();
- requestWatchesModel.detach();
+ branchWatchesModel.detach();
aheadBehindsModel.detach();
aheadBehindWidthModel.detach();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java
index 00347d4c5f..6460847b42 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java
@@ -132,10 +132,10 @@ public class NewRequestPage extends RepositoryPage {
pullRequest.setSubmitter(currentUser);
PullRequestUpdate update = new PullRequestUpdate();
- pullRequest.getUpdates().add(update);
+ pullRequest.addUpdate(update);
update.setRequest(pullRequest);
update.setHeadCommitHash(source.getHeadCommitHash());
- pullRequest.setUpdateDate(new Date());
+ pullRequest.setLastEventDate(new Date());
PullRequestManager pullRequestManager = GitPlex.getInstance(PullRequestManager.class);
List<IntegrationStrategy> strategies = pullRequestManager.getApplicableIntegrationStrategies(pullRequest);
@@ -425,7 +425,7 @@ public class NewRequestPage extends RepositoryPage {
for (ReviewInvitation invitation: pullRequest.getReviewInvitations())
invitation.setReviewer(dao.load(User.class, invitation.getReviewer().getId()));
- pullRequest.setAssignee(pullRequest.getTarget().getRepository().getOwner());
+ pullRequest.setAssignee(dao.load(User.class, pullRequest.getAssignee().getId()));
GitPlex.getInstance(PullRequestManager.class).open(pullRequest, new PageId(getPageId()));
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.java
index f6865d165a..80ab2898ca 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
@@ -439,7 +439,7 @@ public class RequestComparePage extends RequestDetailPage {
comment.setContext(commentContext);
InheritableThreadLocalData.set(new PageId(getPageId()));
try {
- GitPlex.getInstance(PullRequestCommentManager.class).save(comment);
+ GitPlex.getInstance(PullRequestCommentManager.class).save(comment, true);
} finally {
InheritableThreadLocalData.clear();
}
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.java
index 9e6d532fe5..f704b774d4 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
@@ -5,10 +5,15 @@ import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERG
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.MERGE_WITH_SQUASH;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.REBASE_SOURCE_ONTO_TARGET;
import static com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy.REBASE_TARGET_ONTO_SOURCE;
-import static com.pmease.gitplex.core.model.PullRequestOperation.*;
+import static com.pmease.gitplex.core.model.PullRequestOperation.APPROVE;
+import static com.pmease.gitplex.core.model.PullRequestOperation.DISAPPROVE;
+import static com.pmease.gitplex.core.model.PullRequestOperation.DISCARD;
+import static com.pmease.gitplex.core.model.PullRequestOperation.INTEGRATE;
+import static com.pmease.gitplex.core.model.PullRequestOperation.REOPEN;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
@@ -75,8 +80,11 @@ import com.pmease.gitplex.core.model.PullRequest.Status;
import com.pmease.gitplex.core.model.PullRequestComment;
import com.pmease.gitplex.core.model.PullRequestCommentReply;
import com.pmease.gitplex.core.model.PullRequestOperation;
+import com.pmease.gitplex.core.model.PullRequestUpdate;
import com.pmease.gitplex.core.model.PullRequestVerification;
import com.pmease.gitplex.core.model.Review;
+import com.pmease.gitplex.core.model.ReviewInvitation;
+import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.web.component.branch.BranchLink;
import com.pmease.gitplex.web.event.PullRequestChanged;
import com.pmease.gitplex.web.model.EntityModel;
@@ -933,7 +941,7 @@ public abstract class RequestDetailPage extends RepositoryPage {
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass())
return false;
- final PullRequestChangeTrait other = (PullRequestChangeTrait) obj;
+ PullRequestChangeTrait other = (PullRequestChangeTrait) obj;
return Objects.equal(requestId, other.requestId);
}
@@ -953,39 +961,47 @@ public abstract class RequestDetailPage extends RepositoryPage {
}
@Override
- public void onUpdated(PullRequest request) {
- onChange(request);
+ public void onUpdated(PullRequestUpdate update) {
+ onChange(update.getRequest());
}
@Override
- public void onReviewed(Review review) {
+ public void onReviewed(Review review, String comment) {
onChange(review.getUpdate().getRequest());
}
@Override
- public void onIntegrated(PullRequest request) {
+ public void onIntegrated(PullRequest request, User user, String comment) {
onChange(request);
}
@Override
- public void onDiscarded(PullRequest request) {
+ public void onDiscarded(PullRequest request, User user, String comment) {
onChange(request);
}
- private void onChange(final PullRequest request) {
+ private void onChange(PullRequest request) {
/*
* Make sure that pull request and associated objects are committed before
* sending render request; otherwise rendering request may not reflect
* expected status as rendering happens in another thread which may get
* executed before pull request modification is committed.
*/
+ final PullRequestChangeTrait trait = new PullRequestChangeTrait();
+ trait.requestId = request.getId();
dao.afterCommit(new Runnable() {
@Override
public void run() {
- PullRequestChangeTrait trait = new PullRequestChangeTrait();
- trait.requestId = request.getId();
- WebSocketRenderBehavior.requestToRender(trait, PageId.fromObj(InheritableThreadLocalData.get()));
+ // Send web socket message in a thread in order not to blocking UI operations
+ GitPlex.getInstance(ExecutorService.class).execute(new Runnable() {
+
+ @Override
+ public void run() {
+ WebSocketRenderBehavior.requestToRender(trait, PageId.fromObj(InheritableThreadLocalData.get()));
+ }
+
+ });
}
});
@@ -1015,6 +1031,30 @@ public abstract class RequestDetailPage extends RepositoryPage {
public void onCommentReplied(PullRequestCommentReply reply) {
onChange(reply.getComment().getRequest());
}
+
+ @Override
+ public void onReopened(PullRequest request, User user, String comment) {
+ }
+
+ @Override
+ public void onMentioned(PullRequest request, User user, String content) {
+ }
+
+ @Override
+ public void onInvitingReview(ReviewInvitation invitation) {
+ }
+
+ @Override
+ public void pendingIntegration(PullRequest request) {
+ }
+
+ @Override
+ public void pendingUpdate(PullRequest request) {
+ }
+
+ @Override
+ public void pendingApproval(PullRequest request) {
+ }
}
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestListPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestListPanel.java
index 604aa4f35a..5348f82a49 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestListPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestListPanel.java
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import com.pmease.gitplex.core.GitPlex;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
@@ -34,10 +33,15 @@ import com.pmease.commons.wicket.behavior.dropdown.DropdownPanel;
import com.pmease.commons.wicket.behavior.menu.MenuBehavior;
import com.pmease.commons.wicket.behavior.menu.MenuItem;
import com.pmease.commons.wicket.behavior.menu.MenuPanel;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.branch.BranchLink;
+import com.pmease.gitplex.web.component.pullrequest.RequestLink;
import com.pmease.gitplex.web.component.user.UserSingleChoice;
+import com.pmease.gitplex.web.model.EntityModel;
import com.pmease.gitplex.web.page.repository.RepositoryPage;
@SuppressWarnings("serial")
@@ -240,12 +244,45 @@ public class RequestListPanel extends Panel {
});
List<IColumn<PullRequest, Void>> columns = new ArrayList<>();
- columns.add(new AbstractColumn<PullRequest, Void>(Model.of("Summary")) {
+ columns.add(new AbstractColumn<PullRequest, Void>(Model.of("Id")) {
+
+ @Override
+ public void populateItem(Item<ICellPopulator<PullRequest>> cellItem,
+ String componentId, IModel<PullRequest> rowModel) {
+ PullRequest request = rowModel.getObject();
+ cellItem.add(new Label(componentId, "#" + request.getId()));
+ cellItem.add(AttributeAppender.append("class", "narrow"));
+ }
+
+ });
+ columns.add(new AbstractColumn<PullRequest, Void>(Model.of("Title")) {
+
+ @Override
+ public void populateItem(Item<ICellPopulator<PullRequest>> cellItem,
+ String componentId, IModel<PullRequest> rowModel) {
+ cellItem.add(new RequestLink(componentId, rowModel));
+ }
+
+ });
+ columns.add(new AbstractColumn<PullRequest, Void>(Model.of("To Branch")) {
@Override
public void populateItem(Item<ICellPopulator<PullRequest>> cellItem,
String componentId, IModel<PullRequest> rowModel) {
- cellItem.add(new RequestSummaryPanel(componentId, rowModel));
+ cellItem.add(new BranchLink(componentId, new EntityModel<Branch>(rowModel.getObject().getTarget())));
+ }
+
+ });
+ columns.add(new AbstractColumn<PullRequest, Void>(Model.of("From Branch")) {
+
+ @Override
+ public void populateItem(Item<ICellPopulator<PullRequest>> cellItem,
+ String componentId, IModel<PullRequest> rowModel) {
+ PullRequest request = rowModel.getObject();
+ if (request.getSource() != null)
+ cellItem.add(new BranchLink(componentId, new EntityModel<Branch>(request.getSource())));
+ else
+ cellItem.add(new Label(componentId, request.getSourceFQN()));
}
});
@@ -282,16 +319,6 @@ public class RequestListPanel extends Panel {
cellItem.add(AttributeAppender.append("class", "narrow"));
}
- });
- columns.add(new AbstractColumn<PullRequest, Void>(Model.of("Id")) {
-
- @Override
- public void populateItem(Item<ICellPopulator<PullRequest>> cellItem,
- String componentId, IModel<PullRequest> rowModel) {
- cellItem.add(new Label(componentId, "#" + rowModel.getObject().getId()));
- cellItem.add(AttributeAppender.append("class", "narrow"));
- }
-
});
IDataProvider<PullRequest> dataProvider = new IDataProvider<PullRequest>() {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.html
index b0d3c9b348..e5143b399f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.html
@@ -4,7 +4,7 @@
<td class="activities">
<table>
<tr wicket:id="requestActivities" class="activity">
- <td wicket:id="avatar" class="avatar"></td>
+ <td wicket:id="avatar" class="avatar"><div wicket:id="avatar"></div></td>
<td wicket:id="activity" class="activity"></td>
</tr>
</table>
@@ -16,42 +16,54 @@
</div>
</td>
<td class="others">
- <div wicket:id="branches" class="branches well">
- <div class="target">
- <label>Target Branch:</label>
- <span wicket:id="target"></span>
+ <div class="well">
+ <div wicket:id="basicInfo" class="basic-info">
+ <div class="submitter">
+ <label>Submitted By: </label> <span wicket:id="submitter" class="avatar"></span>
+ </div>
+ <div class="target">
+ <label>To Branch:</label>
+ <span wicket:id="target"></span>
+ </div>
+ <div class="source">
+ <label>From Branch:</label>
+ <span wicket:id="sourceLink"></span>
+ <span wicket:id="sourceName"></span>
+ <a wicket:id="restoreSource"><span class="fa fa-undo"></span> Restore</a>
+ </div>
</div>
- <div class="source">
- <label>Source Branch:</label>
- <span wicket:id="sourceLink"></span>
- <span wicket:id="sourceName"></span>
- <a wicket:id="restoreSource"><span class="fa fa-undo"></span> Restore</a>
+ <div wicket:id="assignee" class="assignee"></div>
+ <div wicket:id="reviewers" class="reviewers">
+ <label>Reviewers:</label>
+ <ul class="clearfix list-unstyled">
+ <li wicket:id="reviewers" class="pull-left">
+ <span wicket:id="avatar"></span>
+ <span wicket:id="result"></span>
+ </li>
+ </ul>
+ <wicket:enclosure child="addReviewer">
+ <div>
+ <input wicket:id="addReviewer" type="hidden"></input>
+ </div>
+ </wicket:enclosure>
</div>
- </div>
- <div wicket:id="integrationStrategy" class="integration-strategy well">
- <label>
- Integration Strategy:
- <span wicket:id="help" class="pa pa-question-circle pointer"></span>
- </label>
- <div>
- <select wicket:id="editor"></select>
- <span wicket:id="viewer"></span>
+ <div wicket:id="integrationStrategy" class="integration-strategy">
+ <label>
+ Integration Strategy:
+ <span wicket:id="help" class="fa fa-question-circle pointer"></span>
+ </label>
+ <div>
+ <select wicket:id="editor"></select>
+ <span wicket:id="viewer"></span>
+ </div>
</div>
- </div>
- <div wicket:id="assignee" class="assignee well"></div>
- <div wicket:id="reviewers" class="reviewers well">
- <label>Reviewers:</label>
- <ul class="clearfix list-unstyled">
- <li wicket:id="reviewers" class="pull-left">
- <span wicket:id="avatar"></span>
- <span wicket:id="result"></span>
- </li>
- </ul>
- <wicket:enclosure child="addReviewer">
- <div>
- <input wicket:id="addReviewer" type="hidden"></input>
+ <div wicket:id="watch" class="watch">
+ <div>
+ <label>Watch Status:</label>
+ <select wicket:id="option"></select>
+ </div>
+ <div class="help-block"><i class="fa fa-info-circle"></i> <span wicket:id="help"></span></div>
</div>
- </wicket:enclosure>
</div>
</td>
</tr>
@@ -67,14 +79,14 @@
<div wicket:id="detail" class="detail"></div>
</wicket:fragment>
<wicket:fragment wicket:id="assigneeEditFrag">
- <label>Assigned To: <span wicket:id="help" class="pa pa-question-circle pointer"></span></label>
+ <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer"></span></label>
<div>
<input wicket:id="assignee" type="hidden"></input>
</div>
</wicket:fragment>
<wicket:fragment wicket:id="assigneeViewFrag">
- <label>Assigned To: <span wicket:id="help" class="pa pa-question-circle pointer"></span></label>
- <span wicket:id="assignee"></span>
+ <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer"></span></label>
+ <span wicket:id="assignee" class="avatar"></span>
</wicket:fragment>
<wicket:fragment wicket:id="noAssigneeFrag">
This pull request will be integrated automatically as long as it passes gate keeper check.
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.java
index 5a08905283..377f105da6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestOverviewPage.java
@@ -1,8 +1,10 @@
package com.pmease.gitplex.web.page.repository.pullrequest;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
import java.util.List;
import org.apache.shiro.SecurityUtils;
@@ -19,6 +21,7 @@ import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
@@ -50,6 +53,8 @@ import com.pmease.gitplex.core.model.PullRequest.IntegrationStrategy;
import com.pmease.gitplex.core.model.PullRequestActivity;
import com.pmease.gitplex.core.model.PullRequestComment;
import com.pmease.gitplex.core.model.PullRequestUpdate;
+import com.pmease.gitplex.core.model.PullRequestVisit;
+import com.pmease.gitplex.core.model.PullRequestWatch;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.Review;
import com.pmease.gitplex.core.model.ReviewInvitation;
@@ -87,9 +92,28 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig
@SuppressWarnings("serial")
public class RequestOverviewPage extends RequestDetailPage {
- private static final String ASSIGNEE_HELP = "Assignee is resonsible for integrating "
- + "the pull request into target branch after it passes gate keeper check.";
-
+ private static final String ASSIGNEE_HELP = "Assignee has write permission to the "
+ + "repository and is resonsible for integrating the pull request into "
+ + "target branch after it passes gate keeper check.";
+
+ private enum WatchStatus {
+ WATCHING("Watching"),
+ NOT_WATCHING("Not Watching"),
+ IGNORE("Ignore");
+
+ private final String displayName;
+
+ WatchStatus(String displayName) {
+ this.displayName = displayName;
+ }
+
+ @Override
+ public String toString() {
+ return displayName;
+ }
+
+ };
+
private RepeatingView activitiesView;
public RequestOverviewPage(PageParameters params) {
@@ -153,7 +177,9 @@ public class RequestOverviewPage extends RequestDetailPage {
row.setOutputMarkupId(true);
- row.add(new UserLink("avatar", new UserModel(activity.getUser()), AvatarMode.AVATAR));
+ WebMarkupContainer avatarColumn = new WebMarkupContainer("avatar");
+ avatarColumn.add(new UserLink("avatar", new UserModel(activity.getUser()), AvatarMode.AVATAR));
+ row.add(avatarColumn);
if (row.get("activity") == null)
row.add(activity.render("activity"));
@@ -165,6 +191,9 @@ public class RequestOverviewPage extends RequestDetailPage {
else
row.add(AttributeAppender.append("class", " non-discussion non-update"));
+ PullRequestManager pullRequestManager = GitPlex.getInstance(PullRequestManager.class);
+ final Date lastVisitDate = pullRequestManager.getLastVisitDate(getPullRequest());
+
row.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {
@Override
@@ -178,11 +207,16 @@ public class RequestOverviewPage extends RequestDetailPage {
if (commentActivity.getComment().isResolved())
cssClasses += " resolved";
}
+ if (lastVisitDate != null && lastVisitDate.before(activity.getDate()))
+ cssClasses += " new";
return cssClasses;
}
}));
+ if (lastVisitDate != null && lastVisitDate.before(activity.getDate()))
+ avatarColumn.add(AttributeAppender.append("title", "New activity since your last visit"));
+
return row;
}
@@ -236,7 +270,32 @@ public class RequestOverviewPage extends RequestDetailPage {
}
private Component newActivitiesView() {
- activitiesView = new RepeatingView("requestActivities");
+ activitiesView = new RepeatingView("requestActivities") {
+
+ @Override
+ protected void onDetach() {
+ /*
+ * Put the visit save logic here instead of page wide as the page.onDetach
+ * can be called sometimes before the page has not been rendered.
+ */
+ User user = getCurrentUser();
+ if (user != null) {
+ PullRequestVisit visit = getPullRequest().getVisit(user);
+ if (visit == null) {
+ visit = new PullRequestVisit();
+ visit.setRequest(getPullRequest());
+ visit.setUser(user);
+ getPullRequest().getVisits().add(visit);
+ } else {
+ visit.setDate(new Date());
+ }
+ GitPlex.getInstance(Dao.class).persist(visit);
+ }
+
+ super.onDetach();
+ }
+
+ };
activitiesView.setOutputMarkupId(true);
List<RenderableActivity> activities = getActivities();
@@ -316,7 +375,7 @@ public class RequestOverviewPage extends RequestDetailPage {
comment.setContent(input.getModelObject());
InheritableThreadLocalData.set(new PageId(getPage().getPageId()));
try {
- GitPlex.getInstance(PullRequestCommentManager.class).save(comment);
+ GitPlex.getInstance(PullRequestCommentManager.class).save(comment, true);
} finally {
InheritableThreadLocalData.clear();
}
@@ -342,17 +401,20 @@ public class RequestOverviewPage extends RequestDetailPage {
}.add(new AllowLeaveBehavior()));
- add(newBranchesContainer());
+ add(newBasicInfoContainer());
add(newIntegrationStrategyContainer());
add(newAssigneeContainer());
add(newReviewersContainer());
+ add(newWatchContainer());
}
- private WebMarkupContainer newBranchesContainer() {
- WebMarkupContainer branchesContainer = new WebMarkupContainer("branches");
+ private WebMarkupContainer newBasicInfoContainer() {
PullRequest request = getPullRequest();
- branchesContainer.add(new BranchLink("target", new EntityModel<Branch>(request.getTarget())));
- branchesContainer.add(new BranchLink("sourceLink", new AbstractReadOnlyModel<Branch>() {
+ WebMarkupContainer basicInfoContainer = new WebMarkupContainer("basicInfo");
+ basicInfoContainer.add(new AvatarByUser("submitter", new UserModel(request.getSubmitter()), true));
+
+ basicInfoContainer.add(new BranchLink("target", new EntityModel<Branch>(request.getTarget())));
+ basicInfoContainer.add(new BranchLink("sourceLink", new AbstractReadOnlyModel<Branch>() {
@Override
public Branch getObject() {
@@ -368,7 +430,7 @@ public class RequestOverviewPage extends RequestDetailPage {
}
});
- branchesContainer.add(new Label("sourceName", new LoadableDetachableModel<String>() {
+ basicInfoContainer.add(new Label("sourceName", new LoadableDetachableModel<String>() {
@Override
protected String load() {
@@ -391,7 +453,7 @@ public class RequestOverviewPage extends RequestDetailPage {
});
- branchesContainer.add(new Link<Void>("restoreSource") {
+ basicInfoContainer.add(new Link<Void>("restoreSource") {
@Override
protected void onConfigure() {
@@ -426,7 +488,7 @@ public class RequestOverviewPage extends RequestDetailPage {
});
- return branchesContainer;
+ return basicInfoContainer;
}
private WebMarkupContainer newIntegrationStrategyContainer() {
@@ -524,9 +586,120 @@ public class RequestOverviewPage extends RequestDetailPage {
return integrationStrategyContainer;
}
+ private WebMarkupContainer newWatchContainer() {
+ final WebMarkupContainer watchContainer = new WebMarkupContainer("watch") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(getCurrentUser() != null);
+ }
+
+ };
+
+ watchContainer.setOutputMarkupId(true);
+
+ final IModel<WatchStatus> optionModel = new LoadableDetachableModel<WatchStatus>() {
+
+ @Override
+ protected WatchStatus load() {
+ PullRequestWatch watch = getPullRequest().getWatch(getCurrentUser());
+ if (watch != null) {
+ if (watch.isIgnore())
+ return WatchStatus.IGNORE;
+ else
+ return WatchStatus.WATCHING;
+ } else {
+ return WatchStatus.NOT_WATCHING;
+ }
+ }
+
+ };
+
+ List<WatchStatus> options = Arrays.asList(WatchStatus.values());
+
+ IChoiceRenderer<WatchStatus> choiceRenderer = new IChoiceRenderer<WatchStatus>() {
+
+ @Override
+ public Object getDisplayValue(WatchStatus object) {
+ return object.toString();
+ }
+
+ @Override
+ public String getIdValue(WatchStatus object, int index) {
+ return String.valueOf(index);
+ }
+
+ };
+ DropDownChoice<WatchStatus> choice = new DropDownChoice<>("option", optionModel,
+ options, choiceRenderer);
+
+ choice.add(new OnChangeAjaxBehavior() {
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ PullRequestWatch watch = getPullRequest().getWatch(getCurrentUser());
+ Dao dao = GitPlex.getInstance(Dao.class);
+ if (optionModel.getObject() == WatchStatus.WATCHING) {
+ if (watch != null) {
+ watch.setIgnore(false);
+ watch.setReason(null);
+ } else {
+ watch = new PullRequestWatch();
+ watch.setRequest(getPullRequest());
+ watch.setUser(getCurrentUser());
+ getPullRequest().getWatches().add(watch);
+ }
+ dao.persist(watch);
+ } else if (optionModel.getObject() == WatchStatus.NOT_WATCHING) {
+ if (watch != null) {
+ dao.remove(watch);
+ getPullRequest().getWatches().remove(watch);
+ }
+ } else {
+ if (watch != null) {
+ watch.setIgnore(true);
+ } else {
+ watch = new PullRequestWatch();
+ watch.setRequest(getPullRequest());
+ watch.setUser(getCurrentUser());
+ watch.setIgnore(true);
+ getPullRequest().getWatches().add(watch);
+ }
+ dao.persist(watch);
+ }
+ target.add(watchContainer);
+ }
+
+ });
+ watchContainer.add(choice);
+ watchContainer.add(new Label("help", new LoadableDetachableModel<String>() {
+
+ @Override
+ protected String load() {
+ PullRequestWatch watch = getPullRequest().getWatch(getCurrentUser());
+ if (watch != null) {
+ if (watch.isIgnore()) {
+ return "Ignore notifications irrelevant to me.";
+ } else if (watch.getReason() != null) {
+ return watch.getReason();
+ } else {
+ return "You will be notified of any activities.";
+ }
+ } else {
+ return "Ignore notifications irrelevant to me, but start to watch once I am involved.";
+ }
+ }
+
+ }));
+
+ return watchContainer;
+ }
+
private Component newAssigneeContainer() {
- Fragment assigneeContainer;
PullRequest request = getPullRequest();
+
+ Fragment assigneeContainer;
User assignee = request.getAssignee();
boolean canChangeAssignee = request.isOpen()
&& (request.getSubmitter().equals(getCurrentUser())
@@ -643,5 +816,5 @@ public class RequestOverviewPage extends RequestDetailPage {
return reviewersContainer;
}
-
+
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestSummaryPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestSummaryPanel.java
index 69f3ac4c22..c871e685a4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestSummaryPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestSummaryPanel.java
@@ -4,11 +4,12 @@ import java.util.Date;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
-import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.PullRequest;
@@ -28,14 +29,15 @@ public class RequestSummaryPanel extends Panel {
protected void onInitialize() {
super.onInitialize();
- Link<Void> titleLink = new Link<Void>("titleLink") {
+ BookmarkablePageLink<Void> titleLink = new BookmarkablePageLink<Void>("titleLink", RequestOverviewPage.class) {
- @Override
- public void onClick() {
- setResponsePage(RequestOverviewPage.class, RequestOverviewPage.paramsOf(getPullRequest()));
- }
+ @Override
+ public PageParameters getPageParameters() {
+ return RequestOverviewPage.paramsOf(getPullRequest());
+ }
};
+
add(titleLink);
titleLink.add(new Label("titleLabel", new AbstractReadOnlyModel<String>() {
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.java
index 968fba591b..7439722582 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
@@ -147,10 +147,10 @@ public class RequestUpdatesPage extends RequestDetailPage {
for (Commit commit: update.getRequest().getMergedCommits())
mergedCommitHashes.add(commit.getHash());
- updateItem.add(new ListView<Commit>("commits", new AbstractReadOnlyModel<List<Commit>>() {
+ updateItem.add(new ListView<Commit>("commits", new LoadableDetachableModel<List<Commit>>() {
@Override
- public List<Commit> getObject() {
+ protected List<Commit> load() {
return updateItem.getModelObject().getCommits();
}
diff --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.java
index 4882f9ce33..9eddc145fa 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,11 +13,8 @@ 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 {
@@ -34,14 +31,7 @@ public class CommentActivityPanel extends Panel {
protected void onInitialize() {
super.onInitialize();
- add(new CommentPanel("content", commentModel, new ModelWrapper<CommentReply>() {
-
- @Override
- public IModel<PullRequestCommentReply> asModel(CommentReply object) {
- return new EntityModel<PullRequestCommentReply>((PullRequestCommentReply) object);
- }
-
- }) {
+ add(new CommentPanel("content", commentModel) {
@Override
protected Component newAdditionalCommentActions(String id, final IModel<Comment> commentModel) {
@@ -87,7 +77,7 @@ public class CommentActivityPanel extends Panel {
}
@Override
- protected Component newAdditionalReplyActions(String id, final IModel<CommentReply> replyModel) {
+ protected Component newAdditionalReplyActions(String id, CommentReply reply) {
return new SinceChangesLink(id, new AbstractReadOnlyModel<PullRequest>() {
@Override
@@ -95,15 +85,7 @@ public class CommentActivityPanel extends Panel {
return commentModel.getObject().getRequest();
}
- }, replyModel.getObject().getDate(), "Changes since this reply") {
-
- @Override
- protected void onDetach() {
- replyModel.detach();
- super.onDetach();
- }
-
- };
+ }, reply.getDate(), "Changes since this reply");
}
});
diff --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.java
index 2967f4404e..c0bf9fd563 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
@@ -28,18 +28,14 @@ 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.PullRequestCommentManager;
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.component.label.AgeLabel;
import com.pmease.gitplex.web.component.user.AvatarMode;
import com.pmease.gitplex.web.component.user.UserLink;
import com.pmease.gitplex.web.event.PullRequestChanged;
-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;
@@ -210,14 +206,7 @@ public class InlineCommentActivityPanel extends Panel {
* 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<PullRequestCommentReply> asModel(CommentReply object) {
- return new EntityModel<PullRequestCommentReply>((PullRequestCommentReply) object);
- }
-
- }) {
+ add(new CommentPanel("comment", commentModel) {
@Override
protected Component newAdditionalCommentActions(String id, IModel<Comment> comment) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.html
index 50b6fa5f6f..7285fea6f3 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdateActivityPanel.html
@@ -2,9 +2,7 @@
<div class="commits">
<table>
<tr wicket:id="commits">
- <td class="icon">
- <i class="pa pa-commit"></i>
- </td>
+ <td class="icon"><i class="pa pa-commit"></i></td>
<td class="detail">
<span wicket:id="author"></span>
<span wicket:id="message"></span>