The Unified and Autonomous Development Platform
Able to confirm resolve/unresolve of comment
robin shinec7d81e337088
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/AutoSizeResourceReference.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/AutoSizeResourceReference.javaindex c610e7f1dd..b0526c3312 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/AutoSizeResourceReference.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/AutoSizeResourceReference.java@@ -9,7 +9,7 @@ public class AutoSizeResourceReference extends JavaScriptResourceReference {public static final AutoSizeResourceReference INSTANCE = new AutoSizeResourceReference();private AutoSizeResourceReference() {- super(AutoSizeResourceReference.class, "autosize.js");+ super(AutoSizeResourceReference.class, "autosize-patched.js");}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/autosize.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/autosize-patched.jssimilarity index 98%rename from commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/autosize.jsrename to commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/autosize-patched.jsindex 70dd07ca7f..0990b0bdfb 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/autosize.js+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/autosize/autosize-patched.js@@ -97,6 +97,7 @@function resize() {var htmlTop = window.pageYOffset;var bodyTop = document.body.scrollTop;+ var scrollableTop = $(ta).closest(".scrollable").scrollTop();var originalHeight = ta.style.height;ta.style.height = 'auto';@@ -117,6 +118,7 @@// prevents scroll-position jumpingdocument.documentElement.scrollTop = htmlTop;document.body.scrollTop = bodyTop;+ $(ta).closest(".scrollable").scrollTop(scrollableTop);}function update() {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentManager.javaindex de4b50c78e..706b04046e 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CodeCommentManager.java@@ -9,6 +9,7 @@ import org.eclipse.jgit.lib.ObjectId;import com.pmease.commons.hibernate.dao.EntityDao;import com.pmease.gitplex.core.entity.CodeComment;+import com.pmease.gitplex.core.entity.CodeCommentReply;import com.pmease.gitplex.core.entity.Depot;public interface CodeCommentManager extends EntityDao<CodeComment> {@@ -19,6 +20,8 @@ public interface CodeCommentManager extends EntityDao<CodeComment> {void save(CodeComment comment);+ void save(CodeComment comment, CodeCommentReply reply);+void delete(CodeComment comment);@Nullablediff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.javaindex 3310acfccd..82874ba734 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCodeCommentManager.java@@ -21,19 +21,25 @@ import com.pmease.commons.hibernate.dao.AbstractEntityDao;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.gitplex.core.entity.CodeComment;+import com.pmease.gitplex.core.entity.CodeCommentReply;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.listener.CodeCommentListener;import com.pmease.gitplex.core.manager.CodeCommentManager;+import com.pmease.gitplex.core.manager.CodeCommentReplyManager;@Singletonpublic class DefaultCodeCommentManager extends AbstractEntityDao<CodeComment> implements CodeCommentManager {private final Provider<Set<CodeCommentListener>> listenersProvider;+ private final CodeCommentReplyManager codeCommentReplyManager;+@Inject- public DefaultCodeCommentManager(Dao dao, Provider<Set<CodeCommentListener>> listenersProvider) {+ public DefaultCodeCommentManager(Dao dao, Provider<Set<CodeCommentListener>> listenersProvider,+ CodeCommentReplyManager codeCommentReplyManager) {super(dao);this.listenersProvider = listenersProvider;+ this.codeCommentReplyManager = codeCommentReplyManager;}@Sessional@@ -101,4 +107,10 @@ public class DefaultCodeCommentManager extends AbstractEntityDao<CodeComment> imreturn query(criteria);}+ @Override+ public void save(CodeComment comment, CodeCommentReply reply) {+ save(comment);+ codeCommentReplyManager.save(reply);+ }+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.htmlindex 3afa3bfc3d..84bc3a0623 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.html@@ -2,8 +2,7 @@<div class="code-comment"><div wicket:id="comment" class="comment post"></div><div wicket:id="replies" class="reply post"></div>- <div wicket:id="addReply" class="add-reply">- </div>+ <div wicket:id="addReply" class="add-reply"></div></div><wicket:fragment wicket:id="viewFrag"><div class="author-avatar"><a wicket:id="authorAvatar"></a></div>@@ -46,7 +45,7 @@<div wicket:id="feedback" class="feedback"></div><textarea wicket:id="content" rows="10" class="form-control focusable"></textarea><div class="actions">- <button wicket:id="save" class="btn btn-sm btn-primary dirty-aware">Save</button>+ <button wicket:id="save" class="btn btn-sm btn-primary"><span wicket:id="label"></span></button><button wicket:id="cancel" class="btn btn-sm btn-default">Cancel</button></div></form>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.javaindex 4577d654e2..663fc3dbce 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentPanel.java@@ -4,6 +4,8 @@ import java.util.ArrayList;import java.util.List;import java.util.concurrent.atomic.AtomicLong;+import javax.annotation.Nullable;+import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;import org.apache.wicket.ajax.markup.html.AjaxLink;@@ -211,7 +213,7 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {WebMarkupContainer commentContainer = newCommentContainer();fragment.replaceWith(commentContainer);target.add(commentContainer);- onSaveComment(target, comment);+ onSaveComment(target);} catch (StaleObjectStateException e) {error("Some one changed the content you are editing. Reload the page and try again.");target.add(feedback);@@ -416,7 +418,7 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {}}- });+ }.add(new Label("label", "Save")));fragment.add(form);fragment.setOutputMarkupId(true);@@ -467,83 +469,7 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {@Overridepublic void onClick(AjaxRequestTarget target) {- Fragment fragment = new Fragment(addReplyContainer.getId(), "replyEditFrag", CodeCommentPanel.this);- Form<?> form = new Form<Void>("form");- CommentInput contentInput = new CommentInput("content", Model.of("")) {-- @Override- protected AttachmentSupport getAttachmentSupport() {- return new DepotAttachmentSupport(getComment().getDepot(), getComment().getUUID());- }-- @Override- protected Depot getDepot() {- return getComment().getDepot();- }-- };- form.add(contentInput);- contentInput.setRequired(true);-- NotificationPanel feedback = new NotificationPanel("feedback", contentInput);- feedback.setOutputMarkupPlaceholderTag(true);- form.add(feedback);-- form.add(new AjaxLink<Void>("cancel") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(form));- }-- @Override- public void onClick(AjaxRequestTarget target) {- WebMarkupContainer addReplyContainer = newAddReplyContainer();- fragment.replaceWith(addReplyContainer);- target.add(addReplyContainer);- }-- });-- form.add(new AjaxButton("save") {-- @Override- protected void onError(AjaxRequestTarget target, Form<?> form) {- super.onError(target, form);- target.add(feedback);- }-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- super.onSubmit(target, form);-- CodeCommentReply reply = new CodeCommentReply();- reply.setComment(getComment());- reply.setUser(SecurityUtils.getAccount());- reply.setContent(contentInput.getModelObject());- reply.setCompareContext(getCompareContext());- GitPlex.getInstance(CodeCommentReplyManager.class).save(reply);-- WebMarkupContainer replyContainer = newReplyContainer(repliesView.newChildId(), reply.getId());- repliesView.add(replyContainer);-- String script = String.format("$('#%s .add-reply').before('<div id=\"%s\"></div>');",- CodeCommentPanel.this.getMarkupId(), replyContainer.getMarkupId());- target.prependJavaScript(script);- target.add(replyContainer);-- WebMarkupContainer addReplyContainer = newAddReplyContainer();- fragment.replaceWith(addReplyContainer);- target.add(addReplyContainer);- }-- });-- fragment.add(form);- fragment.setOutputMarkupId(true);- addReplyContainer.replaceWith(fragment);- target.add(fragment);+ onAddReply(target, false);}});@@ -583,9 +509,120 @@ public abstract class CodeCommentPanel extends GenericPanel<CodeComment> {return GitPlex.getInstance(CodeCommentReplyManager.class).load(replyId);}+ private void onAddReply(AjaxRequestTarget target, boolean toggleResolve) {+ Fragment fragment = new Fragment("addReply", "replyEditFrag", CodeCommentPanel.this);+ Form<?> form = new Form<Void>("form");+ CommentInput contentInput = new CommentInput("content", Model.of("")) {++ @Override+ protected AttachmentSupport getAttachmentSupport() {+ return new DepotAttachmentSupport(getComment().getDepot(), getComment().getUUID());+ }++ @Override+ protected Depot getDepot() {+ return getComment().getDepot();+ }++ };+ contentInput.setRequired(!toggleResolve);+ form.add(contentInput);++ NotificationPanel feedback = new NotificationPanel("feedback", form);+ feedback.setOutputMarkupPlaceholderTag(true);+ form.add(feedback);++ form.add(new AjaxLink<Void>("cancel") {++ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(form));+ }++ @Override+ public void onClick(AjaxRequestTarget target) {+ WebMarkupContainer addReplyContainer = newAddReplyContainer();+ fragment.replaceWith(addReplyContainer);+ target.add(addReplyContainer);+ }++ });++ AjaxButton saveButton = new AjaxButton("save") {++ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ super.onSubmit(target, form);++ if (toggleResolve) {+ String replyContent = contentInput.getModelObject();+ CodeCommentManager manager = GitPlex.getInstance(CodeCommentManager.class);+ if (replyContent != null) {+ CodeCommentReply reply = newReply(replyContent);+ getComment().setResolved(!getComment().isResolved());+ manager.save(getComment(), reply);+ onReplyAdded(target, fragment, reply);+ } else {+ getComment().setResolved(!getComment().isResolved());+ manager.save(getComment());+ onReplyAdded(target, fragment, null);+ }+ onSaveComment(target);+ } else {+ CodeCommentReply reply = newReply(contentInput.getModelObject());+ GitPlex.getInstance(CodeCommentReplyManager.class).save(reply);+ onReplyAdded(target, fragment, reply);+ }+ }++ };+ if (toggleResolve) {+ saveButton.add(new Label("label", getComment().isResolved()?"Confirm unresolve":"Confirm resolve"));+ } else {+ saveButton.add(new Label("label", "Save"));+ saveButton.add(AttributeAppender.append("class", "dirty-aware"));+ }+ form.add(saveButton);++ fragment.add(form);+ fragment.setOutputMarkupId(true);+ get("addReply").replaceWith(fragment);+ target.add(fragment);+ }++ public void onToggleResolve(AjaxRequestTarget target) {+ onAddReply(target, true);+ }++ private void onReplyAdded(AjaxRequestTarget target, Fragment fragment, @Nullable CodeCommentReply reply) {+ if (reply != null) {+ WebMarkupContainer replyContainer = newReplyContainer(repliesView.newChildId(), reply.getId());+ repliesView.add(replyContainer);++ String script = String.format("$('#%s .add-reply').before('<div id=\"%s\"></div>');",+ CodeCommentPanel.this.getMarkupId(), replyContainer.getMarkupId());+ target.prependJavaScript(script);+ target.add(replyContainer);+ }++ WebMarkupContainer addReplyContainer = newAddReplyContainer();+ fragment.replaceWith(addReplyContainer);+ target.add(addReplyContainer);+ }++ private CodeCommentReply newReply(String content) {+ CodeCommentReply reply = new CodeCommentReply();+ reply.setComment(getComment());+ reply.setUser(SecurityUtils.getAccount());+ reply.setContent(content);+ reply.setCompareContext(getCompareContext());+ return reply;+ }+protected abstract void onCommentDeleted(AjaxRequestTarget target);- protected abstract void onSaveComment(AjaxRequestTarget target, CodeComment comment);+ protected abstract void onSaveComment(AjaxRequestTarget target);protected abstract CompareContext getCompareContext();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.htmlindex 0557d7f2f6..2ade79030b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html@@ -3,17 +3,17 @@<div wicket:id="comment" class="comment"><div class="ui-resizable-handle ui-resizable-e"></div><div class="content">- <div class="head">+ <div wicket:id="head" class="head"><div wicket:id="title" class="title"></div><div class="actions clearfix"><a wicket:id="context" class="pull-left context close" title="Show this comment by comparing with specified revision"><i class="fa fa-ext fa-file-diff"></i></a><a wicket:id="permanent" class="pull-left permanent close" title="Permanent link of this comment"><i class="fa fa-link"></i></a><a wicket:id="locate" class="pull-left locate close" title="Locate marked text of this comment"><i class="fa fa-hand-o-right"></i></a><a wicket:id="close" class="pull-left close" title="Hide comment"><i class="fa fa-times"></i></a>- <a wicket:id="resolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a>+ <a wicket:id="toggleResolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a></div></div>- <div wicket:id="body" class="body"></div>+ <div wicket:id="body" class="body scrollable"></div></div></div><div class="code"></div>@@ -24,7 +24,7 @@<span class="pull-left">Outline</span><a wicket:id="close" class="pull-right close" title="Hide outline"><i class="fa fa-times"></i></a></div>- <div wicket:id="body" class="body"></div>+ <div wicket:id="body" class="body scrollable"></div></div></div></div>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.javaindex 24dbf21058..024990bcec 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@@ -14,6 +14,7 @@ import javax.annotation.Nullable;import javax.servlet.http.Cookie;import org.apache.wicket.Component;+import org.apache.wicket.Session;import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;@@ -264,7 +265,11 @@ public class SourceViewPanel extends BlobViewPanel {}};- commentContainer.add(new Label("title", new AbstractReadOnlyModel<String>() {+ WebMarkupContainer head = new WebMarkupContainer("head");+ head.setOutputMarkupId(true);+ commentContainer.add(head);++ head.add(new Label("title", new AbstractReadOnlyModel<String>() {@Overridepublic String getObject() {@@ -281,7 +286,7 @@ public class SourceViewPanel extends BlobViewPanel {}});- commentContainer.add(new DropdownLink("context") {+ head.add(new DropdownLink("context") {@Overrideprotected void onConfigure() {@@ -318,7 +323,7 @@ public class SourceViewPanel extends BlobViewPanel {}});- commentContainer.add(new AjaxLink<Void>("locate") {+ head.add(new AjaxLink<Void>("locate") {@Overridepublic void onClick(AjaxRequestTarget target) {@@ -361,7 +366,7 @@ public class SourceViewPanel extends BlobViewPanel {}});- commentContainer.add(new WebMarkupContainer("permanent") {+ head.add(new WebMarkupContainer("permanent") {@Overrideprotected void onConfigure() {@@ -371,7 +376,7 @@ public class SourceViewPanel extends BlobViewPanel {}.add(appender));- commentContainer.add(new AjaxLink<Void>("close") {+ head.add(new AjaxLink<Void>("close") {@Overrideprotected void updateAjaxAttributes(AjaxRequestAttributes attributes) {@@ -389,14 +394,18 @@ public class SourceViewPanel extends BlobViewPanel {});- commentContainer.add(new AjaxLink<Void>("resolve") {+ head.add(new AjaxLink<Void>("toggleResolve") {+ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(commentContainer));+ }+@Overrideprotected void onConfigure() {super.onConfigure();- CodeComment comment = context.getOpenComment();- setVisible(comment != null);- setEnabled(comment != null && SecurityUtils.canModify(comment));+ setVisible(context.getOpenComment() != null);}@Override@@ -406,10 +415,10 @@ public class SourceViewPanel extends BlobViewPanel {if (comment != null) {if (SecurityUtils.canModify(comment)) {if (comment.isResolved()) {- tag.put("title", "Comment is currently resolved, click to mark as unresolved");+ tag.put("title", "Comment is currently resolved, click to unresolve");tag.put("class", "pull-right resolve resolved");} else {- tag.put("title", "Comment is currently unresolved, click to mark as resolved");+ tag.put("title", "Comment is currently unresolved, click to resolve");tag.put("class", "pull-right resolve unresolved");}} else {@@ -426,14 +435,15 @@ public class SourceViewPanel extends BlobViewPanel {@Overridepublic void onClick(AjaxRequestTarget target) {- CodeComment comment = context.getOpenComment();- comment.setResolved(!comment.isResolved());- GitPlex.getInstance(CodeCommentManager.class).save(comment);- target.add(commentContainer);- target.appendJavaScript("gitplex.sourceview.onLayoutChange();");+ if (SecurityUtils.canModify(context.getOpenComment())) {+ ((CodeCommentPanel)commentContainer.get("body")).onToggleResolve(target);+ target.appendJavaScript("gitplex.sourceview.scrollToCommentBottom();");+ } else {+ Session.get().warn("Only repository manager and comment creator can change status");+ }}- });+ }.setOutputMarkupId(true));commentContainer.setOutputMarkupPlaceholderTag(true);if (context.getOpenComment() != null) {@@ -459,9 +469,8 @@ public class SourceViewPanel extends BlobViewPanel {}@Override- protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {- target.add(commentContainer);- target.appendJavaScript("gitplex.sourceview.onLayoutChange();");+ protected void onSaveComment(AjaxRequestTarget target) {+ target.add(commentContainer.get("head"));}};@@ -595,9 +604,8 @@ public class SourceViewPanel extends BlobViewPanel {}@Override- protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {- target.add(commentContainer);- target.appendJavaScript("gitplex.sourceview.onLayoutChange();");+ protected void onSaveComment(AjaxRequestTarget target) {+ target.add(commentContainer.get("head"));}};@@ -642,9 +650,8 @@ public class SourceViewPanel extends BlobViewPanel {}@Override- protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {- target.add(commentContainer);- target.appendJavaScript("gitplex.sourceview.onLayoutChange();");+ protected void onSaveComment(AjaxRequestTarget target) {+ target.add(commentContainer.get("head"));}};diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.cssindex 3ea1afc427..29f40e7fb4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.css@@ -52,9 +52,11 @@background: #F2F2F2;}.source-view>.comment>.content>.body {- padding: 12px;overflow: auto;}+.source-view>.comment>.content>.body>div {+ margin: 12px;+}.source-view>.outline {background: white;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.jsindex 27abc932c4..3c6da97b1c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js@@ -523,5 +523,9 @@ gitplex.sourceview = {onBlame: function(blameInfos) {gitplex.sourceview.blame(blameInfos);gitplex.sourceview.onLayoutChange();+ },+ scrollToCommentBottom: function() {+ var $body = $(".source-view>.comment>.content>.body");+ $body.scrollTop($body[0].scrollHeight);}}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 68814cf571..e3cf784834 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@@ -44,17 +44,17 @@<div wicket:id="comment" class="comment"><div class="ui-resizable-handle ui-resizable-e"></div><div class="content">- <div class="head">+ <div wicket:id="head" class="head"><div wicket:id="title" class="title"></div><div class="actions clearfix"><a wicket:id="context" class="pull-left context close" title="Show this comment by comparing with specified revision"><i class="fa fa-ext fa-file-diff"></i></a><a wicket:id="permanent" class="pull-left permanent close" title="Permanent link of this comment"><i class="fa fa-link"></i></a><a wicket:id="locate" class="pull-left locate close" title="Locate marked text of this comment"><i class="fa fa-hand-o-right"></i></a><a wicket:id="close" class="pull-left close" title="Hide comment"><i class="fa fa-times"></i></a>- <a wicket:id="resolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a>+ <a wicket:id="toggleResolve" class="pull-right resolve"><i class="fa fa-check-circle"></i></a></div></div>- <div wicket:id="body" class="body"></div>+ <div wicket:id="body" class="body scrollable"></div></div></div><ul class="diffs 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 bd6a67df90..2291c71aed 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@@ -20,6 +20,7 @@ import javax.servlet.http.Cookie;import org.apache.wicket.AttributeModifier;import org.apache.wicket.Component;+import org.apache.wicket.Session;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;import org.apache.wicket.ajax.markup.html.AjaxLink;@@ -743,9 +744,8 @@ public class RevisionDiffPanel extends Panel {}@Override- protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {- target.add(commentContainer);- target.appendJavaScript("gitplex.revisionDiff.reposition();");+ protected void onSaveComment(AjaxRequestTarget target) {+ target.add(commentContainer.get("head"));}};@@ -870,9 +870,8 @@ public class RevisionDiffPanel extends Panel {}@Override- protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {- target.add(commentContainer);- target.appendJavaScript("gitplex.revisionDiff.reposition();");+ protected void onSaveComment(AjaxRequestTarget target) {+ target.add(commentContainer.get("head"));}};@@ -978,7 +977,11 @@ public class RevisionDiffPanel extends Panel {};commentContainer.setOutputMarkupPlaceholderTag(true);- commentContainer.add(new Label("title", new AbstractReadOnlyModel<String>() {+ WebMarkupContainer head = new WebMarkupContainer("head");+ head.setOutputMarkupId(true);+ commentContainer.add(head);++ head.add(new Label("title", new AbstractReadOnlyModel<String>() {@Overridepublic String getObject() {@@ -996,7 +999,7 @@ public class RevisionDiffPanel extends Panel {});- commentContainer.add(new DropdownLink("context") {+ head.add(new DropdownLink("context") {@Overrideprotected void onConfigure() {@@ -1034,7 +1037,7 @@ public class RevisionDiffPanel extends Panel {});- commentContainer.add(new AjaxLink<Void>("locate") {+ head.add(new AjaxLink<Void>("locate") {@Overrideprotected void onInitialize() {@@ -1075,7 +1078,7 @@ public class RevisionDiffPanel extends Panel {});- commentContainer.add(new WebMarkupContainer("permanent") {+ head.add(new WebMarkupContainer("permanent") {@Overrideprotected void onConfigure() {@@ -1085,7 +1088,7 @@ public class RevisionDiffPanel extends Panel {}.add(appender));- commentContainer.add(new AjaxLink<Void>("close") {+ head.add(new AjaxLink<Void>("close") {@Overrideprotected void updateAjaxAttributes(AjaxRequestAttributes attributes) {@@ -1116,14 +1119,18 @@ public class RevisionDiffPanel extends Panel {});- commentContainer.add(new AjaxLink<Void>("resolve") {+ head.add(new AjaxLink<Void>("toggleResolve") {+ @Override+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {+ super.updateAjaxAttributes(attributes);+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(commentContainer));+ }+@Overrideprotected void onConfigure() {super.onConfigure();- CodeComment comment = getOpenComment();- setVisible(comment != null);- setEnabled(comment != null && SecurityUtils.canModify(comment));+ setVisible(getOpenComment() != null);}@Override@@ -1133,18 +1140,18 @@ public class RevisionDiffPanel extends Panel {if (comment != null) {if (SecurityUtils.canModify(comment)) {if (comment.isResolved()) {- tag.put("title", "Comment is currently resolved, click to mark as unresolved");+ tag.put("title", "Comment is currently resolved, click to unresolve");tag.put("class", "pull-right resolve resolved");} else {- tag.put("title", "Comment is currently unresolved, click to mark as resolved");+ tag.put("title", "Comment is currently unresolved, click to resolve");tag.put("class", "pull-right resolve unresolved");}} else {if (comment.isResolved()) {- tag.put("title", "Comment is currently resolved, contact comment owner or repository manager to change status of the comment");+ tag.put("title", "Comment is currently resolved");tag.put("class", "pull-right resolve resolved");} else {- tag.put("title", "Comment is currently unresolved, contact comment owner or repository manager to change status of the comment");+ tag.put("title", "Comment is currently unresolved");tag.put("class", "pull-right resolve unresolved");}}@@ -1153,14 +1160,15 @@ public class RevisionDiffPanel extends Panel {@Overridepublic void onClick(AjaxRequestTarget target) {- CodeComment comment = getOpenComment();- comment.setResolved(!comment.isResolved());- GitPlex.getInstance(CodeCommentManager.class).save(comment);- target.add(commentContainer);- target.appendJavaScript("gitplex.revisionDiff.reposition();");+ if (SecurityUtils.canModify(getOpenComment())) {+ ((CodeCommentPanel)commentContainer.get("body")).onToggleResolve(target);+ target.appendJavaScript("gitplex.revisionDiff.scrollToCommentBottom();");+ } else {+ Session.get().warn("Only repository owner or comment creator can change status");+ }}- });+ }.setOutputMarkupId(true));boolean locatable = false;CodeComment comment = getOpenComment();@@ -1196,9 +1204,8 @@ public class RevisionDiffPanel extends Panel {}@Override- protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {- target.add(commentContainer);- target.appendJavaScript("gitplex.revisionDiff.reposition();");+ protected void onSaveComment(AjaxRequestTarget target) {+ target.add(commentContainer.get("head"));}};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 9ece891519..72a666828c 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@@ -132,8 +132,10 @@margin-bottom: 8px;}.revision-diff>.body>.detail>.comment>.content>.body {- padding: 12px;overflow: auto;border-left: 3px solid #F2F2F2;border-bottom: 3px solid #F2F2F2;}+.revision-diff>.body>.detail>.comment>.content>.body>div {+ margin: 12px;+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.jsindex 0cfe1f6dd0..1f3f85f373 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.js@@ -81,6 +81,15 @@ gitplex.revisionDiff = {}});}+ },+ scrollToCommentBottom: function() {+ var $comment = $(".revision-diff>.body>.detail>.comment");+ if ($(window).scrollTop() < $comment.offset().top)+ $(window).scrollTop($comment.offset().top);+ setTimeout(function() {+ var $body = $comment.find(">.content>.body");+ $body.scrollTop($body[0].scrollHeight);+ }, 0);}}$(function() {