Skip to content

The Unified and Autonomous Development Platform

Display inline comment at request activities page.

robin shined1a8fe2d9e87
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java
new file mode 100644
index 0000000000..36e2006a83
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java
@@ -0,0 +1,18 @@
+package com.pmease.gitplex.core.comment;
+
+public interface InlineComment extends Comment {
+
+ int CONTEXT_SIZE = 10;
+
+ String getCommit();
+
+ String getOldCommit();
+
+ String getNewCommit();
+
+ int getLine();
+
+ String getFile();
+
+ InlineContext getContext();
+}
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
new file mode 100644
index 0000000000..79ed844340
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java
@@ -0,0 +1,14 @@
+package com.pmease.gitplex.core.comment;
+
+import java.util.Map;
+
+public interface InlineCommentSupport {
+
+ Map<Integer, InlineComment> getOldComments();
+
+ Map<Integer, InlineComment> getNewComments();
+
+ InlineComment addComment(String commit, String file, int line, String content);
+
+ InlineComment getConcernedComment();
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineContext.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineContext.java
new file mode 100644
index 0000000000..47a5fe2879
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineContext.java
@@ -0,0 +1,34 @@
+package com.pmease.gitplex.core.comment;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.pmease.commons.util.diff.DiffLine;
+
+@SuppressWarnings("serial")
+public class InlineContext implements Serializable {
+ private final List<DiffLine> diffs;
+
+ private final boolean aboveOmitted;
+
+ private final boolean belowOmitted;
+
+ public InlineContext(List<DiffLine> diffs, boolean aboveOmitted, boolean belowOmitted) {
+ this.diffs = diffs;
+ this.aboveOmitted = aboveOmitted;
+ this.belowOmitted = belowOmitted;
+ }
+
+ public List<DiffLine> getDiffs() {
+ return diffs;
+ }
+
+ public boolean isAboveOmitted() {
+ return aboveOmitted;
+ }
+
+ public boolean isBelowOmitted() {
+ return belowOmitted;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineContextAware.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineContextAware.java
new file mode 100644
index 0000000000..9b72873174
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineContextAware.java
@@ -0,0 +1,7 @@
+package com.pmease.gitplex.core.comment;
+
+public interface InlineContextAware {
+
+ InlineContext getInlineContext(InlineComment comment);
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/LineComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/LineComment.java
deleted file mode 100644
index 1708c8d161..0000000000
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/LineComment.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.pmease.gitplex.core.comment;
-
-public interface LineComment extends Comment {
-
- String getCommit();
-
- int getLine();
-}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/LineCommentContext.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/LineCommentContext.java
deleted file mode 100644
index a275ec6eb2..0000000000
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/LineCommentContext.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.pmease.gitplex.core.comment;
-
-import java.util.Map;
-
-public interface LineCommentContext {
-
- Map<Integer, LineComment> getOldComments();
-
- Map<Integer, LineComment> getNewComments();
-
- LineComment addComment(String commit, String file, int line, String content);
-
- LineComment getConcernedComment();
-}
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 ee830618fb..a07b69ca70 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,12 +1,11 @@
package com.pmease.gitplex.core.model;
import java.io.Serializable;
-import java.util.List;
import javax.persistence.Embeddable;
import javax.persistence.Lob;
-import com.pmease.commons.util.diff.DiffLine;
+import com.pmease.gitplex.core.comment.InlineContext;
@SuppressWarnings("serial")
@Embeddable
@@ -19,9 +18,11 @@ public class InlineInfo implements Serializable {
private Integer line;
@Lob
- private List<DiffLine> context;
+ private InlineContext context;
- private String compareCommit;
+ private String oldCommit;
+
+ private String newCommit;
public String getCommit() {
return commit;
@@ -47,20 +48,28 @@ public class InlineInfo implements Serializable {
this.line = line;
}
- public List<DiffLine> getContext() {
+ public InlineContext getContext() {
return context;
}
- public void setContext(List<DiffLine> context) {
+ public void setContext(InlineContext context) {
this.context = context;
}
- public String getCompareCommit() {
- return compareCommit;
+ public String getOldCommit() {
+ return oldCommit;
+ }
+
+ public void setOldCommit(String oldCommit) {
+ this.oldCommit = oldCommit;
+ }
+
+ public String getNewCommit() {
+ return newCommit;
}
- public void setCompareCommit(String compareCommit) {
- this.compareCommit = compareCommit;
+ public void setNewCommit(String newCommit) {
+ this.newCommit = newCommit;
}
}
\ No newline at end of file
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 8b883dcf19..fdf27e67cc 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
@@ -18,7 +18,8 @@ import com.pmease.commons.hibernate.AbstractEntity;
import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.comment.CommentReply;
-import com.pmease.gitplex.core.comment.LineComment;
+import com.pmease.gitplex.core.comment.InlineComment;
+import com.pmease.gitplex.core.comment.InlineContext;
import com.pmease.gitplex.core.manager.UserManager;
@SuppressWarnings("serial")
@@ -26,7 +27,7 @@ import com.pmease.gitplex.core.manager.UserManager;
@Table(uniqueConstraints={
@UniqueConstraint(columnNames={"commit", "file", "line"})
})
-public class PullRequestComment extends AbstractEntity implements LineComment {
+public class PullRequestComment extends AbstractEntity implements InlineComment {
@ManyToOne
@JoinColumn(nullable=false)
@@ -135,4 +136,24 @@ public class PullRequestComment extends AbstractEntity implements LineComment {
return Preconditions.checkNotNull(inlineInfo).getCommit();
}
+ @Override
+ public String getOldCommit() {
+ return Preconditions.checkNotNull(inlineInfo).getOldCommit();
+ }
+
+ @Override
+ public String getNewCommit() {
+ return Preconditions.checkNotNull(inlineInfo).getNewCommit();
+ }
+
+ @Override
+ public String getFile() {
+ return Preconditions.checkNotNull(inlineInfo).getFile();
+ }
+
+ @Override
+ public InlineContext getContext() {
+ return Preconditions.checkNotNull(inlineInfo).getContext();
+ }
+
}
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 0eaffe593b..cf5f7dae69 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
@@ -770,6 +770,7 @@ h2.section-title { margin: 18px 0; font-size: 16px; }
.text-diff>.panel-heading {z-index: 10; border-top: 1px solid #DDD;}
.text-diff>.panel-heading .pull-right {margin-left: 12px;}
.text-diff>.body {overflow: auto;}
+
.table-diff .line.content>td.line-no {color: #999; width: 1%; text-align: right; white-space: nowrap;}
.table-diff .line.content td.text {font-family: Consolas,"Liberation Mono",Menlo,Courier,monospace;
color: #333; overflow: visible; white-space: pre;}
@@ -786,9 +787,10 @@ h2.section-title { margin: 18px 0; font-size: 16px; }
.table-diff .line.content:hover {background: #fea; }
.table-diff .line.content:hover>td.line-no {background: #FBDE6D;}
.table-diff table.content {width: 100%;}
-.table-diff .line.comments>td {padding: 0 12px 0 12px; border-top: 1px solid #DDD; border-bottom: 1px solid #DDD;}
+.table-diff .line.comments>td {padding: 0 12px; border: 3px solid #DDD;}
+
+.table-diff .line.comments td.avatar .concerned-comment {margin-top: 12px; font-size: 36px; color: #E7C325;}
.table-diff form.add-comment {margin: 8px;}
-
.table-diff a.add-comment {position: absolute; left:0; margin-left: -20px;
width: 20px; height: 20px; text-decoration: none;}
.table-diff a.add-comment .fa {display:none;}
@@ -949,6 +951,12 @@ ul.status-help li:last-child .description {border-bottom: none;}
.request-detail>.activities .activity>.commits td.status .failed {color: #F93333;}
.request-detail>.activities .activity>.commits td.status .running {color: #AFAD1F;}
+.request-detail>.activities .table-diff>tbody>.line.comments>td {padding: 12px;}
+.request-detail>.activities .table-diff>tbody>tr.omit>td .fa {font-size: 24px; color: #888; margin-left: 12px;}
+.request-detail>.activities .inline-comment.panel>.panel-heading {padding: 8px;}
+.request-detail>.activities .inline-comment.panel>.panel-heading .actions {margin-left: 12px;}
+.request-detail>.activities .inline-comment.panel>.panel-heading .actions a {color: #888; margin-right: 4px;}
+
.request-detail>.activities .activity>.summary .fa {background: white;}
.request-detail>.activities .activity>.discard .fa {margin-left: -19px; color: #F93333; font-size: 24px;}
.request-detail>.activities .activity>.integrate .fa {margin-left: -19px; color: #35A612; font-size: 24px;}
@@ -972,6 +980,7 @@ ul.status-help li:last-child .description {border-bottom: none;}
.request-detail>.updates>.update>.commits .commit-message>.full {margin-bottom: 4px;}
.request-detail .compare>.head {background: white; z-index: 90; padding-bottom: 20px;}
+.request-detail .compare>.head .tooltip-inner {max-width: 500px;}
.content>.commit-choice {max-height: 600px; padding: 8px 0; overflow-y: scroll;}
.content>.commit-choice a {text-decoration: none; color: #333; display: block; padding: 8px;}
.content>.commit-choice li {border-bottom: 1px dotted #BBB;}
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 768f9689f9..f220f619d8 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
@@ -2,24 +2,27 @@ package com.pmease.gitplex.web.component.diff;
import static com.pmease.commons.git.Change.Status.UNCHANGED;
-import java.util.List;
-
import org.apache.tika.mime.MediaType;
+import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.visit.IVisit;
+import org.apache.wicket.util.visit.IVisitor;
import org.eclipse.jgit.lib.FileMode;
+import com.google.common.base.Preconditions;
import com.pmease.commons.git.BlobInfo;
import com.pmease.commons.git.BlobText;
import com.pmease.commons.git.RevAwareChange;
import com.pmease.commons.util.MediaTypes;
-import com.pmease.commons.util.diff.DiffLine;
import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.comment.LineComment;
-import com.pmease.gitplex.core.comment.LineCommentContext;
+import com.pmease.gitplex.core.comment.InlineComment;
+import com.pmease.gitplex.core.comment.InlineCommentSupport;
+import com.pmease.gitplex.core.comment.InlineContext;
+import com.pmease.gitplex.core.comment.InlineContextAware;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.web.component.gitlink.GitLink;
import com.pmease.gitplex.web.component.symbollink.SymbolLink;
@@ -28,21 +31,21 @@ import com.pmease.gitplex.web.extensionpoint.DiffRenderer;
import com.pmease.gitplex.web.extensionpoint.DiffRendererProvider;
@SuppressWarnings("serial")
-public class BlobDiffPanel extends Panel {
+public class BlobDiffPanel extends Panel implements InlineContextAware {
private final IModel<Repository> repoModel;
private final RevAwareChange change;
- private final LineCommentContext commentContext;
+ private final InlineCommentSupport commentSupport;
public BlobDiffPanel(String id, IModel<Repository> repoModel, RevAwareChange change,
- LineCommentContext commentContext) {
+ InlineCommentSupport commentSupport) {
super(id);
this.repoModel = repoModel;
this.change = change;
- this.commentContext = commentContext;
+ this.commentSupport = commentSupport;
}
@Override
@@ -113,9 +116,9 @@ public class BlobDiffPanel extends Panel {
BlobText newText = repoModel.getObject().getBlobText(change.getNewBlobInfo());
if (oldText != null) {
if (newText != null) {
- add(new TextDiffPanel("blobContent", repoModel, oldText, newText, change, commentContext));
+ add(new TextDiffPanel("blobContent", repoModel, oldText, newText, change, commentSupport));
} else if (newContent.length == 0) {
- add(new TextDiffPanel("blobContent", repoModel, oldText, new BlobText(), change, commentContext));
+ add(new TextDiffPanel("blobContent", repoModel, oldText, new BlobText(), change, commentSupport));
} else {
Fragment fragment = new Fragment("blobContent", "binaryFileFrag", this);
fragment.add(new FileDiffTitle("summary", change));
@@ -123,7 +126,7 @@ public class BlobDiffPanel extends Panel {
}
} else if (newText != null) {
if (oldContent.length == 0) {
- add(new TextDiffPanel("blobContent", repoModel, new BlobText(), newText, change, commentContext));
+ add(new TextDiffPanel("blobContent", repoModel, new BlobText(), newText, change, commentSupport));
} else {
Fragment fragment = new Fragment("blobContent", "binaryFileFrag", this);
fragment.add(new FileDiffTitle("summary", change));
@@ -173,8 +176,18 @@ public class BlobDiffPanel extends Panel {
}
- public List<DiffLine> getLineContext(LineComment comment) {
- return null;
+ @Override
+ public InlineContext getInlineContext(final InlineComment comment) {
+ InlineContext context = visitChildren(InlineContextAware.class, new IVisitor<Component, InlineContext>() {
+
+ @Override
+ public void component(Component object, IVisit<InlineContext> visit) {
+ InlineContextAware inlineContextAware = (InlineContextAware) object;
+ visit.stop(inlineContextAware.getInlineContext(comment));
+ }
+
+ });
+ return Preconditions.checkNotNull(context);
}
protected void onDetach() {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
index 7d1005ff67..a685dbe426 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
@@ -40,7 +40,8 @@
<table class="comments">
<tr wicket:id="comments">
<td class="avatar">
- <span wicket:id="avatar"></span>
+ <div wicket:id="avatar"></div>
+ <div wicket:id="concerned" class="fa fa-flag concerned-comment" title="Concerned comment"></div>
</td>
<td class="comment">
<div wicket:id="comment"></div>
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 bee4e273a1..39fb40fe87 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
@@ -43,8 +43,10 @@ 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.comment.LineComment;
-import com.pmease.gitplex.core.comment.LineCommentContext;
+import com.pmease.gitplex.core.comment.InlineComment;
+import com.pmease.gitplex.core.comment.InlineCommentSupport;
+import com.pmease.gitplex.core.comment.InlineContext;
+import com.pmease.gitplex.core.comment.InlineContextAware;
import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -57,7 +59,7 @@ import com.pmease.gitplex.web.component.user.UserLink;
import com.pmease.gitplex.web.model.UserModel;
@SuppressWarnings("serial")
-public class TextDiffPanel extends Panel {
+public class TextDiffPanel extends Panel implements InlineContextAware {
private enum DiffOption {IGNORE_NOTHING, IGNORE_EOL, IGNORE_EOL_SPACES, IGNORE_CHANGE_SPACES};
@@ -81,7 +83,7 @@ public class TextDiffPanel extends Panel {
private final RevAwareChange change;
- private final LineCommentContext commentContext;
+ private final InlineCommentSupport commentContext;
private final IModel<Boolean> allowToAddCommentModel;
@@ -125,7 +127,7 @@ public class TextDiffPanel extends Panel {
public TextDiffPanel(String id, final IModel<Repository> repoModel,
BlobText oldText, BlobText newText, RevAwareChange change,
- @Nullable LineCommentContext commentContext) {
+ @Nullable InlineCommentSupport commentContext) {
super(id);
this.repoModel = repoModel;
@@ -423,10 +425,10 @@ public class TextDiffPanel extends Panel {
final DiffLine diffLine = lineItem.getModelObject();
final WebMarkupContainer contentRow = new WebMarkupContainer(CONTENT_ROW_ID);
- final IModel<List<LineComment>> lineCommentsModel = new LoadableDetachableModel<List<LineComment>>() {
+ final IModel<List<InlineComment>> lineCommentsModel = new LoadableDetachableModel<List<InlineComment>>() {
@Override
- protected List<LineComment> load() {
+ protected List<InlineComment> load() {
return getLineComments(diffLine);
}
@@ -461,11 +463,13 @@ public class TextDiffPanel extends Panel {
};
commentsRow.setOutputMarkupId(true);
- commentsRow.add(new ListView<LineComment>("comments", lineCommentsModel) {
+ commentsRow.add(new ListView<InlineComment>("comments", lineCommentsModel) {
@Override
- protected void populateItem(final ListItem<LineComment> item) {
+ protected void populateItem(final ListItem<InlineComment> item) {
item.add(new UserLink("avatar", new UserModel(item.getModelObject().getUser()), AvatarMode.AVATAR));
+ item.add(new WebMarkupContainer("concerned")
+ .setVisible(item.getModelObject().equals(commentContext.getConcernedComment())));
item.add(new CommentPanel("comment", item.getModel()).setOutputMarkupId(true));
}
@@ -523,7 +527,7 @@ public class TextDiffPanel extends Panel {
+ "if ($('.concerned-comment').length != 0) "
+ " pmease.commons.scroll.next('.concerned-comment', %d);"
+ "else"
- + " pmease.commons.scroll.next('.diff-block:first', %d);", SCROLL_MARGIN, SCROLL_MARGIN);
+ + " pmease.commons.scroll.next('.diff-block:first', %d);", SCROLL_MARGIN * 2, SCROLL_MARGIN);
}
private void showComments(AjaxRequestTarget target) {
@@ -544,8 +548,8 @@ public class TextDiffPanel extends Panel {
return commentsRow.get(ADD_COMMENT_ID) instanceof Fragment;
}
- private List<LineComment> getLineComments(DiffLine line) {
- List<LineComment> lineComments = new ArrayList<>();
+ private List<InlineComment> getLineComments(DiffLine line) {
+ List<InlineComment> lineComments = new ArrayList<>();
if (commentContext != null
&& commentContext.getOldComments().containsKey(line.getOldLineNo())
&& line.getAction() != ADD) {
@@ -606,20 +610,17 @@ public class TextDiffPanel extends Panel {
super.onSubmit(target, form);
String commit;
- String filePath;
int lineNo;
if (diffLine.getAction() == DELETE) {
commit = change.getOldRevision();
- filePath = change.getOldPath();
lineNo = diffLine.getOldLineNo();
} else {
commit = change.getNewRevision();
- filePath = change.getNewPath();
lineNo = diffLine.getNewLineNo();
- }
+ }
- commentContext.addComment(commit, filePath, lineNo, input.getModelObject());
+ commentContext.addComment(commit, change.getPath(), lineNo, input.getModelObject());
commentsRow.replace(new WebMarkupContainer(ADD_COMMENT_ID));
target.add(commentsRow);
@@ -678,4 +679,40 @@ public class TextDiffPanel extends Panel {
super.onDetach();
}
+ @Override
+ public InlineContext getInlineContext(InlineComment comment) {
+ List<DiffLine> contextDiffs = new ArrayList<>();
+ int index = -1;
+ for (int i=0; i<diffs.size(); i++) {
+ DiffLine diff = diffs.get(i);
+ if (comment.getCommit().equals(change.getOldRevision())) {
+ if (diff.getOldLineNo() == comment.getLine()) {
+ index = i;
+ break;
+ }
+ } else if (comment.getCommit().equals(change.getNewRevision())){
+ if (diff.getNewLineNo() == comment.getLine()) {
+ index = i;
+ break;
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ Preconditions.checkState(index != -1);
+
+ int start = index - InlineComment.CONTEXT_SIZE;
+ if (start < 0)
+ start = 0;
+ int end = index + InlineComment.CONTEXT_SIZE;
+ if (end > diffs.size() - 1)
+ end = diffs.size() - 1;
+
+ for (int i=start; i<=end; i++)
+ contextDiffs.add(diffs.get(i));
+
+ return new InlineContext(contextDiffs, start>0, end<diffs.size()-1);
+ }
+
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java
index c388c4e3e7..548f778c32 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java
@@ -51,8 +51,8 @@ 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.comment.LineComment;
-import com.pmease.gitplex.core.comment.LineCommentContext;
+import com.pmease.gitplex.core.comment.InlineComment;
+import com.pmease.gitplex.core.comment.InlineCommentSupport;
import com.pmease.gitplex.core.manager.PullRequestCommentManager;
import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.InlineInfo;
@@ -74,7 +74,7 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig
import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig.Placement;
@SuppressWarnings("serial")
-public class RequestComparePage extends RequestDetailPage implements LineCommentContext {
+public class RequestComparePage extends RequestDetailPage implements InlineCommentSupport {
private static final String HEAD_ID = "compareHead";
@@ -91,6 +91,10 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
private static final String CHANGES_ID = "changes";
private static final String BLOB_DIFF_ID = "blobDiff";
+
+ private static final String TARGET_BRANCH_HEAD = "Head of Target Branch";
+
+ private static final String INTEGRATION_PREVIEW = "Integration Preview";
private String file;
@@ -118,43 +122,44 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
LinkedHashMap<String, CommitDescription> choices = new LinkedHashMap<>();
PullRequest request = getPullRequest();
+ String concernedCommit;
+ if (getConcernedComment() != null)
+ concernedCommit = getConcernedComment().getCommit();
+ else
+ concernedCommit = null;
+
String name = "Base of Pull Request";
+ if (request.getBaseCommit().equals(concernedCommit))
+ name += " - Concerned";
CommitDescription description = new CommitDescription(name,
- getRepository().getCommit(request.getBaseCommit()).getSubject());
+ getRepository().git().showRevision(request.getBaseCommit()).getSubject());
choices.put(request.getBaseCommit(), description);
for (int i=request.getSortedUpdates().size()-1; i>=0; i--) {
PullRequestUpdate update = request.getSortedUpdates().get(i);
int updateNo = request.getSortedUpdates().size()-i;
- int j = 0;
- for (Commit commit: update.getCommits()) {
- if (j == update.getCommits().size()-1) {
- name = "Head of Update #" + updateNo;
- description = new CommitDescription(name, commit.getSubject());
- } else {
- description = new CommitDescription(null, commit.getSubject());
- }
- j++;
- choices.put(commit.getHash(), description);
- }
+ name = "Head of Update #" + updateNo;
+ String commitHash = update.getHeadCommit();
+ if (commitHash.equals(concernedCommit))
+ name += " - Concerned";
+ description = new CommitDescription(name, getRepository().getCommit(commitHash).getSubject());
+ choices.put(commitHash, description);
}
String targetHead = request.getTarget().getHeadCommit();
if (!choices.containsKey(targetHead)) {
- description = new CommitDescription("Head of Target Branch",
- getRepository().getCommit(targetHead).getSubject());
+ description = new CommitDescription(TARGET_BRANCH_HEAD,
+ getRepository().git().showRevision(targetHead).getSubject());
choices.put(targetHead, description);
}
IntegrationInfo integrationInfo = request.getIntegrationInfo();
if (request.isOpen()
&& integrationInfo.getIntegrationHead() != null
- && !integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())
- && integrationInfo.hasChanges()) {
- Commit commit = getRepository().getCommit(
- request.getIntegrationInfo().getIntegrationHead());
+ && !integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())) {
+ Commit commit = getRepository().git().showRevision(request.getIntegrationInfo().getIntegrationHead());
choices.put(request.getIntegrationInfo().getIntegrationHead(),
- new CommitDescription("Integration Preview", commit.getSubject()));
+ new CommitDescription(INTEGRATION_PREVIEW, commit.getSubject()));
}
return choices;
@@ -168,19 +173,18 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
@Override
protected Collection<PullRequestComment> load() {
Preconditions.checkNotNull(change);
- PullRequestCommentManager manager =
- GitPlex.getInstance(PullRequestCommentManager.class);
+ PullRequestCommentManager manager = GitPlex.getInstance(PullRequestCommentManager.class);
return manager.findByChange(getPullRequest(), change);
}
};
- private final IModel<Map<Integer, LineComment>> oldCommentsModel =
- new LoadableDetachableModel<Map<Integer, LineComment>>() {
+ private final IModel<Map<Integer, InlineComment>> oldCommentsModel =
+ new LoadableDetachableModel<Map<Integer, InlineComment>>() {
@Override
- protected Map<Integer, LineComment> load() {
- Map<Integer, LineComment> oldComments = new HashMap<>();
- for (LineComment comment: changeCommentsModel.getObject()) {
+ protected Map<Integer, InlineComment> load() {
+ Map<Integer, InlineComment> oldComments = new HashMap<>();
+ for (InlineComment comment: changeCommentsModel.getObject()) {
if (comment.getCommit().equals(oldCommit))
oldComments.put(comment.getLine(), comment);
}
@@ -189,13 +193,13 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
};
- private final IModel<Map<Integer, LineComment>> newCommentsModel =
- new LoadableDetachableModel<Map<Integer, LineComment>>() {
+ private final IModel<Map<Integer, InlineComment>> newCommentsModel =
+ new LoadableDetachableModel<Map<Integer, InlineComment>>() {
@Override
- protected Map<Integer, LineComment> load() {
- Map<Integer, LineComment> newComments = new HashMap<>();
- for (LineComment comment: changeCommentsModel.getObject()) {
+ protected Map<Integer, InlineComment> load() {
+ Map<Integer, InlineComment> newComments = new HashMap<>();
+ for (InlineComment comment: changeCommentsModel.getObject()) {
if (comment.getCommit().equals(newCommit))
newComments.put(comment.getLine(), comment);
}
@@ -225,8 +229,11 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
oldCommit = params.get("original").toString();
newCommit = params.get("revised").toString();
- if (!(oldCommit == null && newCommit == null || oldCommit != null && newCommit != null))
- throw new IllegalArgumentException("Param 'original' and 'revised' should be specified both or none.");
+ if (oldCommit != null && newCommit == null) {
+ newCommit = getPullRequest().getLatestUpdate().getHeadCommit();
+ } else if (oldCommit == null && newCommit != null) {
+ oldCommit = getPullRequest().getBaseCommit();
+ }
if (oldCommit != null) {
if (!commitsModel.getObject().containsKey(oldCommit))
@@ -273,8 +280,8 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
}
} else {
file = comment.getInlineInfo().getFile();
- oldCommit = comment.getInlineInfo().getCommit();
- newCommit = getPullRequest().getLatestUpdate().getHeadCommit();
+ oldCommit = comment.getInlineInfo().getOldCommit();
+ newCommit = comment.getInlineInfo().getNewCommit();
change = resolveChange();
}
if (change == null && !getChanges().isEmpty()) {
@@ -283,6 +290,19 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
}
}
+ @Nullable
+ private InlineCommentSupport getInlineCommentSupport() {
+ Map<String, CommitDescription> commits = commitsModel.getObject();
+ String oldCommitName = Preconditions.checkNotNull(commits.get(oldCommit)).getName();
+ String newCommitName = Preconditions.checkNotNull(commits.get(newCommit)).getName();
+ if (oldCommitName.equals(TARGET_BRANCH_HEAD) || oldCommitName.equals(INTEGRATION_PREVIEW)
+ || newCommitName.equals(TARGET_BRANCH_HEAD) || newCommitName.equals(INTEGRATION_PREVIEW)) {
+ return null;
+ } else {
+ return this;
+ }
+ }
+
@Override
protected void onInitialize() {
super.onInitialize();
@@ -370,6 +390,32 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
@Override
protected List<MenuItem> getMenuItems() {
List<MenuItem> items = new ArrayList<>();
+
+ if (getConcernedComment() != null) {
+ items.add(new ComparisonChoiceItem("Base", "Concerned") {
+
+ @Override
+ protected void onSelect() {
+ PageParameters params = paramsOf(getPullRequest(),
+ getPullRequest().getBaseCommit(), getConcernedComment().getCommit(), null,
+ getConcernedComment());
+ setResponsePage(RequestComparePage.class, params);
+ }
+
+ });
+ items.add(new ComparisonChoiceItem("Concerned", "Latest Update") {
+
+ @Override
+ protected void onSelect() {
+ PageParameters params = paramsOf(getPullRequest(),
+ getConcernedComment().getCommit(), null, null,
+ getConcernedComment());
+ setResponsePage(RequestComparePage.class, params);
+ }
+
+ });
+ }
+
items.add(new ComparisonChoiceItem("Base", "Latest Update") {
@Override
@@ -515,7 +561,7 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
}.setOutputMarkupId(true));
if (change != null) {
- BlobDiffPanel blobDiffPanel = new BlobDiffPanel(BLOB_DIFF_ID, repoModel, change, this);
+ BlobDiffPanel blobDiffPanel = new BlobDiffPanel(BLOB_DIFF_ID, repoModel, change, getInlineCommentSupport());
blobDiffPanel.setOutputMarkupId(true);
add(blobDiffPanel);
} else {
@@ -626,11 +672,9 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
} else if (event.getPayload() instanceof CommentReplied) {
CommentReplied commentReplied = (CommentReplied) event.getPayload();
PullRequestComment comment = (PullRequestComment) commentReplied.getReply().getComment();
- if (oldCommit.equals(comment.getCommit()))
- comment.getInlineInfo().setCompareCommit(newCommit);
- else
- comment.getInlineInfo().setCompareCommit(oldCommit);
- comment.getInlineInfo().setContext(getBlobDiffPanel().getLineContext(comment));
+ comment.getInlineInfo().setOldCommit(oldCommit);
+ comment.getInlineInfo().setNewCommit(newCommit);
+ comment.getInlineInfo().setContext(getBlobDiffPanel().getInlineContext(comment));
GitPlex.getInstance(Dao.class).persist(comment);
}
}
@@ -640,12 +684,12 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
private final String subject;
- CommitDescription(final @Nullable String name, final String subject) {
+ CommitDescription(final String name, final String subject) {
this.name = name;
this.subject = subject;
}
- public @Nullable String getName() {
+ public String getName() {
return name;
}
@@ -744,8 +788,8 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
super.onComponentTag(tag);
if (change != null
- && Objects.equals(change.getOldPath(), change.getOldPath())
- && Objects.equals(change.getNewPath(), change.getNewPath())) {
+ && Objects.equals(change.getOldPath(), RequestComparePage.this.change.getOldPath())
+ && Objects.equals(change.getNewPath(), RequestComparePage.this.change.getNewPath())) {
tag.put("class", "active");
}
}
@@ -760,7 +804,7 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
private void onChangeSelected(AjaxRequestTarget target, Change change) {
file = change.getPath();
this.change = new RevAwareChange(change, oldCommit, newCommit);
- BlobDiffPanel diffPanel = new BlobDiffPanel(BLOB_DIFF_ID, repoModel, this.change, this);
+ BlobDiffPanel diffPanel = new BlobDiffPanel(BLOB_DIFF_ID, repoModel, this.change, getInlineCommentSupport());
getPage().replace(diffPanel);
target.add(diffPanel);
@@ -810,17 +854,17 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
}
@Override
- public Map<Integer, LineComment> getOldComments() {
+ public Map<Integer, InlineComment> getOldComments() {
return oldCommentsModel.getObject();
}
@Override
- public Map<Integer, LineComment> getNewComments() {
+ public Map<Integer, InlineComment> getNewComments() {
return newCommentsModel.getObject();
}
@Override
- public LineComment addComment(String commit, String file, int line, String content) {
+ public InlineComment addComment(String commit, String file, int line, String content) {
User user = GitPlex.getInstance(UserManager.class).getCurrent();
Preconditions.checkNotNull(user);
PullRequestComment comment = new PullRequestComment();
@@ -829,14 +873,13 @@ public class RequestComparePage extends RequestDetailPage implements LineComment
comment.setContent(content);
comment.setRequest(getPullRequest());
InlineInfo inlineInfo = new InlineInfo();
+ comment.setInlineInfo(inlineInfo);
inlineInfo.setCommit(commit);
+ inlineInfo.setOldCommit(oldCommit);
+ inlineInfo.setNewCommit(newCommit);
inlineInfo.setFile(file);
inlineInfo.setLine(line);
- if (commit.equals(oldCommit))
- inlineInfo.setCompareCommit(newCommit);
- else
- inlineInfo.setCompareCommit(oldCommit);
- inlineInfo.setContext(getBlobDiffPanel().getLineContext(comment));
+ inlineInfo.setContext(getBlobDiffPanel().getInlineContext(comment));
comment.setInlineInfo(inlineInfo);
GitPlex.getInstance(Dao.class).persist(comment);
return comment;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.html
new file mode 100644
index 0000000000..d1a7672183
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.html
@@ -0,0 +1,20 @@
+<wicket:panel>
+ <div wicket:id="content"></div>
+ <wicket:fragment wicket:id="inlineFrag">
+ <div class="inline-comment summary">
+ <span wicket:id="name" class="user"></span>
+ added inline comment
+ <span wicket:id="age"></span>
+ </div>
+ <div class="inline-comment panel panel-default">
+ <div class="panel-heading">
+ <span wicket:id="file"></span>
+ <span class="actions">
+ <a wicket:id="displayFullContext" class="fa fa-file-txt" title="Display comment in full context"></a>
+ <a wicket:id="compareWithLatest" class="fa fa-diff" title="Display comment by comparing with latest commit"></a>
+ </span>
+ </div>
+ <div wicket:id="comment"></div>
+ </div>
+ </wicket:fragment>
+</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.java
new file mode 100644
index 0000000000..ad8332434c
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentActivityPanel.java
@@ -0,0 +1,61 @@
+package com.pmease.gitplex.web.page.repository.info.pullrequest.activity;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.markup.html.panel.Panel;
+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.PullRequestComment;
+import com.pmease.gitplex.web.component.comment.CommentPanel;
+import com.pmease.gitplex.web.component.label.AgeLabel;
+import com.pmease.gitplex.web.component.user.AvatarMode;
+import com.pmease.gitplex.web.component.user.UserLink;
+import com.pmease.gitplex.web.model.UserModel;
+import com.pmease.gitplex.web.page.repository.info.pullrequest.RequestComparePage;
+
+@SuppressWarnings("serial")
+public class CommentActivityPanel extends Panel {
+
+ private final IModel<PullRequestComment> commentModel;
+
+ public CommentActivityPanel(String id, IModel<PullRequestComment> commentModel) {
+ super(id);
+
+ this.commentModel = commentModel;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ PullRequestComment comment = commentModel.getObject();
+ if (comment.getInlineInfo() != null) {
+ Fragment fragment = new Fragment("content", "inlineFrag", this);
+ fragment.add(new UserLink("name", new UserModel(comment.getUser()), AvatarMode.NAME));
+ fragment.add(new AgeLabel("age", Model.of(comment.getDate())));
+
+ fragment.add(new Label("file", comment.getFile()));
+
+ PageParameters params = RequestComparePage.paramsOf(comment.getRequest(), null, null, null, comment);
+ fragment.add(new BookmarkablePageLink<>("displayFullContext", RequestComparePage.class, params));
+ params = RequestComparePage.paramsOf(comment.getRequest(), comment.getCommit(), null, null, comment);
+ fragment.add(new BookmarkablePageLink<Void>("compareWithLatest", RequestComparePage.class, params));
+
+ fragment.add(new InlineCommentPanel("comment", commentModel));
+ fragment.setRenderBodyOnly(true);
+ add(fragment);
+ } else {
+ add(new CommentPanel("content", commentModel));
+ }
+ }
+
+ @Override
+ protected void onDetach() {
+ commentModel.detach();
+ super.onDetach();
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentPullRequest.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentPullRequest.java
index 0af3824539..6551e71dd2 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentPullRequest.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/CommentPullRequest.java
@@ -6,7 +6,6 @@ import org.apache.wicket.markup.html.panel.Panel;
import com.pmease.gitplex.core.model.PullRequestComment;
import com.pmease.gitplex.core.model.User;
-import com.pmease.gitplex.web.component.comment.CommentPanel;
import com.pmease.gitplex.web.model.EntityModel;
public class CommentPullRequest implements PullRequestActivity {
@@ -24,7 +23,7 @@ public class CommentPullRequest implements PullRequestActivity {
@Override
public Panel render(String panelId) {
- return new CommentPanel(panelId, new EntityModel<PullRequestComment>(comment));
+ return new CommentActivityPanel(panelId, new EntityModel<PullRequestComment>(comment));
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.html
new file mode 100644
index 0000000000..984e915a4c
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.html
@@ -0,0 +1,28 @@
+<wicket:panel>
+ <table class="table-diff">
+ <tr wicket:id="aboveOmitted" class="omit">
+ <td colspan="3"><i class="fa fa-ellipsis"></i></td>
+ </tr>
+ <wicket:container wicket:id="lines">
+ <tr wicket:id="contentRow" class="line content">
+ <td class="old line-no">
+ <span wicket:id="oldLineNo"></span>
+ </td>
+ <td class="new line-no">
+ <span wicket:id="newLineNo"></span>
+ </td>
+ <td class="text"><wicket:container wicket:id="partials"><span wicket:id="partial"></span></wicket:container></td>
+ </tr>
+ <wicket:enclosure child="comment">
+ <tr class="line comments">
+ <td colspan="3">
+ <div wicket:id="comment"></div>
+ </td>
+ </tr>
+ </wicket:enclosure>
+ </wicket:container>
+ <tr wicket:id="belowOmitted" class="omit">
+ <td colspan="3"><i class="fa fa-ellipsis"></i></td>
+ </tr>
+ </table>
+</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.java
new file mode 100644
index 0000000000..4f95141b5d
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/InlineCommentPanel.java
@@ -0,0 +1,118 @@
+package com.pmease.gitplex.web.page.repository.info.pullrequest.activity;
+
+import static com.pmease.commons.util.diff.DiffLine.Action.ADD;
+import static com.pmease.commons.util.diff.DiffLine.Action.DELETE;
+
+import java.util.List;
+
+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.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+
+import com.pmease.commons.util.diff.DiffLine;
+import com.pmease.commons.util.diff.Partial;
+import com.pmease.gitplex.core.comment.InlineComment;
+import com.pmease.gitplex.web.component.comment.CommentPanel;
+
+@SuppressWarnings("serial")
+public class InlineCommentPanel extends Panel {
+
+ private final IModel<? extends InlineComment> commentModel;
+
+ public InlineCommentPanel(String id, IModel<? extends InlineComment> commentModel) {
+ super(id);
+
+ this.commentModel = commentModel;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new WebMarkupContainer("aboveOmitted") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(commentModel.getObject().getContext().isAboveOmitted());
+ }
+
+ });
+ add(new WebMarkupContainer("belowOmitted") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(commentModel.getObject().getContext().isBelowOmitted());
+ }
+
+ });
+ add(new ListView<DiffLine>("lines", new AbstractReadOnlyModel<List<DiffLine>>() {
+
+ @Override
+ public List<DiffLine> getObject() {
+ return commentModel.getObject().getContext().getDiffs();
+ }
+
+ }) {
+
+ @Override
+ protected void populateItem(final ListItem<DiffLine> item) {
+ DiffLine diffLine = item.getModelObject();
+
+ WebMarkupContainer contentRow = new WebMarkupContainer("contentRow");
+ item.add(contentRow);
+ if (diffLine.getAction() == ADD) {
+ contentRow.add(AttributeAppender.append("class", " new"));
+ contentRow.add(new Label("oldLineNo"));
+ contentRow.add(new Label("newLineNo", "+ " + (diffLine.getNewLineNo() + 1)));
+ } else if (diffLine.getAction() == DELETE) {
+ contentRow.add(AttributeAppender.append("class", " old"));
+ contentRow.add(new Label("oldLineNo", "- " + (diffLine.getOldLineNo() + 1)));
+ contentRow.add(new Label("newLineNo"));
+ } else {
+ contentRow.add(AttributeAppender.append("class", " equal"));
+ contentRow.add(new Label("oldLineNo", " " + (diffLine.getOldLineNo()+1)));
+ contentRow.add(new Label("newLineNo", " " + (diffLine.getNewLineNo()+1)));
+ }
+ contentRow.add(new ListView<Partial>("partials", diffLine.getPartials()) {
+
+ @Override
+ protected void populateItem(ListItem<Partial> item) {
+ Partial partial = item.getModelObject();
+ Label label;
+ if (partial.getContent().equals("\r"))
+ label = new Label("partial", " ");
+ else
+ label = new Label("partial", partial.getContent());
+ if (partial.isEmphasized())
+ label.add(AttributeAppender.append("class", "emphasize"));
+ item.add(label);
+ }
+
+ });
+
+ InlineComment comment = commentModel.getObject();
+ if (comment.getCommit().equals(comment.getOldCommit()) && comment.getLine() == diffLine.getOldLineNo()
+ || comment.getCommit().equals(comment.getNewCommit()) && comment.getLine() == diffLine.getNewLineNo()) {
+ item.add(new CommentPanel("comment", commentModel));
+ } else {
+ item.add(new WebMarkupContainer("comment").setVisible(false));
+ }
+ }
+
+ });
+ }
+
+ @Override
+ protected void onDetach() {
+ commentModel.detach();
+ super.onDetach();
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/UpdateActivityPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/UpdateActivityPanel.html
index 245ce9c8c4..68730474d6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/UpdateActivityPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/activity/UpdateActivityPanel.html
@@ -1,17 +1,19 @@
<wicket:panel>
- <table class="commits">
- <tr wicket:id="commits">
- <td class="icon">
- <i class="fa fa-commit"></i>
- </td>
- <td class="detail">
- <span wicket:id="author"></span>
- <span wicket:id="message"></span>
- </td>
- <td class="status">
- <span wicket:id="verification"></span>
- <span wicket:id="hashLink"></span>
- </td>
- </tr>
- </table>
+ <div class="commits">
+ <table>
+ <tr wicket:id="commits">
+ <td class="icon">
+ <i class="fa fa-commit"></i>
+ </td>
+ <td class="detail">
+ <span wicket:id="author"></span>
+ <span wicket:id="message"></span>
+ </td>
+ <td class="status">
+ <span wicket:id="verification"></span>
+ <span wicket:id="hashLink"></span>
+ </td>
+ </tr>
+ </table>
+ </div>
</wicket:panel>
\ No newline at end of file