Skip to content

The Unified and Autonomous Development Platform

comment draft

robin shine1099675a86f9
diff --git a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java
index fa8659330a..3fc7aa3bab 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java
@@ -1,10 +1,39 @@
package com.pmease.commons.git;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jgit.lib.FileMode;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+
public class GitUtils {
- public static String getTypeName(int blobType) {
+ public static final String NULL_SHA1 = StringUtils.repeat("0", 40);
+
+ public static final Pattern PATTERN_HASH = Pattern.compile("[a-z0-9]{40}");
+
+ public static final int SHORT_SHA_LENGTH = 10;
+
+ public static boolean isHash(String sha) {
+ return PATTERN_HASH.matcher(sha).matches();
+ }
+
+ public static boolean isNullHash(String sha) {
+ return Objects.equal(NULL_SHA1, sha);
+ }
+
+ public static String abbreviateSHA(String sha, int length) {
+ Preconditions.checkArgument(isHash(sha));
+ return sha.substring(0, length);
+ }
+
+ public static String abbreviateSHA(String sha) {
+ return abbreviateSHA(sha, SHORT_SHA_LENGTH);
+ }
+
+ public static String getBlobTypeName(int blobType) {
if (blobType == FileMode.TYPE_FILE)
return "File";
else if (blobType == FileMode.TYPE_GITLINK)
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/AuthorizationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/AuthorizationManager.java
index e4db86a7a7..993da234f7 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/AuthorizationManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/AuthorizationManager.java
@@ -4,6 +4,7 @@ import java.util.Collection;
import com.google.inject.ImplementedBy;
import com.pmease.gitplex.core.manager.impl.DefaultAuthorizationManager;
+import com.pmease.gitplex.core.model.CommitComment;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -19,4 +20,5 @@ public interface AuthorizationManager {
boolean canModify(Vote vote);
+ boolean canModify(CommitComment comment);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommitCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommitCommentManager.java
index 335b59b32d..396f663346 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommitCommentManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommitCommentManager.java
@@ -1,14 +1,50 @@
package com.pmease.gitplex.core.manager;
-import java.util.Map;
+import java.util.List;
import com.google.inject.ImplementedBy;
import com.pmease.gitplex.core.manager.impl.DefaultCommitCommentManager;
+import com.pmease.gitplex.core.model.CommitComment;
import com.pmease.gitplex.core.model.Repository;
@ImplementedBy(DefaultCommitCommentManager.class)
public interface CommitCommentManager {
- Map<String, Integer> getCommitCommentStats(Repository repository);
+ /**
+ * Find comments by commit.
+ *
+ * @param repository
+ * repository to find comment inside
+ * @param commit
+ * commit to find comment for
+ * @return
+ * list of comments ordered by id
+ */
+ List<CommitComment> findByCommit(Repository repository, String commit);
+
+ /**
+ * Find comments by file.
+ *
+ * @param repository
+ * repository to find comment inside
+ * @param commit
+ * file to find comment for
+ * @return
+ * list of comments ordered by id
+ */
+ List<CommitComment> findByFile(Repository repository, String file);
+ /**
+ * Find comments by commit and file.
+ *
+ * @param repository
+ * repository to find comment inside
+ * @param commit
+ * commit to find comment for
+ * @param file
+ * file to find comment for
+ * @return
+ * list of comments ordered by id
+ */
+ List<CommitComment> findByCommitAndFile(Repository repository, String commit, String file);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/OldCommitCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/OldCommitCommentManager.java
new file mode 100644
index 0000000000..13810e8b63
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/OldCommitCommentManager.java
@@ -0,0 +1,14 @@
+package com.pmease.gitplex.core.manager;
+
+import java.util.Map;
+
+import com.google.inject.ImplementedBy;
+import com.pmease.gitplex.core.manager.impl.DefaultOldCommitCommentManager;
+import com.pmease.gitplex.core.model.Repository;
+
+@ImplementedBy(DefaultOldCommitCommentManager.class)
+public interface OldCommitCommentManager {
+
+ Map<String, Integer> getCommitCommentStats(Repository repository);
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuthorizationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuthorizationManager.java
index 8df48d9842..262c0c4ae5 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuthorizationManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAuthorizationManager.java
@@ -11,8 +11,10 @@ import org.apache.shiro.SecurityUtils;
import com.pmease.commons.hibernate.dao.EntityCriteria;
import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.manager.AuthorizationManager;
import com.pmease.gitplex.core.manager.UserManager;
+import com.pmease.gitplex.core.model.CommitComment;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -64,4 +66,19 @@ public class DefaultAuthorizationManager implements AuthorizationManager {
}
}
+ @Override
+ public boolean canModify(CommitComment comment) {
+ User currentUser = GitPlex.getInstance(UserManager.class).getCurrent();
+ if (currentUser == null) {
+ return false;
+ } else {
+ if (currentUser.equals(comment.getUser())) {
+ return true;
+ } else {
+ ObjectPermission adminPermission = ObjectPermission.ofRepositoryAdmin(comment.getRepository());
+ return SecurityUtils.getSubject().isPermitted(adminPermission);
+ }
+ }
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommitCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommitCommentManager.java
index d6b2e14440..6710543202 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommitCommentManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommitCommentManager.java
@@ -1,16 +1,18 @@
package com.pmease.gitplex.core.manager.impl;
import java.util.List;
-import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.hibernate.Query;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
-import com.google.common.collect.Maps;
+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.CommitCommentManager;
+import com.pmease.gitplex.core.model.CommitComment;
import com.pmease.gitplex.core.model.Repository;
@Singleton
@@ -23,22 +25,32 @@ public class DefaultCommitCommentManager implements CommitCommentManager {
this.dao = dao;
}
- @SuppressWarnings("unchecked")
+ @Sessional
@Override
- public Map<String, Integer> getCommitCommentStats(Repository repository) {
- String sql = "SELECT c.commit, count(c.id) from OldCommitComment c "
- + "WHERE repository=:repository "
- + "GROUP BY c.commit";
-
- Query query = dao.getSession().createQuery(sql);
- query.setParameter("repository", repository);
- List<Object[]> list = query.list();
-
- Map<String, Integer> map = Maps.newHashMap();
- for (Object[] each : list) {
- map.put((String) each[0], ((Long) each[1]).intValue());
- }
-
- return map;
+ public List<CommitComment> findByFile(Repository repository, String file) {
+ return dao.query(EntityCriteria.of(CommitComment.class)
+ .add(Restrictions.eq("repository", repository))
+ .add(Restrictions.eq("file", file))
+ .addOrder(Order.asc("id")), 0, 0);
}
+
+ @Sessional
+ @Override
+ public List<CommitComment> findByCommit(Repository repository, String commit) {
+ return dao.query(EntityCriteria.of(CommitComment.class)
+ .add(Restrictions.eq("repository", repository))
+ .add(Restrictions.eq("commit", commit))
+ .addOrder(Order.asc("id")), 0, 0);
+ }
+
+ @Override
+ public List<CommitComment> findByCommitAndFile(Repository repository,
+ String commit, String file) {
+ return dao.query(EntityCriteria.of(CommitComment.class)
+ .add(Restrictions.eq("repository", repository))
+ .add(Restrictions.eq("commit", commit))
+ .add(Restrictions.eq("file", file))
+ .addOrder(Order.asc("id")), 0, 0);
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultOldCommitCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultOldCommitCommentManager.java
new file mode 100644
index 0000000000..0a3d00c34b
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultOldCommitCommentManager.java
@@ -0,0 +1,44 @@
+package com.pmease.gitplex.core.manager.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.hibernate.Query;
+
+import com.google.common.collect.Maps;
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.gitplex.core.manager.OldCommitCommentManager;
+import com.pmease.gitplex.core.model.Repository;
+
+@Singleton
+public class DefaultOldCommitCommentManager implements OldCommitCommentManager {
+
+ private final Dao dao;
+
+ @Inject
+ public DefaultOldCommitCommentManager(Dao dao) {
+ this.dao = dao;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Map<String, Integer> getCommitCommentStats(Repository repository) {
+ String sql = "SELECT c.commit, count(c.id) from OldCommitComment c "
+ + "WHERE repository=:repository "
+ + "GROUP BY c.commit";
+
+ Query query = dao.getSession().createQuery(sql);
+ query.setParameter("repository", repository);
+ List<Object[]> list = query.list();
+
+ Map<String, Integer> map = Maps.newHashMap();
+ for (Object[] each : list) {
+ map.put((String) each[0], ((Long) each[1]).intValue());
+ }
+
+ return map;
+ }
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitComment.java
index 6d7bb4e86c..e44b39587b 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitComment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitComment.java
@@ -13,6 +13,10 @@ import com.pmease.commons.hibernate.AbstractEntity;
@Entity
public class CommitComment extends AbstractEntity {
+ @ManyToOne
+ @JoinColumn(nullable=false)
+ private Repository repository;
+
@Column(nullable=false)
private String commit;
@@ -26,10 +30,18 @@ public class CommitComment extends AbstractEntity {
@Column(nullable=false)
private String content;
- private String filePath;
+ private String file;
- private Integer lineNo;
+ private Integer line;
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+
public User getUser() {
return user;
}
@@ -62,20 +74,20 @@ public class CommitComment extends AbstractEntity {
this.commit = commit;
}
- public String getFilePath() {
- return filePath;
+ public String getFile() {
+ return file;
}
- public void setFilePath(String filePath) {
- this.filePath = filePath;
+ public void setFile(String file) {
+ this.file = file;
}
- public Integer getLineNo() {
- return lineNo;
+ public Integer getLine() {
+ return line;
}
- public void setLineNo(Integer lineNo) {
- this.lineNo = lineNo;
+ public void setLine(Integer line) {
+ this.line = line;
}
}
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 dfb251ba39..a8d45f5f04 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
@@ -78,7 +78,10 @@ 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", cascade=CascadeType.REMOVE)
+ private Collection<CommitComment> commitComments = new ArrayList<>();
+
+ @OneToMany(mappedBy="repository", cascade=CascadeType.REMOVE)
private Collection<Branch> branches = new ArrayList<>();
@OneToMany(mappedBy="forkedFrom", cascade=CascadeType.REMOVE)
@@ -163,7 +166,15 @@ public class Repository extends AbstractEntity implements UserBelonging {
this.authorizations = authorizations;
}
- public Repository getForkedFrom() {
+ public Collection<CommitComment> getCommitComments() {
+ return commitComments;
+ }
+
+ public void setCommitComments(Collection<CommitComment> commitComments) {
+ this.commitComments = commitComments;
+ }
+
+ public Repository getForkedFrom() {
return 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 6ae467ff69..f703192969 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
@@ -39,6 +39,9 @@ public class User extends AbstractUser implements ProtectedObject {
private Date avatarUpdateDate;
+ @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
+ private Collection<CommitComment> commitComments = new ArrayList<CommitComment>();
+
@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
private Collection<Membership> memberships = new ArrayList<Membership>();
@@ -115,6 +118,14 @@ public class User extends AbstractUser implements ProtectedObject {
this.avatarUpdateDate = avatarUpdateDate;
}
+ public Collection<CommitComment> getCommitComments() {
+ return commitComments;
+ }
+
+ public void setCommitComments(Collection<CommitComment> commitComments) {
+ this.commitComments = commitComments;
+ }
+
public Collection<Membership> getMemberships() {
return memberships;
}
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 a10f91d8e1..31697f3481 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
@@ -140,11 +140,11 @@ public class BlobDiffPanel extends Panel {
break;
}
if (textConverter != null) {
- GitText originalText = new GitText(textConverter.convert(oldContent),
+ GitText oldText = new GitText(textConverter.convert(oldContent),
true, Charsets.UTF_8.name());
- GitText revisedText = new GitText(textConverter.convert(newContent),
+ GitText newText = new GitText(textConverter.convert(newContent),
true, Charsets.UTF_8.name());
- diffPanel = new TextDiffPanel("blobContent", diffInfo, originalText, revisedText);
+ diffPanel = new TextDiffPanel("blobContent", repoModel, diffInfo, oldText, newText);
}
}
if (diffPanel == null) {
@@ -157,7 +157,7 @@ public class BlobDiffPanel extends Panel {
GitText newText = GitText.from(newContent);
if (newText != null) {
GitText oldText = new GitText(new ArrayList<String>(), true, newText.getCharset());
- diffPanel = new TextDiffPanel("blobContent", diffInfo, oldText, newText);
+ diffPanel = new TextDiffPanel("blobContent", repoModel, diffInfo, oldText, newText);
} else {
Fragment fragment = new Fragment("blobContent", "binaryFileFrag", this);
fragment.add(new FileDiffTitle("summary", diffInfo));
@@ -169,7 +169,7 @@ public class BlobDiffPanel extends Panel {
GitText oldText = GitText.from(oldContent);
if (oldText != null) {
GitText newText = new GitText(new ArrayList<String>(), true, oldText.getCharset());
- diffPanel = new TextDiffPanel("blobContent", diffInfo, oldText, newText);
+ diffPanel = new TextDiffPanel("blobContent", repoModel, diffInfo, oldText, newText);
} else {
Fragment fragment = new Fragment("blobContent", "binaryFileFrag", this);
fragment.add(new FileDiffTitle("summary", diffInfo));
@@ -179,7 +179,7 @@ public class BlobDiffPanel extends Panel {
GitText oldText = GitText.from(oldContent);
GitText newText = GitText.from(newContent);
if (oldText != null && newText != null) {
- diffPanel = new TextDiffPanel("blobContent", diffInfo, oldText, newText);
+ diffPanel = new TextDiffPanel("blobContent", repoModel, diffInfo, oldText, newText);
} else {
Fragment fragment = new Fragment("blobContent", "binaryFileFrag", this);
fragment.add(new FileDiffTitle("summary", diffInfo));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/HunkHeader.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/HunkHeader.java
deleted file mode 100644
index 00574b76a5..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/HunkHeader.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.pmease.gitplex.web.component.diff;
-
-import java.io.Serializable;
-
-@SuppressWarnings("serial")
-class HunkHeader implements Serializable {
-
- private int oldStart, oldEnd, newStart, newEnd;
-
- public HunkHeader(int oldStart, int oldEnd, int newStart, int newEnd) {
- this.oldStart = oldStart;
- this.oldEnd = oldEnd;
- this.newStart = newStart;
- this.newEnd = newEnd;
- }
-
- public int getOldStart() {
- return oldStart;
- }
-
- public int getOldEnd() {
- return oldEnd;
- }
-
- public int getNewStart() {
- return newStart;
- }
-
- public int getNewEnd() {
- return newEnd;
- }
-
- public void setOldStart(int oldStart) {
- this.oldStart = oldStart;
- }
-
- public void setOldEnd(int oldEnd) {
- this.oldEnd = oldEnd;
- }
-
- public void setNewStart(int newStart) {
- this.newStart = newStart;
- }
-
- public void setNewEnd(int newEnd) {
- this.newEnd = newEnd;
- }
-
- @Override
- public String toString() {
- int oldStart = this.oldStart;
- int newStart = this.newStart;
- int oldCount = oldEnd - oldStart;
- int newCount = newEnd - newStart;
-
- if (oldCount == 0)
- oldStart = 0;
- else
- oldStart++;
- if (newCount == 0)
- newStart = 0;
- else
- newStart++;
- return "@@ -" + oldStart + "," + oldCount + " +" + newStart + "," + newCount + " @@";
- }
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/HunkLine.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/HunkLine.java
deleted file mode 100644
index 75b00bc6cd..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/HunkLine.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.pmease.gitplex.web.component.diff;
-
-import java.io.Serializable;
-
-import com.pmease.commons.util.diff.DiffLine;
-
-@SuppressWarnings("serial")
-class HunkLine implements Serializable {
-
- private int originalLineNo;
-
- private int revisedLineNo;
-
- private DiffLine diffLine;
-
- public HunkLine(int originalLineNo, int revisedLineNo, DiffLine diffLine) {
- this.originalLineNo = originalLineNo;
- this.revisedLineNo = revisedLineNo;
- this.diffLine = diffLine;
- }
-
- public int getOriginalLineNo() {
- return originalLineNo;
- }
-
- public int getRevisedLineNo() {
- return revisedLineNo;
- }
-
- public DiffLine getDiffLine() {
- return diffLine;
- }
-
- public void setOriginalLineNo(int originalLineNo) {
- this.originalLineNo = originalLineNo;
- }
-
- public void setRevisedLineNo(int revisedLineNo) {
- this.revisedLineNo = revisedLineNo;
- }
-
- public void setDiffLine(DiffLine diffLine) {
- this.diffLine = diffLine;
- }
-
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
index b2f1934683..39817a1329 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
@@ -23,7 +23,7 @@
</div>
<table class="table-diff">
<wicket:container wicket:id="lines">
- <tr wicket:id="content" class="line content">
+ <tr wicket:id="contentRow" class="line content">
<td class="old line-no">
<a wicket:id="addComment" class="add-comment"><i class="fa fa-comment-add"></i></a>
<span wicket:id="oldLineNo"></span>
@@ -33,8 +33,51 @@
</td>
<td class="text"><wicket:container wicket:id="partials"><span wicket:id="partial"></span></wicket:container></td>
</tr>
- <tr wicket:id="comments" class="line comments"></tr>
+ <tr wicket:id="commentsRow" class="line comments">
+ <div wicket:id="comments">
+ <div wicket:id="comment"></div>
+ </div>
+ <div wicket:id="newComment"></div>
+ </tr>
</wicket:container>
</table>
</div>
+ <wicket:fragment wicket:id="viewCommentFrag">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <div wicket:id="name" class="pull-left"></div>
+ <div wicket:id="age" class="pull-right"></div>
+ <div class="actions pull-right">
+ <a wicket:id="edit"><i class="fa fa-pencil"></i></a>
+ <a wicket:id="delete"><i class="fa fa-times"></i></a>
+ </div>
+ </div>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="editCommentFrag">
+ <form wicket:id="form">
+ <div wicket:id="input"></div>
+ <div class="submits">
+ <div class="pull-left">
+ <button wicket:id="cancel" class="btn btn-sm btn-default">Close form</button>
+ </div>
+ <div class="pull-right">
+ <button wicket:id="save" class="btn btn-sm btn-primary">Update comment</button>
+ </div>
+ </div>
+ </form>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="newCommentFrag">
+ <form wicket:id="form">
+ <div wicket:id="input"></div>
+ <div class="submits">
+ <div class="pull-left">
+ <button wicket:id="cancel" class="btn btn-sm btn-default">Close form</button>
+ </div>
+ <div class="pull-right">
+ <button wicket:id="save" class="btn btn-sm btn-primary">Comment on this line</button>
+ </div>
+ </div>
+ </form>
+ </wicket:fragment>
</wicket:panel>
\ No newline at end of file
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 d5e45b265f..c82d4bad7b 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
@@ -1,30 +1,57 @@
package com.pmease.gitplex.web.component.diff;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.apache.shiro.SecurityUtils;
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.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
import com.pmease.commons.git.GitText;
+import com.pmease.commons.git.GitUtils;
+import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.util.diff.DiffLine;
import com.pmease.commons.util.diff.DiffUtils;
import com.pmease.commons.util.diff.Partial;
import com.pmease.commons.util.diff.WordSplitter;
+import com.pmease.commons.wicket.behavior.ConfirmBehavior;
import com.pmease.commons.wicket.behavior.ScrollBehavior;
import com.pmease.commons.wicket.behavior.StickyBehavior;
import com.pmease.commons.wicket.behavior.menu.CheckMenuItem;
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.manager.AuthorizationManager;
+import com.pmease.gitplex.core.manager.CommitCommentManager;
+import com.pmease.gitplex.core.manager.UserManager;
+import com.pmease.gitplex.core.model.CommitComment;
+import com.pmease.gitplex.core.model.Repository;
+import com.pmease.gitplex.core.model.User;
+import com.pmease.gitplex.core.permission.ObjectPermission;
+import com.pmease.gitplex.web.component.comment.CommentInput;
+import com.pmease.gitplex.web.component.label.AgeLabel;
+import com.pmease.gitplex.web.component.user.AvatarMode;
+import com.pmease.gitplex.web.component.user.UserLink;
+import com.pmease.gitplex.web.model.UserModel;
@SuppressWarnings("serial")
public class TextDiffPanel extends Panel {
@@ -33,12 +60,18 @@ public class TextDiffPanel extends Panel {
private static final int SCROLL_MARGIN = 50;
+ private final IModel<Repository> repoModel;
+
private final BlobDiffInfo diffInfo;
private final GitText oldText;
private final GitText newText;
+ private final IModel<Map<Integer, List<CommitComment>>> oldCommentsModel;
+
+ private final IModel<Map<Integer, List<CommitComment>>> newCommentsModel;
+
private GitText effectiveOldText;
private GitText effectiveNewText;
@@ -47,16 +80,67 @@ public class TextDiffPanel extends Panel {
private List<DiffLine> diffs;
- public TextDiffPanel(String id, BlobDiffInfo diffInfo, GitText oldText, GitText newText) {
+ public TextDiffPanel(String id, IModel<Repository> repoModel,
+ BlobDiffInfo diffInfo, GitText oldText, GitText newText) {
super(id);
- this.diffInfo = diffInfo;
+ this.repoModel = repoModel;
+
+ String oldCommitHash = diffInfo.getOldRevision();
+ if (!GitUtils.isHash(oldCommitHash))
+ oldCommitHash = repoModel.getObject().git().parseRevision(oldCommitHash, true);
+ String newCommitHash = diffInfo.getNewRevision();
+ if (!GitUtils.isHash(newCommitHash))
+ newCommitHash = repoModel.getObject().git().parseRevision(newCommitHash, true);
+
+ this.diffInfo = new BlobDiffInfo(diffInfo.getStatus(), diffInfo.getOldPath(), diffInfo.getNewPath(),
+ diffInfo.getOldMode(), diffInfo.getNewMode(), oldCommitHash, newCommitHash);
+
this.oldText = oldText;
this.newText = newText;
+ oldCommentsModel = new LoadableDetachableModel<Map<Integer, List<CommitComment>>>() {
+
+ @Override
+ protected Map<Integer, List<CommitComment>> load() {
+ List<CommitComment> comments = GitPlex.getInstance(CommitCommentManager.class).findByCommitAndFile(
+ TextDiffPanel.this.repoModel.getObject(),
+ TextDiffPanel.this.diffInfo.getOldRevision(),
+ TextDiffPanel.this.diffInfo.getOldPath());
+ return mapCommentsToLines(comments);
+ }
+
+ };
+
+ newCommentsModel = new LoadableDetachableModel<Map<Integer, List<CommitComment>>>() {
+
+ @Override
+ protected Map<Integer, List<CommitComment>> load() {
+ List<CommitComment> comments = GitPlex.getInstance(CommitCommentManager.class).findByCommitAndFile(
+ TextDiffPanel.this.repoModel.getObject(),
+ TextDiffPanel.this.diffInfo.getNewRevision(),
+ TextDiffPanel.this.diffInfo.getNewPath());
+ return mapCommentsToLines(comments);
+ }
+
+ };
+
onDiffOptionChanged();
}
+ private Map<Integer, List<CommitComment>> mapCommentsToLines(List<CommitComment> comments) {
+ Map<Integer, List<CommitComment>> map = new HashMap<>();
+ for (CommitComment comment: comments) {
+ List<CommitComment> lineComments = map.get(comment.getLine());
+ if (lineComments == null) {
+ lineComments = new ArrayList<>();
+ map.put(comment.getLine(), lineComments);
+ }
+ lineComments.add(comment);
+ }
+ return map;
+ }
+
private void onDiffOptionChanged() {
if (diffOption == DiffOption.IGNORE_EOL) {
effectiveOldText = oldText.ignoreEOL();
@@ -303,36 +387,223 @@ public class TextDiffPanel extends Panel {
@Override
protected void populateItem(ListItem<DiffLine> item) {
- DiffLine diffLine = item.getModelObject();
- WebMarkupContainer contentContainer = new WebMarkupContainer("content");
- contentContainer.add(new AjaxLink<Void>("addComment") {
+ final DiffLine diffLine = item.getModelObject();
+ final WebMarkupContainer contentRow = new WebMarkupContainer("contentRow");
+
+ final WebMarkupContainer commentsRow = new WebMarkupContainer("commentsRow") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ if (!(get("newComment").getClass() == WebMarkupContainer.class))
+ setVisible(true);
+ else
+ setVisible(((ListView<?>) get("comments")).size() != 0);
+ }
+
+ };
+ commentsRow.setOutputMarkupId(true);
+ commentsRow.add(new ListView<CommitComment>("comments",
+ new LoadableDetachableModel<List<CommitComment>>() {
+
+ @Override
+ protected List<CommitComment> load() {
+ List<CommitComment> oldLineComments = oldCommentsModel.getObject().get(oldLineNo);
+ if (oldLineComments == null)
+ oldLineComments = new ArrayList<>();
+ List<CommitComment> newLineComments = newCommentsModel.getObject().get(newLineNo);
+ if (newLineComments == null)
+ newLineComments = new ArrayList<>();
+
+ if (diffLine.getAction() == DiffLine.Action.DELETE) {
+ return oldLineComments;
+ } else if (diffLine.getAction() == DiffLine.Action.ADD) {
+ return newLineComments;
+ } else {
+ List<CommitComment> comments = new ArrayList<>();
+ comments.addAll(oldLineComments);
+ comments.addAll(newLineComments);
+ Collections.sort(comments);
+ return comments;
+ }
+ }
+
+ }) {
+
+ @Override
+ protected void populateItem(final ListItem<CommitComment> item) {
+ CommitComment comment = item.getModelObject();
+
+ Fragment fragment = new Fragment("comment", "viewCommentFrag", TextDiffPanel.this);
+ item.add(fragment);
+ fragment.add(new UserLink("name", new UserModel(comment.getUser()), AvatarMode.NAME));
+
+ fragment.add(new AgeLabel("age", new AbstractReadOnlyModel<Date>() {
+
+ @Override
+ public Date getObject() {
+ return item.getModelObject().getDate();
+ }
+
+ }));
+
+ fragment.add(new AjaxLink<Void>("edit") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ Fragment fragment = new Fragment("comment", "editCommentFrag", TextDiffPanel.this);
+ item.replace(fragment);
+ Form<?> form = new Form<Void>("form");
+ final CommentInput input;
+ form.add(input = new CommentInput("input", Model.of(item.getModelObject().getContent())));
+ form.add(new AjaxLink<Void>("cancel") {
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ commentsRow.replace(new WebMarkupContainer("newComment"));
+ target.add(commentsRow);
+ }
+
+ });
+ form.add(new AjaxSubmitLink("save") {
+
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ super.onSubmit(target, form);
+
+ CommitComment comment = item.getModelObject();
+ comment.setDate(new Date());
+ comment.setContent(input.getModelObject());
+
+ GitPlex.getInstance(Dao.class).persist(comment);
+ target.add(commentsRow);
+ }
+
+ });
+ fragment.add(form);
+ target.add(commentsRow);
+ }
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ setVisible(GitPlex.getInstance(AuthorizationManager.class).canModify(item.getModelObject()));
+ }
+
+ });
+ fragment.add(new AjaxLink<Void>("delete") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ GitPlex.getInstance(Dao.class).remove(item.getModelObject());
+ target.add(commentsRow);
+ }
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ setVisible(GitPlex.getInstance(AuthorizationManager.class).canModify(item.getModelObject()));
+ }
+
+ }.add(new ConfirmBehavior("Do you really want to delete this comment?")));
+
+ }
+
+ });
+
+ commentsRow.add(new WebMarkupContainer("newComment"));
+
+ item.add(commentsRow);
+
+ contentRow.add(new AjaxLink<Void>("addComment") {
+
+ private String newComment;
+
@Override
public void onClick(AjaxRequestTarget target) {
+ Fragment frag = new Fragment("newComment", "newCommentFrag", TextDiffPanel.this);
+ Form<?> form = new Form<Void>("form");
+ form.add(new CommentInput("input", new PropertyModel<String>(this, "newComment")));
+ form.add(new AjaxLink<Void>("cancel") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ commentsRow.replace(new WebMarkupContainer("newComment"));
+ target.add(commentsRow);
+ }
+
+ });
+ form.add(new AjaxSubmitLink("save") {
+
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ super.onSubmit(target, form);
+ CommitComment comment = new CommitComment();
+ comment.setRepository(repoModel.getObject());
+ comment.setUser(GitPlex.getInstance(UserManager.class).getCurrent());
+ String commit;
+ if (diffLine.getAction() == DiffLine.Action.ADD
+ || diffLine.getAction() == DiffLine.Action.EQUAL) {
+ commit = diffInfo.getNewRevision();
+ comment.setFile(diffInfo.getNewPath());
+ } else {
+ commit = diffInfo.getOldRevision();
+ comment.setFile(diffInfo.getOldPath());
+ }
+ comment.setCommit(commit);
+ comment.setContent(newComment);
+ comment.setDate(new Date());
+
+ GitPlex.getInstance(Dao.class).persist(comment);
+
+ commentsRow.replace(new WebMarkupContainer("newComment"));
+ target.add(commentsRow);
+ }
+
+ });
+ frag.add(form);
+ commentsRow.replace(frag);
+ if (!commentsRow.isVisible()) {
+ String script = String.format("$(\"<tr id='%s'></tr>\").insertAfter('#%s');",
+ commentsRow.getMarkupId(), contentRow.getMarkupId());
+ target.prependJavaScript(script);
+ }
+ target.add(commentsRow);
+ }
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ User currentUser = GitPlex.getInstance(UserManager.class).getCurrent();
+ ObjectPermission readPermission = ObjectPermission.ofRepositoryRead(repoModel.getObject());
+ setVisible(currentUser != null && SecurityUtils.getSubject().isPermitted(readPermission));
}
});
if (diffLine.getAction() == DiffLine.Action.ADD) {
if (item.getIndex() == 0 || diffs.get(item.getIndex()-1).getAction() == DiffLine.Action.EQUAL)
- contentContainer.add(AttributeAppender.append("class", " new diff-block"));
+ contentRow.add(AttributeAppender.append("class", " new diff-block"));
else
- contentContainer.add(AttributeAppender.append("class", " new"));
- contentContainer.add(new Label("oldLineNo"));
- contentContainer.add(new Label("newLineNo", "+ " + (++newLineNo)));
+ contentRow.add(AttributeAppender.append("class", " new"));
+ contentRow.add(new Label("oldLineNo"));
+ contentRow.add(new Label("newLineNo", "+ " + (++newLineNo)));
} else if (diffLine.getAction() == DiffLine.Action.DELETE) {
if (item.getIndex() == 0 || diffs.get(item.getIndex()-1).getAction() == DiffLine.Action.EQUAL)
- contentContainer.add(AttributeAppender.append("class", " old diff-block"));
+ contentRow.add(AttributeAppender.append("class", " old diff-block"));
else
- contentContainer.add(AttributeAppender.append("class", " old"));
- contentContainer.add(new Label("oldLineNo", "- " + (++oldLineNo)));
- contentContainer.add(new Label("newLineNo"));
+ contentRow.add(AttributeAppender.append("class", " old"));
+ contentRow.add(new Label("oldLineNo", "- " + (++oldLineNo)));
+ contentRow.add(new Label("newLineNo"));
} else {
- contentContainer.add(AttributeAppender.append("class", " equal"));
- contentContainer.add(new Label("oldLineNo", " " + (++oldLineNo)));
- contentContainer.add(new Label("newLineNo", " " + (++newLineNo)));
+ contentRow.add(AttributeAppender.append("class", " equal"));
+ contentRow.add(new Label("oldLineNo", " " + (++oldLineNo)));
+ contentRow.add(new Label("newLineNo", " " + (++newLineNo)));
}
- contentContainer.add(new ListView<Partial>("partials", diffLine.getPartials()) {
+ contentRow.add(new ListView<Partial>("partials", diffLine.getPartials()) {
@Override
protected void populateItem(ListItem<Partial> item) {
@@ -348,14 +619,19 @@ public class TextDiffPanel extends Panel {
}
});
- contentContainer.setOutputMarkupId(true);
-
- item.add(contentContainer);
+ contentRow.setOutputMarkupId(true);
- item.add(new WebMarkupContainer("comments").setVisible(false));
+ item.add(contentRow);
}
});
}
-
+
+ @Override
+ protected void onDetach() {
+ oldCommentsModel.detach();
+ newCommentsModel.detach();
+ super.onDetach();
+ }
+
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.html
index 8a107ca2d2..d5157aa7ee 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.html
@@ -1,152 +1,6 @@
<wicket:extend>
<div class="padder" style="background: white; padding: 50px;">
<p wicket:id="test">test</p>
- <div wicket:id="diff"></div>
- <form wicket:id="form">
- <div wicket:id="comment"></div>
- <input type="submit" value="Save" class="btn btn-primary dirty-aware"></input>
- </form>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div class="panel panel-default">
- <div wicket:id="head" class="panel-heading">
- <a wicket:id="prev" class="btn btn-primary btn-sm">prev</a>
- <a wicket:id="next" class="btn btn-primary btn-sm">next</a>
- </div>
- <div class="panel-body">
- <div class="diff" style="background: red;">diff1</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div class="diff" style="background: red;">diff2</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div class="diff" style="background: red;">diff3</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div class="diff" style="background: red;">diff4</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div>hello world</div>
- <div class="diff" style="background: red;">diff5</div>
- <div>hello world</div>
- <div>hello world</div>
- </div>
- </div>
+ <div wicket:id="diff">hello</div>
</div>
</wicket:extend>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.java
index 1b6970b6bd..588a4e7a24 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/TestPage.java
@@ -1,20 +1,15 @@
package com.pmease.gitplex.web.page;
import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.pmease.commons.git.DiffTreeNode;
import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.wicket.behavior.ScrollBehavior;
-import com.pmease.commons.wicket.behavior.StickyBehavior;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.model.Repository;
-import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.diff.BlobDiffInfo;
import com.pmease.gitplex.web.component.diff.BlobDiffPanel;
import com.pmease.gitplex.web.component.diff.DiffTreePanel;
@@ -24,8 +19,6 @@ public class TestPage extends BasePage {
private IModel<Repository> repoModel;
- private String comment;
-
public TestPage(PageParameters params) {
super(params);
@@ -60,30 +53,8 @@ public class TestPage extends BasePage {
});
- add(new WebMarkupContainer("diff"));
-
- Form<?> form = new Form<Void>("form") {
-
- @Override
- protected void onSubmit() {
- super.onSubmit();
- System.out.println("comment: " + comment);
- }
-
- @Override
- protected void onError() {
- System.out.println("error");
- }
-
- };
- form.add(new CommentInput("comment", new PropertyModel<String>(this, "comment")));
- add(form);
+ add(new WebMarkupContainer("diff").setOutputMarkupId(true));
- WebMarkupContainer head = new WebMarkupContainer("head");
- head.add(new StickyBehavior());
- head.add(new WebMarkupContainer("prev").add(new ScrollBehavior(head, ".diff", 200, false)));
- head.add(new WebMarkupContainer("next").add(new ScrollBehavior(head, ".diff", 200, true)));
- add(head);
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/commits/RepoCommitsPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/commits/RepoCommitsPanel.java
index 8e5c899bd0..7bc45c6300 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/commits/RepoCommitsPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/commits/RepoCommitsPanel.java
@@ -25,7 +25,7 @@ import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.pmease.commons.git.Commit;
-import com.pmease.gitplex.core.manager.CommitCommentManager;
+import com.pmease.gitplex.core.manager.OldCommitCommentManager;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.web.common.datatype.DataTypes;
import com.pmease.gitplex.web.component.commit.CommitMessagePanel;
@@ -75,7 +75,7 @@ public class RepoCommitsPanel extends Panel {
@Override
protected Map<String, Integer> load() {
// XXX: this may slow, performance tuning later
- return GitPlex.getInstance(CommitCommentManager.class).getCommitCommentStats(getRepository());
+ return GitPlex.getInstance(OldCommitCommentManager.class).getCommitCommentStats(getRepository());
}
};