Skip to content

The Unified and Autonomous Development Platform

midwork

robin shineb4f884d230cd
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java
index 8b8283fcaf..2c368e4522 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java
@@ -51,6 +51,11 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag
String latestCommitHash = comment.getRequest().getLatestUpdate().getHeadCommitHash();
if (!comment.getNewCommitHash().equals(latestCommitHash)) {
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ }
+
List<DiffEntry> changes = comment.getRepository().getDiffs(comment.getNewCommitHash(),
latestCommitHash, true);
String oldCommitHash = comment.getOldCommitHash();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java
index af0b55add9..25f9c41b46 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java
@@ -216,7 +216,7 @@ public class CommentPanel extends Panel {
if (reply.getDate().after(lastReplyDate)) {
Component newReplyRow = newReplyRow(repliesView.newChildId(), reply);
repliesView.add(newReplyRow);
- String script = String.format("$('#%s>.replies>table>tbody').append(\"<tr id='%s' class='reply'></tr>\");",
+ String script = String.format("$('#%s>.comment>.replies>table>tbody').append(\"<tr id='%s' class='reply'></tr>\");",
getMarkupId(), newReplyRow.getMarkupId());
target.prependJavaScript(script);
target.add(newReplyRow);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.html
index 119186e8e9..f6d9f34937 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.html
@@ -1,7 +1,7 @@
<wicket:extend>
<div class="compare">
<div wicket:id="compareHead" class="head">
- <div wicket:id="options" class="options clearfix">
+ <div class="options clearfix">
<div class="pull-left btn-group">
<span class="btn btn-sm btn-default old" wicket:id="oldSelector">
<i class="fa fa-ext fa-commit"></i> <span wicket:id="label"></span> <i class="caret"></i>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java
index d72eccf547..b7097e5533 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java
@@ -15,6 +15,7 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
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.event.IEvent;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
@@ -91,7 +92,13 @@ public class RequestComparePage extends RequestDetailPage {
private static final String PARAM_COMPARE_PATH = "comparePath";
private HistoryState state = new HistoryState();
-
+
+ // below fields duplicates some members of state field, and they are serving different
+ // purposes and may have different values. State members reflects url parameters, while
+ // below fields records actual value used for comparison. For instance, newCommitHash
+ // in state object can be null to display comparison against latest update, but also
+ // serves as an indication that the out dated alert should be displayed when there are
+ // new updates.
private String oldCommitHash;
private String newCommitHash;
@@ -112,7 +119,7 @@ public class RequestComparePage extends RequestDetailPage {
};
- private WebMarkupContainer compareOptions;
+ private WebMarkupContainer compareHead;
private DiffOptionPanel diffOption;
@@ -208,17 +215,13 @@ public class RequestComparePage extends RequestDetailPage {
protected void onInitialize() {
super.onInitialize();
- WebMarkupContainer compareHead = new WebMarkupContainer("compareHead");
+ compareHead = new WebMarkupContainer("compareHead");
compareHead.add(new StickyBehavior());
add(compareHead);
- compareOptions = new WebMarkupContainer("options");
- compareOptions.setOutputMarkupId(true);
- compareHead.add(compareOptions);
-
WebMarkupContainer oldSelector = new WebMarkupContainer("oldSelector");
- compareOptions.add(oldSelector);
+ compareHead.add(oldSelector);
oldSelector.add(new Label("label", new LoadableDetachableModel<String>() {
@Override
@@ -261,11 +264,11 @@ public class RequestComparePage extends RequestDetailPage {
}
};
- compareOptions.add(oldChoicesDropdown);
+ compareHead.add(oldChoicesDropdown);
oldSelector.add(new DropdownBehavior(oldChoicesDropdown).alignWithTrigger(0, 100, 0, 0));
WebMarkupContainer newSelector = new WebMarkupContainer("newSelector");
- compareOptions.add(newSelector);
+ compareHead.add(newSelector);
newSelector.add(new Label("label", new LoadableDetachableModel<String>() {
@Override
@@ -308,7 +311,7 @@ public class RequestComparePage extends RequestDetailPage {
}
};
- compareOptions.add(newChoicesDropdown);
+ compareHead.add(newChoicesDropdown);
newSelector.add(new DropdownBehavior(newChoicesDropdown).alignWithTrigger(0, 100, 0, 0));
MenuPanel commonComparisons = new MenuPanel("comparisonChoices") {
@@ -404,13 +407,14 @@ public class RequestComparePage extends RequestDetailPage {
}
};
+ commonComparisons.add(AttributeAppender.append("class", " old-vs-new"));
- compareOptions.add(commonComparisons);
- compareOptions.add(new WebMarkupContainer("comparisonSelector")
+ compareHead.add(commonComparisons);
+ compareHead.add(new WebMarkupContainer("comparisonSelector")
.add(new MenuBehavior(commonComparisons)
.alignWithTrigger(50, 100, 50, 0)));
- compareOptions.add(diffOption = new DiffOptionPanel("diffOption", repoModel, newCommitHash) {
+ compareHead.add(diffOption = new DiffOptionPanel("diffOption", repoModel, newCommitHash) {
@Override
protected void onSelectPath(AjaxRequestTarget target, String path) {
@@ -454,6 +458,7 @@ public class RequestComparePage extends RequestDetailPage {
AjaxRequestTarget target = pullRequestChanged.getTarget();
PullRequest request = getPullRequest();
boolean outdated;
+
if (state.previewIntegration) {
if (!oldCommitHash.equals(request.getTarget().getHead())) {
outdated = true;
@@ -467,13 +472,17 @@ public class RequestComparePage extends RequestDetailPage {
outdated = !newCommitHash.equals(previewCommitHash);
}
} else {
+ // only display out-dated alert if url (reflected by state field) does not contain
+ // new commit hash parameter, as otherwise refreshing will not have any effect.
outdated = state.newCommitHash == null && !newCommitHash.equals(request.getLatestUpdate().getHeadCommitHash());
}
- if (outdated) {
+ if (outdated)
setVisible(true);
- target.add(this);
- }
- target.add(compareOptions);
+
+ // have to call this here as the sticky update logic in AbstractWicketConfig can
+ // not be executed in a web socket call back
+ target.prependJavaScript(String.format("$('#%s').trigger('sticky_kit:detach');", compareHead.getMarkupId()));
+ target.add(compareHead);
}
}
@@ -501,7 +510,7 @@ public class RequestComparePage extends RequestDetailPage {
} else {
message = "Integration preview is not available for closed pull request";
}
- return message + ", displaying comparison between target branch and request head instead.";
+ return "<i class='fa fa-warning'></i> " + message + ", displaying comparison between target branch and request head instead.";
}
}) {
@@ -518,7 +527,7 @@ public class RequestComparePage extends RequestDetailPage {
}
}
- });
+ }.setEscapeModelStrings(false));
newCompareResult(null);
}
@@ -725,10 +734,10 @@ public class RequestComparePage extends RequestDetailPage {
protected void onPopState(AjaxRequestTarget target, Serializable data) {
super.onPopState(target, data);
- HistoryState state = (HistoryState) data;
+ state = (HistoryState) data;
initFromState(state);
- target.add(compareOptions);
+ target.add(compareHead);
newCompareResult(target);
}
@@ -747,7 +756,7 @@ public class RequestComparePage extends RequestDetailPage {
private void onStateChange(AjaxRequestTarget target) {
pushState(target);
- target.add(compareOptions);
+ target.add(compareHead);
newCompareResult(target);
}
@@ -766,13 +775,16 @@ public class RequestComparePage extends RequestDetailPage {
public Map<Integer, List<InlineComment>> getComments(BlobIdent blobIdent) {
Map<Integer, List<InlineComment>> comments = new HashMap<>();
for (PullRequestComment comment: getPullRequest().getComments()) {
- if (comment.getInlineInfo() != null && comment.getBlobIdent().equals(blobIdent)) {
- List<InlineComment> commentsAtLine = comments.get(comment.getLine());
- if (commentsAtLine == null) {
- commentsAtLine = new ArrayList<>();
- comments.put(comment.getLine(), commentsAtLine);
+ if (comment.getInlineInfo() != null) {
+// GitPlex.getInstance(PullRequestCommentManager.class).updateInlineInfo(comment);
+ if (comment.getBlobIdent().equals(blobIdent)) {
+ List<InlineComment> commentsAtLine = comments.get(comment.getLine());
+ if (commentsAtLine == null) {
+ commentsAtLine = new ArrayList<>();
+ comments.put(comment.getLine(), commentsAtLine);
+ }
+ commentsAtLine.add(comment);
}
- commentsAtLine.add(comment);
}
}
return comments;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/request-compare.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/request-compare.css
index 4c764e7aa7..a2ddf602c0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/request-compare.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/request-compare.css
@@ -12,6 +12,7 @@
margin-bottom: 0;
border-color: #F4D494;
border-radius: 0;
+ padding: 8px;
}
#request-detail>.compare>.head .alert>a {
color: #8a6d3b;
@@ -40,15 +41,19 @@
font-size: 12px;
color: #999;
}
+.old-vs-new.menu>.content {
+ max-height: 400px;
+ overflow-y: scroll;
+}
table.old-vs-new td {
padding: 0 8px;
}
table.old-vs-new td.old {
- width: 140px;
+ width: 160px;
text-align: left;
}
table.old-vs-new td.new {
- width: 140px;
+ width: 160px;
text-align: right;
}
table.old-vs-new td.vs {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentPullRequest.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentPullRequest.java
index 9ea81de0f9..604e0ee90c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentPullRequest.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/CommentPullRequest.java
@@ -40,7 +40,7 @@ class CommentPullRequest implements RenderableActivity {
}
};
- if (getComment().getInlineInfo() != null)
+ if (getComment().getInlineInfo() != null)
return new InlineCommentActivityPanel(panelId, commentModel);
else
return new CommentActivityPanel(panelId, commentModel);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/InlineCommentActivityPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/InlineCommentActivityPanel.java
index 06ff2621b3..24974ee2a6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/InlineCommentActivityPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/InlineCommentActivityPanel.java
@@ -8,6 +8,8 @@ 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.GitPlex;
+import com.pmease.gitplex.core.manager.PullRequestCommentManager;
import com.pmease.gitplex.core.model.PullRequestComment;
import com.pmease.gitplex.web.component.comment.CommentPanel;
import com.pmease.gitplex.web.page.repository.file.RepoFilePage;
@@ -39,6 +41,7 @@ class InlineCommentActivityPanel extends Panel {
public void onClick() {
PageParameters params;
PullRequestComment comment = commentModel.getObject();
+ GitPlex.getInstance(PullRequestCommentManager.class).updateInlineInfo(comment);
if (comment.getBlobIdent().equals(comment.getCompareWith())) {
params = RepoFilePage.paramsOf(comment);
setResponsePage(RepoFilePage.class, params);