Skip to content

The Unified and Autonomous Development Platform

Some minor tweaks

robin shine6dfff7c0b84b
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
index 7718c4622b..1bd3d01ea1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
@@ -76,8 +76,6 @@ public class CodeComment extends AbstractEntity {
@Embedded
private CompareContext compareContext;
- private String branchRef;
-
private boolean resolved;
@OneToMany(mappedBy="comment", cascade=CascadeType.REMOVE)
@@ -187,15 +185,6 @@ public class CodeComment extends AbstractEntity {
this.resolved = resolved;
}
- @Nullable
- public String getBranchRef() {
- return branchRef;
- }
-
- public void setBranchRef(String branchRef) {
- this.branchRef = branchRef;
- }
-
public LastEvent getLastEvent() {
return lastEvent;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
index 214b176ea4..186192eb66 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
@@ -1035,6 +1035,15 @@ public class PullRequest extends AbstractEntity {
setLastEvent(lastEvent);
setLastCodeCommentEventDate(event.getDate());
}
+
+ @Nullable
+ public ObjectId getSourceHead() {
+ DepotAndBranch depotAndBranch = getSource();
+ if (depotAndBranch != null)
+ return depotAndBranch.getObjectId(false);
+ else
+ return null;
+ }
public static class ComparingInfo implements Serializable {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
index 2d01d9936b..f897bd438a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
@@ -38,8 +38,6 @@ public interface BlobViewContext extends Serializable {
boolean isOnBranch();
- boolean isOnCommentBranch();
-
void onSelect(AjaxRequestTarget target, BlobIdent blobIdent, @Nullable TokenPosition tokenPos);
void onSearchComplete(AjaxRequestTarget target, List<QueryHit> hits);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java
index 41f9e5ecd5..3c66b94c9d 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java
@@ -7,29 +7,20 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
-import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.link.ResourceLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.google.common.base.Preconditions;
import com.pmease.commons.git.BlobIdent;
-import com.pmease.commons.git.GitUtils;
import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.commons.wicket.component.ViewStateAwareAjaxLink;
-import com.pmease.gitplex.core.entity.CodeComment;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.security.SecurityUtils;
-import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
-import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
import com.pmease.gitplex.web.resource.BlobResource;
import com.pmease.gitplex.web.resource.BlobResourceReference;
@@ -49,16 +40,6 @@ public abstract class BlobViewPanel extends Panel {
this.context = context;
}
- @Override
- public void onEvent(IEvent<?> event) {
- super.onEvent(event);
-
- if (event.getPayload() instanceof CodeCommentToggled) {
- CodeCommentToggled codeCommentToggled = (CodeCommentToggled) event.getPayload();
- newChangeActions(codeCommentToggled.getPartialPageRequestHandler());
- }
- }
-
protected WebMarkupContainer newOptions(String id) {
return new WebMarkupContainer(id);
}
@@ -69,9 +50,8 @@ public abstract class BlobViewPanel extends Panel {
private void newChangeActions(@Nullable IPartialPageRequestHandler target) {
WebMarkupContainer changeActions = new WebMarkupContainer("changeActions");
- CodeComment comment = context.getOpenComment();
changeActions.setVisible(SecurityUtils.canModify(context.getDepot(), context.getBlobIdent().revision, context.getBlobIdent().path)
- && (context.isOnBranch() || context.isOnCommentBranch()));
+ && (context.isOnBranch()));
changeActions.setOutputMarkupId(true);
if (context.getDepot().getBlob(context.getBlobIdent()).getText() != null) {
@@ -92,18 +72,6 @@ public abstract class BlobViewPanel extends Panel {
};
link.add(AttributeAppender.append("title", "Edit on branch " + context.getBlobIdent().revision));
changeActions.add(link);
- } else if (context.isOnCommentBranch()) {
- PageParameters params;
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = GitUtils.ref2branch(context.getOpenComment().getBranchRef());
- state.blobIdent.path = context.getBlobIdent().path;
- state.commentId = comment.getId();
- state.requestId = PullRequest.idOf(context.getPullRequest());
- state.mode = Mode.EDIT;
- params = DepotFilePage.paramsOf(context.getDepot(), state);
- Link<Void> link = new BookmarkablePageLink<Void>("edit", DepotFilePage.class, params);
- link.add(AttributeAppender.append("title", "Edit on branch " + state.blobIdent.revision));
- changeActions.add(link);
} else {
changeActions.add(new WebMarkupContainer("edit").setVisible(false));
}
@@ -128,17 +96,6 @@ public abstract class BlobViewPanel extends Panel {
};
link.add(AttributeAppender.append("title", "Delete from branch " + context.getBlobIdent().revision));
changeActions.add(link);
- } else if (context.isOnCommentBranch()) {
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = GitUtils.ref2branch(context.getOpenComment().getBranchRef());
- state.blobIdent.path = context.getBlobIdent().path;
- state.commentId = comment.getId();
- state.requestId = PullRequest.idOf(context.getPullRequest());
- state.mode = Mode.DELETE;
- PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
- Link<Void> link = new BookmarkablePageLink<Void>("delete", DepotFilePage.class, params);
- link.add(AttributeAppender.append("title", "Delete from branch " + state.blobIdent.revision));
- changeActions.add(link);
} else {
changeActions.add(new WebMarkupContainer("delete").setVisible(false));
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
index 26c7db67e1..4737656f15 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
@@ -20,7 +20,6 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.behavior.AttributeAppender;
-import org.apache.wicket.event.Broadcast;
import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider;
import org.apache.wicket.extensions.markup.html.repeater.tree.NestedTree;
import org.apache.wicket.extensions.markup.html.repeater.tree.theme.HumanTheme;
@@ -43,7 +42,6 @@ import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.eclipse.jgit.lib.FileMode;
-import org.eclipse.jgit.lib.Ref;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbescape.html.HtmlEscape;
@@ -78,7 +76,6 @@ import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.web.component.comment.CodeCommentPanel;
-import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.comment.DepotAttachmentSupport;
import com.pmease.gitplex.web.component.comment.comparecontext.CompareContextPanel;
@@ -238,9 +235,13 @@ public class SourceViewPanel extends BlobViewPanel {
target.appendJavaScript("gitplex.sourceview.onToggleOutline();");
}
- public void mark(AjaxRequestTarget target, TextRange mark, boolean scroll) {
- String script = String.format("gitplex.sourceview.mark(%s, %s);",
- getJson(mark), scroll);
+ public void mark(AjaxRequestTarget target, @Nullable TextRange mark, boolean scroll) {
+ String script;
+ if (mark != null) {
+ script = String.format("gitplex.sourceview.mark(%s, %s);", getJson(mark), scroll);
+ } else {
+ script = String.format("gitplex.sourceview.mark(undefined, false);");
+ }
target.appendJavaScript(script);
}
@@ -376,7 +377,6 @@ public class SourceViewPanel extends BlobViewPanel {
if (context.getOpenComment() != null)
context.onCommentOpened(target, null);
target.appendJavaScript("gitplex.sourceview.onCloseComment();");
- send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
});
@@ -520,6 +520,7 @@ public class SourceViewPanel extends BlobViewPanel {
@Override
public void onClick(AjaxRequestTarget target) {
clearComment(target);
+ target.appendJavaScript("gitplex.sourceview.mark(undefined, false);");
target.appendJavaScript("gitplex.sourceview.onLayoutChange();");
}
@@ -547,9 +548,6 @@ public class SourceViewPanel extends BlobViewPanel {
comment.setUser(SecurityUtils.getAccount());
comment.getCommentPos().setRange(mark);
comment.setCompareContext(getCompareContext());
- Ref branchRef = context.getDepot().getBranchRef(context.getBlobIdent().revision);
- if (branchRef != null)
- comment.setBranchRef(branchRef.getName());
GitPlex.getInstance(CodeCommentManager.class).save(comment, context.getPullRequest());
@@ -583,7 +581,6 @@ public class SourceViewPanel extends BlobViewPanel {
getJsonOfComment(comment));
target.appendJavaScript(script);
context.onCommentOpened(target, comment);
- send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
});
@@ -626,7 +623,6 @@ public class SourceViewPanel extends BlobViewPanel {
script = String.format("gitplex.sourceview.onOpenComment(%s);", getJsonOfComment(comment));
target.appendJavaScript(script);
context.onCommentOpened(target, comment);
- send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
break;
}
}
@@ -798,7 +794,6 @@ public class SourceViewPanel extends BlobViewPanel {
getJsonOfComment(comment));
target.appendJavaScript(script);
context.onCommentOpened(target, null);
- send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
private List<Symbol> getChildSymbols(@Nullable Symbol parentSymbol) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js
index c20aa73352..a1f84fa498 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js
@@ -380,11 +380,8 @@ gitplex.sourceview = {
}
gitplex.sourceview.highlightCommentTrigger();
gitplex.sourceview.onLayoutChange();
-
- // make sure marked text is in view port after changing layout
- var mark = $sourceView.data("mark");
- if (mark)
- gitplex.sourceview.mark(mark, true);
+
+ gitplex.sourceview.mark(undefined, false);
},
onLayoutChange: function() {
$sourceView = $('.source-view');
@@ -422,12 +419,7 @@ gitplex.sourceview = {
$sourceView.removeData("openComment");
gitplex.sourceview.highlightCommentTrigger();
gitplex.sourceview.onLayoutChange();
-
- // make sure marked text is in view port after layout change
- var mark = $sourceView.data("mark");
- if (mark) {
- gitplex.sourceview.mark(mark, true);
- }
+ gitplex.sourceview.mark(undefined, false);
},
onToggleOutline: function() {
gitplex.sourceview.onLayoutChange();
@@ -475,9 +467,14 @@ gitplex.sourceview = {
}
},
mark: function(mark, scroll) {
- $(".source-view").data("mark", mark);
var cm = $(".source-view>.code>.CodeMirror")[0].CodeMirror;
- pmease.commons.codemirror.mark(cm, mark, scroll);
+ if (mark) {
+ $(".source-view").data("mark", mark);
+ pmease.commons.codemirror.mark(cm, mark, scroll);
+ } else {
+ $(".source-view").removeData("mark");
+ pmease.commons.codemirror.clearMark(cm);
+ }
},
blame: function(blameInfos) {
var cm = $(".source-view>.code>.CodeMirror")[0].CodeMirror;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java
index d4647ddae5..b86f1f03fa 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java
@@ -16,7 +16,6 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
-import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
@@ -64,7 +63,6 @@ import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.web.Constants;
-import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
import com.pmease.gitplex.web.component.diff.blob.SourceAware;
import com.pmease.gitplex.web.component.diff.blob.text.MarkAwareDiffBlock.Type;
@@ -154,16 +152,6 @@ public class TextDiffPanel extends Panel implements SourceAware {
return blameInfo;
}
- @Override
- public void onEvent(IEvent<?> event) {
- super.onEvent(event);
-
- if (event.getPayload() instanceof CodeCommentToggled) {
- CodeCommentToggled codeCommentToggled = (CodeCommentToggled) event.getPayload();
- newActions(codeCommentToggled.getPartialPageRequestHandler());
- }
- }
-
private void newActions(IPartialPageRequestHandler target) {
WebMarkupContainer actions = new WebMarkupContainer("actions");
actions.setOutputMarkupId(true);
@@ -242,18 +230,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
editState.commentId = comment.getId();
params = DepotFilePage.paramsOf(depot, editState);
title = "Edit on branch " + change.getBlobIdent().revision;
- } else if (comment != null
- && comment.getBranchRef() != null
- && depot.getObjectId(comment.getBranchRef(), false) != null) {
- // we are viewing a code comment, so we can edit referenced branch of the comment instead
- DepotFilePage.State editState = new DepotFilePage.State();
- editState.blobIdent.revision = GitUtils.ref2branch(comment.getBranchRef());
- editState.blobIdent.path = change.getPath();
- editState.mode = Mode.EDIT;
- editState.commentId = comment.getId();
- params = DepotFilePage.paramsOf(depot, editState);
- title = "Edit on branch " + editState.blobIdent.revision;
- }
+ }
}
}
@@ -1060,12 +1037,14 @@ public class TextDiffPanel extends Panel implements SourceAware {
String script = String.format("gitplex.textdiff.onCommentDeleted($('#%s'), %s);",
getMarkupId(), getJsonOfComment(comment));
target.appendJavaScript(script);
+ mark(target, null);
}
@Override
public void onCommentClosed(AjaxRequestTarget target, CodeComment comment) {
String script = String.format("gitplex.textdiff.onCloseComment($('#%s'));", getMarkupId());
target.appendJavaScript(script);
+ mark(target, null);
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
index 5ee8897ba2..604472867a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
@@ -30,8 +30,9 @@
<div wicket:id="tooManyFiles" class="alert alert-warning">Sorry we are unable to display all files as there are too many</div>
<ul wicket:id="diffStats" class="diff-stats list-unstyled">
<li wicket:id="diffStats" class="diff-stat clearfix">
- <i wicket:id="icon" class="icon pull-left"></i>
+ <i wicket:id="icon" class="icon fa-fw pull-left"></i>
<a wicket:id="file" class="file pull-left"><span wicket:id="name"></span></a>
+ <span wicket:id="hasComments" class="fa fa-comments" title="There are comments on this file"></span>
<wicket:enclosure child="bar">
<span wicket:id="bar" class="bar pull-right"></span>
<span wicket:id="deletions" class="deletions pull-right"></span>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
index 2aa7900091..de65b4485e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
@@ -26,7 +26,6 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.behavior.AttributeAppender;
-import org.apache.wicket.event.Broadcast;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
@@ -52,7 +51,6 @@ import org.apache.wicket.util.visit.IVisitor;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.FileMode;
-import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;
import com.google.common.base.Objects;
@@ -83,7 +81,6 @@ import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.Constants;
import com.pmease.gitplex.web.component.comment.CodeCommentPanel;
-import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.comment.DepotAttachmentSupport;
import com.pmease.gitplex.web.component.comment.comparecontext.CompareContextPanel;
@@ -647,7 +644,7 @@ public class RevisionDiffPanel extends Panel {
BlobChange change = item.getModelObject();
String iconClass;
if (change.getType() == null) {
- iconClass = " fa fa-square-o";
+ iconClass = " fa fa-file-text-o";
} else if (change.getType() == ChangeType.ADD || change.getType() == ChangeType.COPY)
iconClass = " fa-ext fa-diff-added";
else if (change.getType() == ChangeType.DELETE)
@@ -658,6 +655,8 @@ public class RevisionDiffPanel extends Panel {
iconClass = " fa-ext fa-diff-renamed";
item.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", iconClass)));
+
+ item.add(new WebMarkupContainer("hasComments").setVisible(!getComments(change).isEmpty()));
WebMarkupContainer fileLink = new WebMarkupContainer("file");
fileLink.add(new Label("name", change.getPath()));
@@ -733,7 +732,6 @@ public class RevisionDiffPanel extends Panel {
@Override
public void onOpenComment(AjaxRequestTarget target, CodeComment comment) {
RevisionDiffPanel.this.onOpenComment(target, comment);
- send(RevisionDiffPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
@Override
@@ -778,6 +776,14 @@ public class RevisionDiffPanel extends Panel {
@Override
public void onClick(AjaxRequestTarget target) {
clearComment(target);
+ CommentPos mark = getMark();
+ if (mark != null) {
+ SourceAware sourceAware = getSourceAware(mark.getPath());
+ if (sourceAware != null)
+ sourceAware.mark(target, null);
+ commentSupport.onMark(target, null);
+ }
+
target.appendJavaScript("gitplex.revisionDiff.reposition();");
}
@@ -803,9 +809,6 @@ public class RevisionDiffPanel extends Panel {
comment.setCommentPos(commentPos);
comment.setCompareContext(getCompareContext(comment.getCommentPos().getCommit()));
comment.setContent(contentInput.getModelObject());
- Ref branchRef = depot.getBranchRef(newRev);
- if (branchRef != null)
- comment.setBranchRef(branchRef.getName());
GitPlex.getInstance(CodeCommentManager.class).save(comment, requestModel.getObject());
@@ -841,7 +844,6 @@ public class RevisionDiffPanel extends Panel {
commentSupport.onCommentOpened(target, comment);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
- send(RevisionDiffPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
});
@@ -866,18 +868,11 @@ public class RevisionDiffPanel extends Panel {
}
commentSupport.onAddComment(target, commentPos);
target.appendJavaScript("gitplex.revisionDiff.reposition();");
- send(RevisionDiffPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
@Override
public Collection<CodeComment> getComments() {
- Collection<CodeComment> comments = new ArrayList<>();
- for (CodeComment comment: commentsModel.getObject()) {
- if (change.getPaths().contains(comment.getCommentPos().getPath())) {
- comments.add(comment);
- }
- }
- return comments;
+ return RevisionDiffPanel.this.getComments(change);
}
@Override
@@ -896,6 +891,16 @@ public class RevisionDiffPanel extends Panel {
setOutputMarkupId(true);
}
+
+ private Collection<CodeComment> getComments(BlobChange change) {
+ Collection<CodeComment> comments = new ArrayList<>();
+ for (CodeComment comment: commentsModel.getObject()) {
+ if (change.getPaths().contains(comment.getCommentPos().getPath())) {
+ comments.add(comment);
+ }
+ }
+ return comments;
+ }
private void onOpenComment(AjaxRequestTarget target, CodeComment comment) {
CodeCommentPanel commentPanel = new CodeCommentPanel(BODY_ID, comment.getId()) {
@@ -1095,15 +1100,6 @@ public class RevisionDiffPanel extends Panel {
commentSupport.onCommentOpened(target, null);
}
target.appendJavaScript("gitplex.revisionDiff.reposition();");
-
- CommentPos mark = getMark();
- if (mark != null) {
- SourceAware sourceAware = getSourceAware(mark.getPath());
- if (sourceAware != null) {
- sourceAware.mark(target, mark);
- }
- }
- send(RevisionDiffPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
});
@@ -1274,7 +1270,6 @@ public class RevisionDiffPanel extends Panel {
sourceAware.mark(target, mark);
}
}
- send(RevisionDiffPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
private void clearComment(AjaxRequestTarget target) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
index f3036e215b..cffd4326ab 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
@@ -674,16 +674,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
});
- } else if (comment != null) {
- RevisionComparePage.State state = new RevisionComparePage.State();
- state.commentId = comment.getId();
- state.pathFilter = comment.getCompareContext().getPathFilter();
- state.whitespaceOption = comment.getCompareContext().getWhitespaceOption();
- state.mark = comment.getCommentPos();
- state.leftSide = new DepotAndRevision(depot, comment.getCommentPos().getCommit());
- state.rightSide = new DepotAndRevision(depot, newCommitId.name());
- state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
- setResponsePage(RevisionComparePage.class, RevisionComparePage.paramsOf(depot, state));
} else {
RevisionComparePage.State state = new RevisionComparePage.State();
state.leftSide = new DepotAndRevision(depot, oldCommitId.name());
@@ -1004,6 +994,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
mark = comment.getCommentPos().getRange();
} else {
commentId = null;
+ mark = null;
}
GitPlex.getInstance(WebSocketManager.class).onRegionChange(this);
pushState(target);
@@ -1022,12 +1013,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
return getDepot().getBranchRef(blobIdent.revision) != null;
}
- @Override
- public boolean isOnCommentBranch() {
- CodeComment comment = getOpenComment();
- return comment != null && comment.getBranchRef() != null && getDepot().getObjectId(comment.getBranchRef(), false) != null;
- }
-
@Override
public RevCommit getCommit() {
return getDepot().getRevCommit(getBlobIdent().revision);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
index cacd1bd123..dc77a16eff 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/changes/RequestChangesPage.java
@@ -524,6 +524,7 @@ public class RequestChangesPage extends RequestDetailPage implements CommentSupp
state.mark = comment.getCommentPos();
} else {
state.commentId = null;
+ state.mark = null;
}
GitPlex.getInstance(WebSocketManager.class).onRegionChange(this);
pushState(target);