The Unified and Autonomous Development Platform
Able to focus on concerned comment.
robin shine2e960f870170
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.javaindex 88b0ebbd56..455e9d75eb 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java@@ -594,40 +594,6 @@ public class Repository extends AbstractEntity implements UserBelonging {commitCache.put(commit.getHash(), commit);}- private static class DiffKey implements Serializable {- String oldRev;-- String newRev;-- String[] paths;-- boolean detectRenames;-- DiffKey(String oldRev, String newRev, boolean detectRenames, String...paths) {- this.oldRev = oldRev;- this.newRev = newRev;- this.detectRenames = detectRenames;- this.paths = paths;- }-- public boolean equals(Object other) {- if (!(other instanceof DiffKey))- return false;- if (this == other)- return true;- DiffKey otherKey = (DiffKey) other;- return Objects.equal(oldRev, otherKey.oldRev)- && Objects.equal(newRev, otherKey.newRev)- && Objects.equal(paths, otherKey.paths)- && Objects.equal(detectRenames, otherKey.detectRenames);- }-- public int hashCode() {- return Objects.hashCode(oldRev, newRev, paths, detectRenames);- }-- }-public FileRepository openAsJGitRepo() {try {return (FileRepository) RepositoryCache.open(FileKey.exact(git().repoDir(), FS.DETECTED), true);@@ -767,4 +733,38 @@ public class Repository extends AbstractEntity implements UserBelonging {listener.onRefUpdate(this, GitUtils.branch2ref(branch), null);}+ private static class DiffKey implements Serializable {+ String oldRev;++ String newRev;++ String[] paths;++ boolean detectRenames;++ DiffKey(String oldRev, String newRev, boolean detectRenames, String...paths) {+ this.oldRev = oldRev;+ this.newRev = newRev;+ this.detectRenames = detectRenames;+ this.paths = paths;+ }++ public boolean equals(Object other) {+ if (!(other instanceof DiffKey))+ return false;+ if (this == other)+ return true;+ DiffKey otherKey = (DiffKey) other;+ return Objects.equal(oldRev, otherKey.oldRev)+ && Objects.equal(newRev, otherKey.newRev)+ && Objects.equal(paths, otherKey.paths)+ && Objects.equal(detectRenames, otherKey.detectRenames);+ }++ public int hashCode() {+ return Objects.hashCode(oldRev, newRev, paths, detectRenames);+ }++ }+}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.javaindex 532ef02ef7..8ab5e33e69 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@@ -596,6 +596,7 @@ public class TextDiffPanel extends Panel {}private Component newCommentRow(String id, CommentAndPos commentAndPos) {+ final Long commentId = commentAndPos.comment.getId();WebMarkupContainer row = new WebMarkupContainer(id) {@Override@@ -609,10 +610,20 @@ public class TextDiffPanel extends Panel {commentRemoved.getTarget().appendJavaScript(script);}}++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);++ if (commentSupport.getConcernedComment() != null+ && commentId.equals(commentSupport.getConcernedComment().getId())) {+ String script = String.format("$('#%s').closest('td').focus();", getMarkupId());+ response.render(OnDomReadyHeaderItem.forScript(script));+ }+ }};row.add(new UserLink("avatar", new UserModel(commentAndPos.comment.getUser()), AvatarMode.AVATAR));- final Long commentId = commentAndPos.comment.getId();row.add(new CommentPanel("detail", new LoadableDetachableModel<Comment>() {@Override@@ -626,7 +637,6 @@ public class TextDiffPanel extends Panel {row.add(AttributeAppender.append("class", " concerned"));row.add(AttributeAppender.append("data-oldLineNo", commentAndPos.oldLineNo));row.add(AttributeAppender.append("data-newLineNo", commentAndPos.newLineNo));-row.setOutputMarkupId(true);return row;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.jsindex 90b19449b7..8e2070a4a7 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@@ -43,13 +43,13 @@ gitplex.textdiff = {var $commentLine = $("<tr class='comment'></tr>").insertAfter($currentLine);if ($line.children().length == 3)- $commentLine.append("<td colspan='3' class='content comment'></td>");+ $commentLine.append("<td colspan='3' tabindex='0' class='content comment'></td>");else if (!$content.hasClass("old") && !$content.hasClass("new"))- $commentLine.append("<td colspan='4' class='content comment'></td>");+ $commentLine.append("<td colspan='4' tabindex='0' class='content comment'></td>");else if (newLineNo != -1)- $commentLine.append("<td class='number'> </td><td class='content'> </td><td colspan='2' class='content comment'></td>");+ $commentLine.append("<td class='number'> </td><td tabindex='0' class='content'> </td><td colspan='2' tabindex='0' class='content comment'></td>");else- $commentLine.append("<td colspan='2' class='content comment'></td><td class='number'> </td><td class='content'> </td>");+ $commentLine.append("<td colspan='2' tabindex='0' class='content comment'></td><td class='number'> </td><td class='content' tabindex='0'> </td>");$commentLine.children(".content.comment").append($comment);}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.htmlindex 3732645910..d379751b44 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@@ -1,8 +1,8 @@<wicket:panel><div class="revision-diff"><div class="title">- Total <a onclick="$(this).closest('.revision-diff').find('.diff-stats').toggle();$(document.body).trigger('sticky_kit:recalc');return false;"><span wicket:id="totalChanged"></span> changed files</a>- <span wicket:id="filterPath"></span>+ Total <a onclick="$(this).closest('.revision-diff').find('.diff-stats').toggle();$(document.body).trigger('sticky_kit:recalc');return false;"><span wicket:id="totalChanged"></span> changed files </a>+ <span wicket:id="filterPath"></span> <a wicket:id="clearPath" title="Clear filter path"><i class="fa fa-times"></i></a></div><div wicket:id="tooManyChanges" class="alert alert-warning">Sorry we are unable to display the full diff as there are too many changes</div><ul class="diff-stats list-unstyled">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.javaindex dc5d3b0439..f3fdca7a5c 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@@ -12,6 +12,9 @@ import java.util.concurrent.Future;import javax.annotation.Nullable;import org.apache.wicket.AttributeModifier;+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.markup.head.CssHeaderItem;import org.apache.wicket.markup.head.IHeaderResponse;@@ -33,6 +36,7 @@ import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.BlobChange;import com.pmease.commons.git.LineProcessor;import com.pmease.commons.lang.diff.DiffUtils;+import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.comment.InlineCommentSupport;import com.pmease.gitplex.core.model.Repository;@@ -41,7 +45,7 @@ import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;@SuppressWarnings("serial")-public class RevisionDiffPanel extends Panel {+public abstract class RevisionDiffPanel extends Panel {private final IModel<Repository> repoModel;@@ -49,7 +53,7 @@ public class RevisionDiffPanel extends Panel {private final String newRev;- private final String filterPath;+ private final String path;private final String comparePath;@@ -66,8 +70,13 @@ public class RevisionDiffPanel extends Panel {protected ChangesAndCount load() {String oldCommitHash = repoModel.getObject().getObjectId(oldRev).name();String newCommitHash = repoModel.getObject().getObjectId(newRev).name();+ List<String> paths = new ArrayList<>();+ if (path != null)+ paths.add(path);+ if (comparePath != null)+ paths.add(comparePath);List<DiffEntry> diffEntries = repoModel.getObject().getDiffs(oldCommitHash, newCommitHash,- true, filterPath, comparePath);+ true, paths.toArray(new String[paths.size()]));List<BlobChange> diffableChanges = new ArrayList<>();for (DiffEntry entry: diffEntries) {if (diffableChanges.size() < Constants.MAX_DIFF_FILES) {@@ -158,14 +167,14 @@ public class RevisionDiffPanel extends Panel {};public RevisionDiffPanel(String id, IModel<Repository> repoModel, String oldRev, String newRev,- @Nullable String filterPath, @Nullable String comparePath, LineProcessor lineProcessor,+ @Nullable String path, @Nullable String comparePath, LineProcessor lineProcessor,DiffMode diffMode, @Nullable InlineCommentSupport commentSupport) {super(id);this.repoModel = repoModel;this.oldRev = oldRev;this.newRev = newRev;- this.filterPath = filterPath;+ this.path = path;this.comparePath = comparePath;this.lineProcessor = lineProcessor;this.diffMode = diffMode;@@ -184,10 +193,26 @@ public class RevisionDiffPanel extends Panel {}}));- if (filterPath != null)- add(new Label("filterPath", "under " + filterPath));- else- add(new Label("filterPath"));+ if (path != null) {+ add(new Label("filterPath", "filter by " + path));+ add(new AjaxLink<Void>("clearPath") {++ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new IndicateLoadingListener());+ }++ @Override+ public void onClick(AjaxRequestTarget target) {+ onClearPath(target);+ }++ });+ } else {+ add(new WebMarkupContainer("filterPath").setVisible(false));+ add(new WebMarkupContainer("clearPath").setVisible(false));+ }add(new WebMarkupContainer("tooManyChanges") {@@ -291,6 +316,8 @@ public class RevisionDiffPanel extends Panel {super.renderHead(response);response.render(CssHeaderItem.forReference(new CssResourceReference(RevisionDiffPanel.class, "revision-diff.css")));}++ protected abstract void onClearPath(AjaxRequestTarget target);private static class ChangesAndCount {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.htmlindex ed35e3eecd..4b20357344 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.html@@ -1,10 +1,10 @@<wicket:panel><span class="diff-option clearfix"><span class="pull-left">- <span wicket:id="filterBy" class="btn btn-sm btn-default" title="Filter changes by path">+ <span wicket:id="filter" class="btn btn-sm btn-default" title="Filter changes by path">Filter by <i class="fa fa-caret-down"></i></span>- <div wicket:id="filterByDropdown"></div>+ <div wicket:id="filterDropdown"></div></span><span wicket:id="lineProcessor" class="line-process btn btn-sm btn-default pull-left" title="Line process options">White space <i class="caret"></i></span><div wicket:id="lineProcessorMenu"></div>@@ -13,13 +13,4 @@<a wicket:id="split" class="btn btn-sm btn-default">Split</a></span></span>- <wicket:fragment wicket:id="filterPathFrag">- <div class="filter-path">- <div wicket:id="current" class="current">- Filter path: <span wicket:id="path"></span>- <a wicket:id="clear" title="Clear filter path"><i class="fa fa-times"></i></a>- </div>- <div wicket:id="selector"></div>- </div>- </wicket:fragment></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.javaindex 69b6c096bf..059e25ad7d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/option/DiffOptionPanel.java@@ -13,8 +13,6 @@ import org.apache.wicket.behavior.AttributeAppender;import org.apache.wicket.markup.head.CssHeaderItem;import org.apache.wicket.markup.head.IHeaderResponse;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.model.LoadableDetachableModel;@@ -45,21 +43,17 @@ public abstract class DiffOptionPanel extends Panel {private final IModel<Repository> repoModel;- private final IModel<String> filterPathModel;-- private final String newRev;+ private final IModel<String> newRevModel;private LineProcessor lineProcessor = LineProcessOption.IGNORE_NOTHING;private DiffMode diffMode;- public DiffOptionPanel(String id, IModel<Repository> repoModel,- IModel<String> filterPathModel, String newRev) {+ public DiffOptionPanel(String id, IModel<Repository> repoModel, IModel<String> newRevModel) {super(id);this.repoModel = repoModel;- this.newRev = newRev;- this.filterPathModel = filterPathModel;+ this.newRevModel = newRevModel;WebRequest request = (WebRequest) RequestCycle.get().getRequest();Cookie cookie = request.getCookie(COOKIE_DIFF_MODE);@@ -70,52 +64,21 @@ public abstract class DiffOptionPanel extends Panel {}@Override- protected void onInitialize() {- super.onInitialize();-- DropdownPanel filterByDropdown = new DropdownPanel("filterByDropdown", true) {+ protected void onBeforeRender() {+ // replace filter dropdown at render time in order to update it for instance+ // when pull request is updated with new commit in request compare page+ DropdownPanel filterDropdown = new DropdownPanel("filterDropdown", true) {@Overrideprotected Component newContent(String id) {- Fragment fragment = new Fragment(id, "filterPathFrag", DiffOptionPanel.this);- WebMarkupContainer current = new WebMarkupContainer("current") {-- @Override- protected void onConfigure() {- super.onConfigure();- setVisible(filterPathModel.getObject() != null);- }-- };- current.add(new Label("path", filterPathModel));- current.add(new AjaxLink<Void>("clear") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new IndicateLoadingListener());- }-- @Override- public void onClick(AjaxRequestTarget target) {- filterPathModel.setObject(null);- hide(target);- target.add(DiffOptionPanel.this);- onFilterPathChange(target);- }-- });- fragment.add(current);-- fragment.add(new PathSelector("selector", repoModel, newRev, FileMode.TYPE_TREE,+ return new PathSelector(id, repoModel, newRevModel.getObject(), FileMode.TYPE_TREE,FileMode.TYPE_FILE, FileMode.TYPE_GITLINK, FileMode.TYPE_SYMLINK) {@Overrideprotected void onSelect(AjaxRequestTarget target, BlobIdent blobIdent) {- filterPathModel.setObject(blobIdent.path);hide(target);target.add(DiffOptionPanel.this);- onFilterPathChange(target);+ onSelectPath(target, blobIdent.path);}@Override@@ -123,13 +86,19 @@ public abstract class DiffOptionPanel extends Panel {attributes.getAjaxCallListeners().add(new IndicateLoadingListener());}- });- return fragment;+ };}};- add(filterByDropdown);- add(new WebMarkupContainer("filterBy").add(new DropdownBehavior(filterByDropdown)));+ addOrReplace(filterDropdown);+ addOrReplace(new WebMarkupContainer("filter").add(new DropdownBehavior(filterDropdown)));++ super.onBeforeRender();+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();MenuPanel lineProcessorMenu = new MenuPanel("lineProcessorMenu") {@@ -210,7 +179,7 @@ public abstract class DiffOptionPanel extends Panel {@Overrideprotected void onDetach() {repoModel.detach();- filterPathModel.detach();+ newRevModel.detach();super.onDetach();}@@ -223,7 +192,7 @@ public abstract class DiffOptionPanel extends Panel {new CssResourceReference(DiffOptionPanel.class, "diff-option.css")));}- protected abstract void onFilterPathChange(AjaxRequestTarget target);+ protected abstract void onSelectPath(AjaxRequestTarget target, String path);protected abstract void onLineProcessorChange(AjaxRequestTarget target);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.cssindex bac5750f49..6c69128d45 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css@@ -2,9 +2,6 @@font-size: 16px;margin-bottom: 16px;}-.revision-diff>.title .fa {- color: #BBB;-}.revision-diff>.alert {margin-bottom: 16px;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.javaindex 8c2416b476..eea3318184 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java@@ -87,7 +87,7 @@ public class NewRequestPage extends PullRequestPage {private DiffOptionPanel diffOption;- private String filterPath;+ private String path;public static PageParameters paramsOf(Repository repository, RepoAndBranch source, RepoAndBranch target) {PageParameters params = paramsOf(repository);@@ -332,29 +332,18 @@ public class NewRequestPage extends PullRequestPage {private Component newComparePanel() {final Fragment fragment = new Fragment(TAB_PANEL_ID, "compareFrag", this);- PullRequest request = getPullRequest();- String newRev = request.getLatestUpdate().getHeadCommitHash();-- diffOption = new DiffOptionPanel("diffOption", repoModel, new IModel<String>() {-- @Override- public void detach() {- }+ diffOption = new DiffOptionPanel("diffOption", repoModel, new AbstractReadOnlyModel<String>() {@Overridepublic String getObject() {- return filterPath;- }-- @Override- public void setObject(String object) {- filterPath = object;+ return getPullRequest().getLatestUpdate().getHeadCommitHash();}- }, newRev) {+ }) {@Override- protected void onFilterPathChange(AjaxRequestTarget target) {+ protected void onSelectPath(AjaxRequestTarget target, String path) {+ NewRequestPage.this.path = path;RevisionDiffPanel diffPanel = newRevDiffPanel();fragment.replace(diffPanel);target.add(diffPanel);@@ -387,8 +376,18 @@ public class NewRequestPage extends PullRequestPage {String oldRev = request.getBaseCommitHash();String newRev = request.getLatestUpdate().getHeadCommitHash();RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", repoModel,- oldRev, newRev, filterPath, null, diffOption.getLineProcessor(),- diffOption.getDiffMode(), null);+ oldRev, newRev, path, null, diffOption.getLineProcessor(),+ diffOption.getDiffMode(), null) {++ @Override+ protected void onClearPath(AjaxRequestTarget target) {+ path = null;+ RevisionDiffPanel diffPanel = newRevDiffPanel();+ replaceWith(diffPanel);+ target.add(diffPanel);+ }++ };diffPanel.setOutputMarkupId(true);return diffPanel;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/RequestDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/RequestDetailPage.javaindex 6e32777824..356f9dda2e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/RequestDetailPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/RequestDetailPage.java@@ -402,7 +402,7 @@ public abstract class RequestDetailPage extends PullRequestPage {IntegrationPreview preview = request.getIntegrationPreview();PageParameters params = RequestComparePage.paramsOf(- request, null, request.getTarget().getHead(),+ request, request.getTarget().getHead(),preview!=null?preview.getIntegrated():null, null);Link<Void> link = new BookmarkablePageLink<Void>("preview", RequestComparePage.class, params) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/UpdateChangesLink.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/UpdateChangesLink.javaindex d6e71f4a77..0cf74beb29 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/UpdateChangesLink.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/UpdateChangesLink.java@@ -21,7 +21,7 @@ public class UpdateChangesLink extends BookmarkablePageLink<Void> {private static PageParameters paramsOf(PullRequestUpdate update) {PullRequest request = update.getRequest();PageParameters params = RequestComparePage.paramsOf(- request, null, update.getBaseCommitHash(), update.getHeadCommitHash(), null);+ request, update.getBaseCommitHash(), update.getHeadCommitHash(), null);return params;}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.javaindex 7fb2ddeef5..be6385fe1c 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@@ -23,6 +23,7 @@ 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.Fragment;+import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.request.cycle.RequestCycle;@@ -77,17 +78,19 @@ public class RequestComparePage extends RequestDetailPage {private static final String PARAM_COMMENT = "comment";- private static final String PARAM_OLD = "old";+ private static final String PARAM_OLD_COMMIT = "oldCommit";- private static final String PARAM_NEW = "new";+ private static final String PARAM_NEW_COMMIT = "newCommit";private static final String PARAM_PATH = "path";+ private static final String PARAM_COMPARE_PATH = "comparePath";+private String oldCommitHash;private String newCommitHash;- private String filterPath;+ private String path;private String comparePath;@@ -162,7 +165,7 @@ public class RequestComparePage extends RequestDetailPage {target.add(compareOptions);PageParameters params = getPageParameters();- if (params.get(PARAM_NEW).toString() == null) {+ if (params.get(PARAM_NEW_COMMIT).toString() == null) {newCommitHash = getPullRequest().getLatestUpdate().getHeadCommitHash();newCompareResult(target);}@@ -209,7 +212,7 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target, String commitHash) {oldCommitHash = commitHash;- getPageParameters().set(PARAM_OLD, commitHash);+ detachComment();hide(target);onStateChange(target);}@@ -256,7 +259,7 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target, String commitHash) {newCommitHash = commitHash;- getPageParameters().set(PARAM_NEW, commitHash);+ detachComment();hide(target);onStateChange(target);}@@ -279,10 +282,10 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target) {hide(target);+oldCommitHash = getPullRequest().getBaseCommitHash();newCommitHash = getPullRequest().getLatestUpdate().getHeadCommitHash();- getPageParameters().set(PARAM_OLD, oldCommitHash);- getPageParameters().set(PARAM_NEW, newCommitHash);+ detachComment();onStateChange(target);}@@ -301,10 +304,10 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target) {hide(target);+oldCommitHash = getPullRequest().getTarget().getHead();newCommitHash = preview.getIntegrated();- getPageParameters().set(PARAM_OLD, oldCommitHash);- getPageParameters().set(PARAM_NEW, newCommitHash);+ detachComment();onStateChange(target);}@@ -335,10 +338,11 @@ public class RequestComparePage extends RequestDetailPage {@Overrideprotected void onSelect(AjaxRequestTarget target) {hide(target);+oldCommitHash = baseCommit;newCommitHash = headCommit;- getPageParameters().set(PARAM_OLD, oldCommitHash);- getPageParameters().set(PARAM_NEW, newCommitHash);+ detachComment();+onStateChange(target);}@@ -355,28 +359,26 @@ public class RequestComparePage extends RequestDetailPage {.add(new MenuBehavior(commonComparisons).alignWithTrigger(50, 100, 50, 0)));- compareOptions.add(diffOption = new DiffOptionPanel("diffOption", repoModel, new IModel<String>() {-- @Override- public void detach() {- }+ compareOptions.add(diffOption = new DiffOptionPanel("diffOption", repoModel, new AbstractReadOnlyModel<String>() {@Overridepublic String getObject() {- return filterPath;- }-- @Override- public void setObject(String object) {- filterPath = object;+ return newCommitHash;}- }, newCommitHash) {+ }) {@Override- protected void onFilterPathChange(AjaxRequestTarget target) {+ protected void onSelectPath(AjaxRequestTarget target, String path) {+ RequestComparePage.this.path = path;+ comparePath = null;+ if (commentId != null) {+ detachComment();+ } else {+ getPageParameters().set(PARAM_PATH, path);+ getPageParameters().remove(PARAM_COMPARE_PATH);+ }newCompareResult(target);- getPageParameters().set(PARAM_PATH, filterPath);pushState(target);}@@ -393,6 +395,16 @@ public class RequestComparePage extends RequestDetailPage {});newCompareResult(null);}++ private void detachComment() {+ commentId = null;+ PageParameters params = getPageParameters();+ params.set(PARAM_OLD_COMMIT, oldCommitHash);+ params.set(PARAM_NEW_COMMIT, newCommitHash);+ params.set(PARAM_PATH, path);+ params.set(PARAM_COMPARE_PATH, comparePath);+ params.remove(PARAM_COMMENT);+ }@Overridepublic void onDetach() {@@ -401,22 +413,27 @@ public class RequestComparePage extends RequestDetailPage {super.onDetach();}- public static PageParameters paramsOf(PullRequest request, @Nullable PullRequestComment comment,- @Nullable String oldCommitHash, @Nullable String newCommitHash, @Nullable String path) {+ public static PageParameters paramsOf(PullRequestComment comment) {+ PageParameters params = RequestDetailPage.paramsOf(comment.getRequest());+ params.set(PARAM_COMMENT, comment.getId());++ return params;+ }++ public static PageParameters paramsOf(PullRequest request, @Nullable String oldCommitHash,+ @Nullable String newCommitHash, @Nullable String path) {PageParameters params = RequestDetailPage.paramsOf(request);- if (comment != null)- params.set(PARAM_COMMENT, comment.getId());if (oldCommitHash != null)- params.set(PARAM_OLD, oldCommitHash);+ params.set(PARAM_OLD_COMMIT, oldCommitHash);if (newCommitHash != null)- params.set(PARAM_NEW, newCommitHash);+ params.set(PARAM_NEW_COMMIT, newCommitHash);if (path != null)params.set(PARAM_PATH, path);return params;}-+@Overridepublic void onEvent(IEvent<?> event) {super.onEvent(event);@@ -428,7 +445,7 @@ public class RequestComparePage extends RequestDetailPage {// compare identifier instead of comment object as comment may have been deleted// to cause LazyInitializationExceptionif (HibernateUtils.getId(comment).equals(commentId)) {- commentId = null;+ detachComment();onStateChange(commentRemoved.getTarget());}}@@ -556,26 +573,23 @@ public class RequestComparePage extends RequestDetailPage {}private void initState(PageParameters params) {- oldCommitHash = params.get(PARAM_OLD).toString();- newCommitHash = params.get(PARAM_NEW).toString();- filterPath = params.get(PARAM_PATH).toString();commentId = params.get(PARAM_COMMENT).toOptionalLong();-PullRequestComment comment = getComment();if (comment != null) {+ oldCommitHash = comment.getOldCommitHash();+ newCommitHash = comment.getNewCommitHash();+ path = comment.getBlobIdent().path;+ comparePath = comment.getCompareWith().path;+ } else {+ oldCommitHash = params.get(PARAM_OLD_COMMIT).toString();+ newCommitHash = params.get(PARAM_NEW_COMMIT).toString();+ path = params.get(PARAM_PATH).toString();+ comparePath = params.get(PARAM_COMPARE_PATH).toString();if (oldCommitHash == null)- oldCommitHash = comment.getOldCommitHash();+ oldCommitHash = getPullRequest().getBaseCommitHash();if (newCommitHash == null)- newCommitHash = comment.getNewCommitHash();- if (filterPath == null) {- filterPath = comment.getBlobIdent().path;- comparePath = comment.getCompareWith().path;- }+ newCommitHash = getPullRequest().getLatestUpdate().getHeadCommitHash();}- if (oldCommitHash == null)- oldCommitHash = getPullRequest().getBaseCommitHash();- if (newCommitHash == null)- newCommitHash = getPullRequest().getLatestUpdate().getHeadCommitHash();}@Override@@ -669,8 +683,25 @@ public class RequestComparePage extends RequestDetailPage {};RevisionDiffPanel diffPanel = new RevisionDiffPanel("compareResult",- repoModel, oldCommitHash, newCommitHash, filterPath, comparePath,- diffOption.getLineProcessor(), diffOption.getDiffMode(), commentSupport);+ repoModel, oldCommitHash, newCommitHash, path, comparePath,+ diffOption.getLineProcessor(), diffOption.getDiffMode(),+ commentSupport) {++ @Override+ protected void onClearPath(AjaxRequestTarget target) {+ path = null;+ comparePath = null;+ if (commentId != null) {+ detachComment();+ } else {+ getPageParameters().remove(PARAM_PATH);+ getPageParameters().remove(PARAM_COMPARE_PATH);+ }+ newCompareResult(target);+ pushState(target);+ }++ };diffPanel.setOutputMarkupId(true);if (target != null) {replace(diffPanel);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.javaindex 837d3585cb..f7e140eab0 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@@ -43,7 +43,7 @@ class InlineCommentActivityPanel extends Panel {params = RepoFilePage.paramsOf(comment.getRepository(), comment.getBlobIdent());setResponsePage(RepoFilePage.class, params);} else {- params = RequestComparePage.paramsOf(comment.getRequest(), comment, null, null, null);+ params = RequestComparePage.paramsOf(comment);setResponsePage(RequestComparePage.class, params);}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/SinceChangesLink.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/SinceChangesLink.javaindex b8559ecace..1f31768b03 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/SinceChangesLink.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/overview/SinceChangesLink.java@@ -60,7 +60,7 @@ class SinceChangesLink extends Panel {@Overridepublic void onClick() {PullRequest request = requestModel.getObject();- PageParameters params = RequestComparePage.paramsOf(request, null, oldCommitModel.getObject(),+ PageParameters params = RequestComparePage.paramsOf(request, oldCommitModel.getObject(),request.getLatestUpdate().getHeadCommitHash(), null);setResponsePage(RequestComparePage.class, params);}