Skip to content

The Unified and Autonomous Development Platform

Able to edit file when compare branches, "next" button considers open comment in request changes page

robin shine4352b2b67e59
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
index 3f547bb85a..6c0aea3465 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java
@@ -27,14 +27,10 @@ public class TextRange implements Serializable {
}
public TextRange(TextRange range) {
- if (range != null) {
- beginLine = range.beginLine;
- beginChar = range.beginChar;
- endLine = range.endLine;
- endChar = range.endChar;
- } else {
- beginLine = endLine = beginChar = endChar = -1;
- }
+ beginLine = range.beginLine;
+ beginChar = range.beginChar;
+ endLine = range.endLine;
+ endChar = range.endChar;
}
public TextRange(TokenPosition tokenPos) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
index 57cf4e473c..edfd37b29c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/instant/InstantSearchPanel.java
@@ -46,7 +46,6 @@ import com.pmease.commons.wicket.component.floating.ComponentTarget;
import com.pmease.commons.wicket.component.floating.FloatingPanel;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.SearchManager;
import com.pmease.gitplex.search.hit.QueryHit;
@@ -64,8 +63,6 @@ public abstract class InstantSearchPanel extends Panel {
final IModel<Depot> depotModel;
- private final IModel<PullRequest> requestModel;
-
final IModel<String> revisionModel;
private TextField<String> searchField;
@@ -80,12 +77,10 @@ public abstract class InstantSearchPanel extends Panel {
private int activeHitIndex;
- public InstantSearchPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,
- IModel<String> revisionModel) {
+ public InstantSearchPanel(String id, IModel<Depot> depotModel, IModel<String> revisionModel) {
super(id);
this.depotModel = depotModel;
- this.requestModel = requestModel;
this.revisionModel = revisionModel;
}
@@ -276,7 +271,6 @@ public abstract class InstantSearchPanel extends Panel {
state.blobIdent.revision = revisionModel.getObject();
state.blobIdent.path = hit.getBlobPath();
state.mark = TextRange.of(hit.getTokenPos());
- state.requestId = PullRequest.idOf(requestModel.getObject());
PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), state);
CharSequence url = RequestCycle.get().urlFor(DepotFilePage.class, params);
link.add(AttributeAppender.replace("href", url.toString()));
@@ -367,7 +361,6 @@ public abstract class InstantSearchPanel extends Panel {
@Override
protected void onDetach() {
depotModel.detach();
- requestModel.detach();
revisionModel.detach();
super.onDetach();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java
index 9d9b813425..2965456239 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobsearch/result/SearchResultPanel.java
@@ -33,7 +33,6 @@ import com.pmease.commons.git.BlobIdent;
import com.pmease.commons.wicket.assets.uri.URIResourceReference;
import com.pmease.commons.wicket.component.EmphasizeAwareLabel;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.hit.FileHit;
import com.pmease.gitplex.search.hit.QueryHit;
@@ -413,7 +412,6 @@ public abstract class SearchResultPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent.revision = context.getBlobIdent().revision;
state.blobIdent.path = blobPath;
- state.requestId = PullRequest.idOf(context.getPullRequest());
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
CharSequence url = RequestCycle.get().urlFor(DepotFilePage.class, params);
add(AttributeAppender.replace("href", url.toString()));
@@ -470,7 +468,6 @@ public abstract class SearchResultPanel extends Panel {
add(AttributeAppender.append("class", " active"));
DepotFilePage.State state = new DepotFilePage.State();
- state.requestId = PullRequest.idOf(context.getPullRequest());
state.mark = TextRange.of(hit.getTokenPos());
state.blobIdent.revision = context.getBlobIdent().revision;
state.blobIdent.path = hit.getBlobPath();
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 af5cd742af..2b73e8c123 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
@@ -14,7 +14,6 @@ import com.pmease.commons.wicket.component.menu.MenuItem;
import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.hit.QueryHit;
@@ -24,9 +23,6 @@ public interface BlobViewContext extends Serializable {
Depot getDepot();
- @Nullable
- PullRequest getPullRequest();
-
BlobIdent getBlobIdent();
@Nullable
@@ -40,8 +36,6 @@ public interface BlobViewContext extends Serializable {
boolean isOnBranch();
- boolean isAtSourceBranchHead();
-
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/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
index 70ee6de9d1..504a3f9236 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
@@ -755,7 +755,6 @@ public class SourceViewPanel extends BlobViewPanel {
state.blobIdent = context.getBlobIdent();
state.commentId = CodeComment.idOf(context.getOpenComment());
state.mark = TextRange.of(symbol.getPos());
- state.requestId = PullRequest.idOf(context.getPullRequest());
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
link.add(AttributeAppender.replace("href", urlFor(DepotFilePage.class, params).toString()));
link.add(symbol.render("label", null));
@@ -788,13 +787,6 @@ public class SourceViewPanel extends BlobViewPanel {
return context.getDepot();
}
- }, new AbstractReadOnlyModel<PullRequest>() {
-
- @Override
- public PullRequest getObject() {
- return context.getPullRequest();
- }
-
}) {
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/symbollink/SymbolLinkPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/symbollink/SymbolLinkPanel.java
index 03a893ab66..8989f0e6ef 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/symbollink/SymbolLinkPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/symbollink/SymbolLinkPanel.java
@@ -19,7 +19,6 @@ import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.treewalk.TreeWalk;
import com.pmease.commons.git.Blob;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewPanel;
import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
@@ -69,7 +68,6 @@ public class SymbolLinkPanel extends BlobViewPanel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent.revision = context.getBlobIdent().revision;
state.blobIdent.path = targetPath;
- state.requestId = PullRequest.idOf(context.getPullRequest());
link = new BookmarkablePageLink<Void>("link", DepotFilePage.class,
DepotFilePage.paramsOf(context.getDepot(), state));
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filelist/FileListPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filelist/FileListPanel.java
index 391736b574..87fdbdef40 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filelist/FileListPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filelist/FileListPanel.java
@@ -38,7 +38,6 @@ import com.pmease.commons.git.BlobIdent;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.commons.wicket.component.markdownviewer.MarkdownViewer;
import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
@SuppressWarnings("serial")
@@ -48,8 +47,6 @@ public abstract class FileListPanel extends Panel {
private final IModel<Depot> depotModel;
- private final IModel<PullRequest> requestModel;
-
private final BlobIdent directory;
private final IModel<List<BlobIdent>> childrenModel = new LoadableDetachableModel<List<BlobIdent>>() {
@@ -113,11 +110,10 @@ public abstract class FileListPanel extends Panel {
};
- public FileListPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel, BlobIdent directory) {
+ public FileListPanel(String id, IModel<Depot> depotModel, BlobIdent directory) {
super(id);
this.depotModel = depotModel;
- this.requestModel = requestModel;
this.directory = directory;
}
@@ -159,7 +155,6 @@ public abstract class FileListPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent = parentIdent;
- state.requestId = PullRequest.idOf(requestModel.getObject());
PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), state);
tag.put("href", urlFor(DepotFilePage.class, params));
}
@@ -195,7 +190,6 @@ public abstract class FileListPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent = blobIdent;
- state.requestId = PullRequest.idOf(requestModel.getObject());
PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), state);
tag.put("href", urlFor(DepotFilePage.class, params));
}
@@ -286,7 +280,6 @@ public abstract class FileListPanel extends Panel {
childrenModel.detach();
readmeModel.detach();
depotModel.detach();
- requestModel.detach();
super.onDetach();
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java
index 33904c3eb7..005203d1c4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java
@@ -25,7 +25,6 @@ import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.AbstractLink;
-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.list.ListItem;
@@ -58,7 +57,6 @@ import com.pmease.commons.wicket.component.floating.AlignPlacement;
import com.pmease.commons.wicket.component.floating.FloatingPanel;
import com.pmease.commons.wicket.component.menu.MenuItem;
import com.pmease.commons.wicket.component.menu.MenuLink;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.component.BlobIcon;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobNameChangeCallback;
@@ -138,7 +136,6 @@ public abstract class FileNavigator extends Panel {
super.onComponentTag(tag);
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent = blobIdent;
- state.requestId = PullRequest.idOf(context.getPullRequest());
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
tag.put("href", urlFor(DepotFilePage.class, params));
}
@@ -257,7 +254,6 @@ public abstract class FileNavigator extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent = model.getObject();
- state.requestId = PullRequest.idOf(context.getPullRequest());
PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
tag.put("href", urlFor(DepotFilePage.class, params));
}
@@ -423,49 +419,6 @@ public abstract class FileNavigator extends Panel {
});
}
- PullRequest request = context.getPullRequest();
- if (file.isFile() && context.getDepot().getBlob(file).getText() != null
- && context.isAtSourceBranchHead()
- && SecurityUtils.canModify(request.getSourceDepot(), request.getSourceBranch(), path)) {
- changeItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-pencil";
- }
-
- @Override
- public String getLabel() {
- return "Edit";
- }
-
- @Override
- public AbstractLink newLink(String id) {
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = context.getPullRequest().getSourceBranch();
- state.blobIdent.path = context.getBlobIdent().path;
- state.mode = Mode.EDIT;
- state.mark = context.getMark();
- PageParameters params = DepotFilePage.paramsOf(context.getPullRequest().getSourceDepot(), state);
-
- AbstractLink link = new BookmarkablePageLink<Void>(id, DepotFilePage.class, params) {
-
- @Override
- protected CharSequence getOnClickScript(CharSequence url) {
- return closeBeforeClick(super.getOnClickScript(url));
- }
-
- };
- link.add(new ViewStateAwareBehavior());
- // open in a new tab by default to make sure user can continue to add reply to
- // comments on current page after committing code
- link.add(AttributeAppender.append("target", "_blank"));
-
- return link;
- }
-
- });
- }
if (file.isFile() && context.getDepot().getBlob(file).getText() != null
&& context.isOnBranch()
&& SecurityUtils.canModify(context.getDepot(), file.revision, path)) {
@@ -514,41 +467,6 @@ public abstract class FileNavigator extends Panel {
});
}
- if (file.isFile() && context.isAtSourceBranchHead()
- && SecurityUtils.canModify(request.getSourceDepot(), request.getSourceBranch(), path)) {
- changeItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-trash";
- }
-
- @Override
- public String getLabel() {
- return "Delete";
- }
-
- @Override
- public AbstractLink newLink(String id) {
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = context.getPullRequest().getSourceBranch();
- state.blobIdent.path = context.getBlobIdent().path;
- state.mode = Mode.DELETE;
- PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
- AbstractLink link = new BookmarkablePageLink<Void>(id, DepotFilePage.class, params) {
-
- @Override
- protected CharSequence getOnClickScript(CharSequence url) {
- return closeBeforeClick(super.getOnClickScript(url));
- }
-
- };
- link.add(AttributeAppender.append("target", "_blank"));
- return link;
- }
-
- });
- }
if (file.isFile() && context.isOnBranch()
&& SecurityUtils.canModify(context.getDepot(), file.revision, path)) {
changeItems.add(new MenuItem() {
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 83c322f061..feeb4731f8 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
@@ -23,7 +23,6 @@ import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
@@ -34,6 +33,7 @@ import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.revwalk.RevCommit;
import org.unbescape.html.HtmlEscape;
import org.unbescape.javascript.JavaScriptEscape;
@@ -190,39 +190,35 @@ public class TextDiffPanel extends Panel implements SourceAware {
})).setOutputMarkupId(true));
+ DepotFilePage.State viewState = new DepotFilePage.State();
+ viewState.blobIdent = change.getBlobIdent();
+ PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), viewState);
+ add(new BookmarkablePageLink<Void>("viewFile", DepotFilePage.class, params));
+
PullRequest request = requestModel.getObject();
- if (request != null) {
- DepotFilePage.State state = new DepotFilePage.State();
- state.requestId = request.getId();
- state.blobIdent = change.getBlobIdent();
- PageParameters params = DepotFilePage.paramsOf(request.getTargetDepot(), state);
- add(new BookmarkablePageLink<Void>("viewFile", DepotFilePage.class, params));
- state = new DepotFilePage.State();
- state.blobIdent.revision = request.getSourceBranch();
- state.blobIdent.path = change.getPath();
- state.mode = Mode.EDIT;
- params = DepotFilePage.paramsOf(request.getSourceDepot(), state);
- Link<Void> editFileLink = new BookmarkablePageLink<Void>("editFile", DepotFilePage.class, params) {
-
- @Override
- protected void onConfigure() {
- super.onConfigure();
- PullRequest request = requestModel.getObject();
- setVisible(request.getSourceDepot() != null
- && change.getBlobIdent().revision.equals(request.getSource().getObjectName(false)));
- }
-
- };
- editFileLink.add(AttributeAppender.append("target", "_blank"));
- add(editFileLink);
+ if (change.getType() != ChangeType.DELETE
+ && request != null
+ && request.getSourceDepot() != null
+ && change.getBlobIdent().revision.equals(request.getSource().getObjectName(false))) {
+ // we are on pull request head and pull request source branch exists, so we edit source branch instead
+ DepotFilePage.State editState = new DepotFilePage.State();
+ editState.blobIdent.revision = request.getSourceBranch();
+ editState.blobIdent.path = change.getPath();
+ editState.mode = Mode.EDIT;
+ params = DepotFilePage.paramsOf(request.getSourceDepot(), editState);
+ add(new BookmarkablePageLink<Void>("editFile", DepotFilePage.class, params));
+ } else if (change.getType() != ChangeType.DELETE
+ && depotModel.getObject().getRefs(org.eclipse.jgit.lib.Constants.R_HEADS).containsKey(change.getBlobIdent().revision)) {
+ // we are on a branch
+ DepotFilePage.State editState = new DepotFilePage.State();
+ editState.blobIdent = change.getBlobIdent();
+ editState.mode = Mode.EDIT;
+ params = DepotFilePage.paramsOf(depotModel.getObject(), editState);
+ add(new BookmarkablePageLink<Void>("editFile", DepotFilePage.class, params));
} else {
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent = change.getBlobIdent();
- PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), state);
- add(new BookmarkablePageLink<Void>("viewFile", DepotFilePage.class, params));
add(new WebMarkupContainer("editFile").setVisible(false));
}
-
+
add(new Label("diffLines", new LoadableDetachableModel<String>() {
@Override
@@ -297,7 +293,7 @@ public class TextDiffPanel extends Panel implements SourceAware {
});
- symbolTooltip = new SymbolTooltipPanel("symbolTooltip", depotModel, requestModel) {
+ symbolTooltip = new SymbolTooltipPanel("symbolTooltip", depotModel) {
@Override
protected void onSelect(AjaxRequestTarget target, QueryHit hit) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js
index 249959f18e..c4f3eb1922 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js
@@ -583,30 +583,23 @@ gitplex.textdiff = {
scroll: function($container, mark) {
// use a timer to scroll after possible view port resize
setTimeout(function() {
- if (mark.beginLine != -1) {
- var markInfo = gitplex.textdiff.getMarkInfo($container, mark);
- var $startTd = markInfo.startTd;
- var $endTd = markInfo.endTd;
- if ($startTd && $endTd) {
- var top = $startTd.offset().top;
- var bottom = $endTd.offset().top + $endTd.outerHeight();
- var markHeight = bottom - top;
- var windowHeight = $(window).height();
- if (windowHeight <= markHeight) {
- $(window).scrollTop(top-50);
- } else {
- $(window).scrollTop((top+bottom-windowHeight)/2);
- }
+ var markInfo = gitplex.textdiff.getMarkInfo($container, mark);
+ var $startTd = markInfo.startTd;
+ var $endTd = markInfo.endTd;
+ if ($startTd && $endTd) {
+ var top = $startTd.offset().top;
+ var bottom = $endTd.offset().top + $endTd.outerHeight();
+ var markHeight = bottom - top;
+ var windowHeight = $(window).height();
+ if (windowHeight <= markHeight) {
+ $(window).scrollTop(top-50);
+ } else {
+ $(window).scrollTop((top+bottom-windowHeight)/2);
}
- } else {
- $(window).scrollTop($container.offset().top);
}
}, 0);
},
mark: function($container, mark) {
- if (mark.beginLine == -1)
- return;
-
gitplex.textdiff.clearMark($container);
var markInfo = gitplex.textdiff.getMarkInfo($container, mark);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.java
index 4610456508..d664bc96dc 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.java
@@ -18,8 +18,6 @@ public class HashAndCodePanel extends Panel {
private final IModel<Depot> depotModel;
- private final Long requestId;
-
private final String hash;
private final String path;
@@ -30,15 +28,9 @@ public class HashAndCodePanel extends Panel {
public HashAndCodePanel(String id, IModel<Depot> depotModel, String hash,
@Nullable String path) {
- this(id, depotModel, hash, path, null);
- }
-
- public HashAndCodePanel(String id, IModel<Depot> depotModel, String hash,
- @Nullable String path, @Nullable Long requestId) {
super(id);
this.depotModel = depotModel;
- this.requestId = requestId;
this.hash = hash;
this.path = path;
}
@@ -50,7 +42,6 @@ public class HashAndCodePanel extends Panel {
add(new CommitHashPanel("hash", hash));
DepotFilePage.State state = new DepotFilePage.State();
- state.requestId = requestId;
state.blobIdent.revision = hash;
state.blobIdent.path = path;
add(new BookmarkablePageLink<Void>("code", DepotFilePage.class,
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java
index ddfa210a30..20e2348121 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/symboltooltip/SymbolTooltipPanel.java
@@ -37,7 +37,6 @@ import com.pmease.commons.wicket.behavior.RunTaskBehavior;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.search.SearchManager;
import com.pmease.gitplex.search.hit.QueryHit;
@@ -54,19 +53,16 @@ public abstract class SymbolTooltipPanel extends Panel {
private final IModel<Depot> depotModel;
- private final IModel<PullRequest> requestModel;
-
private String revision = "";
private String symbol = "";
private List<QueryHit> symbolHits = new ArrayList<>();
- public SymbolTooltipPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel) {
+ public SymbolTooltipPanel(String id, IModel<Depot> depotModel) {
super(id);
this.depotModel = depotModel;
- this.requestModel = requestModel;
}
@Override
@@ -240,7 +236,6 @@ public abstract class SymbolTooltipPanel extends Panel {
state.blobIdent.revision = revision;
state.blobIdent.path = hit.getBlobPath();
state.mark = TextRange.of(hit.getTokenPos());
- state.requestId = PullRequest.idOf(requestModel.getObject());
return DepotFilePage.paramsOf(depotModel.getObject(), state);
}
@@ -248,7 +243,6 @@ public abstract class SymbolTooltipPanel extends Panel {
DepotFilePage.State state = new DepotFilePage.State();
state.blobIdent.revision = revision;
state.blobIdent.path = getBlobPath();
- state.requestId = PullRequest.idOf(requestModel.getObject());
state.query = symbol;
return DepotFilePage.paramsOf(depotModel.getObject(), state);
}
@@ -264,7 +258,6 @@ public abstract class SymbolTooltipPanel extends Panel {
@Override
protected void onDetach() {
depotModel.detach();
- requestModel.detach();
super.onDetach();
}
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 cbf1888757..2929ff1bf2 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
@@ -26,8 +26,6 @@ import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.model.AbstractReadOnlyModel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.cycle.RequestCycle;
@@ -48,7 +46,6 @@ import com.google.common.base.Objects;
import com.pmease.commons.git.BlobIdent;
import com.pmease.commons.git.GitUtils;
import com.pmease.commons.git.exception.ObjectNotExistException;
-import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.lang.extractors.TokenPosition;
import com.pmease.commons.wicket.assets.cookies.CookiesResourceReference;
import com.pmease.commons.wicket.assets.jqueryui.JQueryUIResourceReference;
@@ -60,7 +57,6 @@ import com.pmease.commons.wicket.websocket.WebSocketTrait;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.component.TextRange;
import com.pmease.gitplex.core.listener.RefListener;
import com.pmease.gitplex.core.manager.CodeCommentManager;
@@ -89,7 +85,6 @@ import com.pmease.gitplex.web.component.depotfile.filenavigator.FileNavigator;
import com.pmease.gitplex.web.component.revisionpicker.RevisionPicker;
import com.pmease.gitplex.web.page.depot.DepotPage;
import com.pmease.gitplex.web.page.depot.NoCommitsPage;
-import com.pmease.gitplex.web.websocket.PullRequestChangeRenderer;
@SuppressWarnings("serial")
public class DepotFilePage extends DepotPage implements BlobViewContext {
@@ -108,8 +103,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
private static final String PARAM_PATH = "path";
- private static final String PARAM_REQUEST = "request";
-
private static final String PARAM_COMMENT = "comment";
private static final String PARAM_MODE = "mode";
@@ -130,19 +123,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
private static final String SEARCH_RESULD_ID = "searchResult";
- private Long requestId;
-
- private final IModel<PullRequest> requestModel = new LoadableDetachableModel<PullRequest>() {
-
- @Override
- protected PullRequest load() {
- if (requestId != null)
- return GitPlex.getInstance(Dao.class).load(PullRequest.class, requestId);
- else
- return null;
- }
- };
-
private BlobIdent blobIdent = new BlobIdent();
private ObjectId resolvedRevision;
@@ -174,17 +154,12 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
blobIdent.revision = params.get(PARAM_REVISION).toString();
blobIdent.path = GitUtils.normalizePath(params.get(PARAM_PATH).toString());
- requestId = params.get(PARAM_REQUEST).toOptionalLong();
-
blobIdent.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());
if (blobIdent.revision == null)
blobIdent.revision = getDepot().getDefaultBranch();
resolvedRevision = getDepot().getObjectId(blobIdent.revision);
- if (requestId != null && !GitUtils.isHash(blobIdent.revision))
- throw new IllegalArgumentException("Pull request can only be associated with a hash revision");
-
RevCommit commit = getDepot().getRevCommit(blobIdent.revision);
trait.commitId = commit.copy();
@@ -248,7 +223,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
protected void onInitialize() {
super.onInitialize();
- add(new InstantSearchPanel("instantSearch", depotModel, requestModel, new AbstractReadOnlyModel<String>() {
+ add(new InstantSearchPanel("instantSearch", depotModel, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
@@ -365,9 +340,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
});
- if (getPullRequest() != null) {
- add(new PullRequestChangeRenderer(getPullRequest().getId()));
- }
}
/*
@@ -385,11 +357,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
return objectIdCache;
}
- @Override
- public PullRequest getPullRequest() {
- return requestModel.getObject();
- }
-
@Override
public CodeComment getOpenComment() {
if (commentId != null)
@@ -589,7 +556,7 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
};
} else if (blobIdent.path == null || blobIdent.isTree()) {
- fileViewer = new FileListPanel(FILE_VIEWER_ID, depotModel, requestModel, blobIdent) {
+ fileViewer = new FileListPanel(FILE_VIEWER_ID, depotModel, blobIdent) {
@Override
protected void onSelect(AjaxRequestTarget target, BlobIdent blobIdent) {
@@ -619,7 +586,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
state.blobIdent = new BlobIdent(blobIdent);
state.mark = mark;
state.mode = mode;
- state.requestId = requestId;
state.commentId = commentId;
return state;
}
@@ -640,13 +606,11 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
mark = state.mark;
mode = state.mode;
commentId = state.commentId;
- requestId = state.requestId;
}
private void onSelect(AjaxRequestTarget target, String revision) {
State state = getState();
state.blobIdent.revision = revision;
- state.requestId = null;
state.commentId = null;
state.mode = null;
state.mark = null;
@@ -736,8 +700,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
params.set(PARAM_MARK, state.mark.toString());
if (state.commentId != null)
params.set(PARAM_COMMENT, state.commentId);
- if (state.requestId != null)
- params.set(PARAM_REQUEST, state.requestId);
if (state.mode != null)
params.set(PARAM_MODE, state.mode.name().toLowerCase());
if (state.query != null)
@@ -812,13 +774,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
- @Override
- protected void onDetach() {
- requestModel.detach();
-
- super.onDetach();
- }
-
@Override
public BlobIdent getBlobIdent() {
return blobIdent;
@@ -948,13 +903,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
return getDepot().getRevCommit(getBlobIdent().revision);
}
- @Override
- public boolean isAtSourceBranchHead() {
- PullRequest request = getPullRequest();
- return request != null && request.getSourceDepot() != null
- && blobIdent.revision.equals(request.getSource().getObjectName(false));
- }
-
@Override
protected boolean isFootVisible() {
return false;
@@ -992,8 +940,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
private static final long serialVersionUID = 1L;
- public Long requestId;
-
public Long commentId;
public BlobIdent blobIdent = new BlobIdent();
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 6bcd65b9ab..0c5aef66f6 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
@@ -199,7 +199,12 @@ public class RequestChangesPage extends RequestDetailPage implements CommentSupp
public void onClick(AjaxRequestTarget target) {
int index = getCommitIndex(state.newCommit);
if (index != -1 && index != commitsModel.getObject().size()-1) {
- state.oldCommit = commitsModel.getObject().get(index).getHash();
+ CodeComment comment = getOpenComment();
+
+ // we will not move old commit if an opened comment points to it
+ if (comment == null || comment.getCommentPos().getCommit().equals(state.newCommit)) {
+ state.oldCommit = state.newCommit;
+ }
index++;
state.newCommit = commitsModel.getObject().get(index).getHash();
newRevisionDiff(target);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/UpdateActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/UpdateActivityPanel.java
index 1a4b5662b4..98a7441d7a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/UpdateActivityPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/UpdateActivityPanel.java
@@ -1,192 +1,192 @@
-package com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.behavior.AttributeAppender;
-import org.apache.wicket.markup.ComponentTag;
-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.model.AbstractReadOnlyModel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.Model;
-
-import com.pmease.commons.git.Commit;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.PullRequestUpdate;
-import com.pmease.gitplex.core.entity.Verification;
-import com.pmease.gitplex.web.Constants;
-import com.pmease.gitplex.web.component.avatar.AvatarLink;
-import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;
-import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;
-import com.pmease.gitplex.web.component.pullrequest.verificationstatus.VerificationStatusPanel;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
-
-@SuppressWarnings("serial")
-class UpdateActivityPanel extends AbstractActivityPanel {
-
- private final IModel<PullRequestUpdate> updateModel;
-
- private final IModel<Set<String>> mergedCommitsModel = new LoadableDetachableModel<Set<String>>() {
-
- @Override
- protected Set<String> load() {
- Set<String> hashes = new HashSet<>();
-
- for (Commit commit: updateModel.getObject().getRequest().getMergedCommits())
- hashes.add(commit.getHash());
- return hashes;
- }
-
- };
-
- public UpdateActivityPanel(String id, RenderableActivity activity, IModel<PullRequestUpdate> updateModel) {
- super(id, activity);
-
- this.updateModel = updateModel;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- String tooManyMessage = "Too many commits, displaying recent " + Constants.MAX_DISPLAY_COMMITS;
- add(new Label("tooManyCommits", tooManyMessage) {
-
- @Override
- protected void onConfigure() {
- super.onConfigure();
- setVisible(updateModel.getObject().getCommits().size()>Constants.MAX_DISPLAY_COMMITS);
- }
-
- });
- add(new ListView<Commit>("commits", new LoadableDetachableModel<List<Commit>>() {
-
- @Override
- protected List<Commit> load() {
- List<Commit> commits = updateModel.getObject().getCommits();
- if (commits.size() > Constants.MAX_DISPLAY_COMMITS)
- return commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());
- else
- return commits;
- }
-
- }) {
-
- @Override
- protected void populateItem(final ListItem<Commit> item) {
- Commit commit = item.getModelObject();
-
- item.add(new AvatarLink("author", commit.getAuthor(), new TooltipConfig()));
-
- IModel<Depot> depotModel = new AbstractReadOnlyModel<Depot>() {
-
- @Override
- public Depot getObject() {
- return updateModel.getObject().getRequest().getTarget().getDepot();
- }
-
- };
- item.add(new CommitMessagePanel("message", depotModel, new AbstractReadOnlyModel<Commit>() {
-
- @Override
- public Commit getObject() {
- return item.getModelObject();
- }
-
- }));
-
- IModel<PullRequest> requestModel = new AbstractReadOnlyModel<PullRequest>() {
-
- @Override
- public PullRequest getObject() {
- return updateModel.getObject().getRequest();
- }
-
- };
- item.add(new VerificationStatusPanel("verification", requestModel, Model.of(commit.getHash())) {
-
- @Override
- protected Component newStatusComponent(String id, final IModel<Verification.Status> statusModel) {
- return new Label(id, new AbstractReadOnlyModel<String>() {
-
- @Override
- public String getObject() {
- if (statusModel.getObject() == Verification.Status.PASSED)
- return "<i class='fa fa-check'></i><i class='caret'></i> ";
- else if (statusModel.getObject() == Verification.Status.ONGOING)
- return "<i class='fa fa-clock-o'></i><i class='caret'></i> ";
- else if (statusModel.getObject() == Verification.Status.NOT_PASSED)
- return "<i class='fa fa-times'></i><i class='caret'></i>";
- else
- return "";
- }
-
- }) {
-
- @Override
- protected void onComponentTag(ComponentTag tag) {
- super.onComponentTag(tag);
-
- if (statusModel.getObject() == Verification.Status.PASSED) {
- tag.put("class", "successful");
- tag.put("title", "Build is successful");
- } else if (statusModel.getObject() == Verification.Status.ONGOING) {
- tag.put("class", "running");
- tag.put("title", "Build is running");
- } else if (statusModel.getObject() == Verification.Status.NOT_PASSED) {
- tag.put("class", "failed");
- tag.put("title", "Build is failed");
- }
- }
-
- @Override
- protected void onDetach() {
- statusModel.detach();
-
- super.onDetach();
- }
-
- }.setEscapeModelStrings(false);
- }
-
- });
-
- item.add(new HashAndCodePanel("hashAndCode", new AbstractReadOnlyModel<Depot>() {
-
- @Override
- public Depot getObject() {
- return updateModel.getObject().getRequest().getTargetDepot();
- }
-
- }, commit.getHash(), null, updateModel.getObject().getRequest().getId()));
-
- if (mergedCommitsModel.getObject().contains(commit.getHash())) {
- item.add(AttributeAppender.append("class", " integrated"));
- item.add(AttributeAppender.append("title", "This commit has been integrated"));
- } else if (!updateModel.getObject().getRequest().getPendingCommits().contains(commit.getHash())) {
- item.add(AttributeAppender.append("class", " rebased"));
- item.add(AttributeAppender.append("title", "This commit has been rebased"));
- }
-
- }
-
- });
-
- }
-
- @Override
- protected void onDetach() {
- super.onDetach();
-
- updateModel.detach();
- mergedCommitsModel.detach();
- }
-
-}
+package com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.markup.ComponentTag;
+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.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.Model;
+
+import com.pmease.commons.git.Commit;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.PullRequestUpdate;
+import com.pmease.gitplex.core.entity.Verification;
+import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.avatar.AvatarLink;
+import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;
+import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;
+import com.pmease.gitplex.web.component.pullrequest.verificationstatus.VerificationStatusPanel;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
+
+@SuppressWarnings("serial")
+class UpdateActivityPanel extends AbstractActivityPanel {
+
+ private final IModel<PullRequestUpdate> updateModel;
+
+ private final IModel<Set<String>> mergedCommitsModel = new LoadableDetachableModel<Set<String>>() {
+
+ @Override
+ protected Set<String> load() {
+ Set<String> hashes = new HashSet<>();
+
+ for (Commit commit: updateModel.getObject().getRequest().getMergedCommits())
+ hashes.add(commit.getHash());
+ return hashes;
+ }
+
+ };
+
+ public UpdateActivityPanel(String id, RenderableActivity activity, IModel<PullRequestUpdate> updateModel) {
+ super(id, activity);
+
+ this.updateModel = updateModel;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ String tooManyMessage = "Too many commits, displaying recent " + Constants.MAX_DISPLAY_COMMITS;
+ add(new Label("tooManyCommits", tooManyMessage) {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(updateModel.getObject().getCommits().size()>Constants.MAX_DISPLAY_COMMITS);
+ }
+
+ });
+ add(new ListView<Commit>("commits", new LoadableDetachableModel<List<Commit>>() {
+
+ @Override
+ protected List<Commit> load() {
+ List<Commit> commits = updateModel.getObject().getCommits();
+ if (commits.size() > Constants.MAX_DISPLAY_COMMITS)
+ return commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());
+ else
+ return commits;
+ }
+
+ }) {
+
+ @Override
+ protected void populateItem(final ListItem<Commit> item) {
+ Commit commit = item.getModelObject();
+
+ item.add(new AvatarLink("author", commit.getAuthor(), new TooltipConfig()));
+
+ IModel<Depot> depotModel = new AbstractReadOnlyModel<Depot>() {
+
+ @Override
+ public Depot getObject() {
+ return updateModel.getObject().getRequest().getTarget().getDepot();
+ }
+
+ };
+ item.add(new CommitMessagePanel("message", depotModel, new AbstractReadOnlyModel<Commit>() {
+
+ @Override
+ public Commit getObject() {
+ return item.getModelObject();
+ }
+
+ }));
+
+ IModel<PullRequest> requestModel = new AbstractReadOnlyModel<PullRequest>() {
+
+ @Override
+ public PullRequest getObject() {
+ return updateModel.getObject().getRequest();
+ }
+
+ };
+ item.add(new VerificationStatusPanel("verification", requestModel, Model.of(commit.getHash())) {
+
+ @Override
+ protected Component newStatusComponent(String id, final IModel<Verification.Status> statusModel) {
+ return new Label(id, new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ if (statusModel.getObject() == Verification.Status.PASSED)
+ return "<i class='fa fa-check'></i><i class='caret'></i> ";
+ else if (statusModel.getObject() == Verification.Status.ONGOING)
+ return "<i class='fa fa-clock-o'></i><i class='caret'></i> ";
+ else if (statusModel.getObject() == Verification.Status.NOT_PASSED)
+ return "<i class='fa fa-times'></i><i class='caret'></i>";
+ else
+ return "";
+ }
+
+ }) {
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+
+ if (statusModel.getObject() == Verification.Status.PASSED) {
+ tag.put("class", "successful");
+ tag.put("title", "Build is successful");
+ } else if (statusModel.getObject() == Verification.Status.ONGOING) {
+ tag.put("class", "running");
+ tag.put("title", "Build is running");
+ } else if (statusModel.getObject() == Verification.Status.NOT_PASSED) {
+ tag.put("class", "failed");
+ tag.put("title", "Build is failed");
+ }
+ }
+
+ @Override
+ protected void onDetach() {
+ statusModel.detach();
+
+ super.onDetach();
+ }
+
+ }.setEscapeModelStrings(false);
+ }
+
+ });
+
+ item.add(new HashAndCodePanel("hashAndCode", new AbstractReadOnlyModel<Depot>() {
+
+ @Override
+ public Depot getObject() {
+ return updateModel.getObject().getRequest().getTargetDepot();
+ }
+
+ }, commit.getHash(), null));
+
+ if (mergedCommitsModel.getObject().contains(commit.getHash())) {
+ item.add(AttributeAppender.append("class", " integrated"));
+ item.add(AttributeAppender.append("title", "This commit has been integrated"));
+ } else if (!updateModel.getObject().getRequest().getPendingCommits().contains(commit.getHash())) {
+ item.add(AttributeAppender.append("class", " rebased"));
+ item.add(AttributeAppender.append("title", "This commit has been rebased"));
+ }
+
+ }
+
+ });
+
+ }
+
+ @Override
+ protected void onDetach() {
+ super.onDetach();
+
+ updateModel.detach();
+ mergedCommitsModel.detach();
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/updates/RequestUpdatesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/updates/RequestUpdatesPage.java
index 78056ada90..6605c37cd5 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/updates/RequestUpdatesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/updates/RequestUpdatesPage.java
@@ -203,7 +203,7 @@ public class RequestUpdatesPage extends RequestDetailPage {
return getPullRequest().getTargetDepot();
}
- }, commit.getHash(), null, getPullRequest().getId()));
+ }, commit.getHash(), null));
commitItem.add(new VerificationStatusPanel("verification", requestModel, Model.of(commit.getHash())) {