The Unified and Autonomous Development Platform
before pull robin, just some small updates
steve4c6a5e4513b8
diff --git a/gitop.model/src/main/java/com/pmease/gitop/model/CommitComment.java b/gitop.model/src/main/java/com/pmease/gitop/model/CommitComment.javaindex 2e5ba4bcc2..e389d6df78 100644--- a/gitop.model/src/main/java/com/pmease/gitop/model/CommitComment.java+++ b/gitop.model/src/main/java/com/pmease/gitop/model/CommitComment.java@@ -11,6 +11,9 @@ import javax.persistence.ManyToOne;import javax.persistence.Temporal;import javax.persistence.TemporalType;+import org.hibernate.validator.constraints.NotEmpty;++import com.google.common.base.Objects;import com.pmease.commons.hibernate.AbstractEntity;@SuppressWarnings("serial")@@ -48,6 +51,7 @@ public class CommitComment extends AbstractEntity {@Column@Lob+ @NotEmptyprivate String content;public User getAuthor() {@@ -105,4 +109,17 @@ public class CommitComment extends AbstractEntity {public void setContent(String content) {this.content = content;}++ @Override+ public String toString() {+ return Objects.toStringHelper(this)+ .add("id", getId())+ .add("project", getProject())+ .add("commit", commit)+ .add("line", line)+ .add("content", content)+ .add("created", createdDate)+ .add("updatedDate", updatedDate)+ .toString();+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.cssindex 6940cebf83..8ed24eb0bf 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css@@ -4,6 +4,8 @@pre, code { font-family: Consolas, 'Liberation Mono', Courier, monospace; }.alert pre, .alert code { background: white; margin: 5px 0; }+.form-actions { padding: 10px 0; }+/* MENU */.menu-ul { list-style: none; margin: 0; padding: 0; }.menu-item { display: block; padding: 5px 10px; color: #666; }@@ -45,9 +47,7 @@ ul.f-dropdown { padding: 0; }/*** GLOBAL HEADER*/-#globalheader .navbar { border-width: 0 0 1px 0; border-color: #ddd; border-radius: 0; margin: 0;- background: #f0f2f4; color: white;-}+#globalheader .navbar { border-width: 0 0 1px 0; border-color: #ddd; border-radius: 0; margin: 0; background: #f0f2f4; }#globalheader .navbar-brand { padding: 10px 10px 10px 20px; }#globalheader .search-form { margin-top: 12px; margin-bottom: 0;}.search-form input.text-field {@@ -65,10 +65,9 @@ ul.f-dropdown { padding: 0; }#globalheader .tooltip { white-space: nowrap; }#globalheader .navbar-right { margin-right: 20px; }#globalheader .user-links { margin: 0; }-.user-links > li { margin: 0; }-.user-links > li.separator { height: 50px; border-left: 1px solid #d5d5d5; border-right: 1px solid #fefefe; margin: 0 6px;}-.user-links a { padding: 16px 10px 5px; line-height: 20px; }-.user-links a > i { font-size: 16px; }+.user-links > li { margin: 0; height: 52px; line-height: 52px; }+.user-links > li.separator { border-left: 1px solid #d5d5d5; border-right: 1px solid #fefefe; margin: 0 6px;}+.user-links a { padding: 0 10px; }.user-links a:hover { color: #333; text-decoration: none; }.user-links li .caret { border-top-color: #09f; }.user-links li a:hover .caret { border-top-color: #333; }@@ -373,14 +372,20 @@ pre.detailed-message { padding-left: 8px; background: transparent; color: #888;.commitish-list .menu-ul,.committer-list.menu-ul { max-height: 400px; padding: 10px 0; overflow: auto; }-table.files { margin: 0; }-table.files td.file-icon { width: 18px; padding-right: 2px; padding-left: 15px; color: #888; }+table.table-files { margin: 0; }+table.table-files td.file-icon { width: 18px; padding-right: 2px; padding-left: 15px; color: #888; }.commit-meta { color: #999; font-size: 12px; padding: 5px 0; }.commit-meta .name, .commit-meta .name a { color: #333; font-weight: normal; }.commit-meta .committer-info .icon { font-size: 12px; }-.sha { font-family: Consolas, 'Liberation Mono', Courier, monospace; }+.sha, .commitish { font-family: Consolas, 'Liberation Mono', Courier, monospace; }+.panel-sourcetree .last-commit { padding: 0 15px; }+.panel-sourcetree .last-commit .commitish { padding: 5px 0; font-size: 12px; }+.panel-sourcetree .last-commit .commitish a { color: #999; }++.panel-sourcetree .panel-heading { position: relative; padding-right: 90px; }+.panel-sourcetree .panel-heading .history-link { position: absolute; right: 15px; top: 10px; z-index: 10; }/** SOURCE BLOB PAGE@@ -427,6 +432,8 @@ table.table-blob { width: 100%; }.readme > .body { padding: 15px 4px; }.readme .plain pre { background: white; border-width: 0; }+.wiki > *:first-child { margin-top: 0; }+.wiki > *:last-child { margin-bottom: 0; }.wiki pre { }.code-highlight .ace_line { padding-left: 12px; }@@ -474,14 +481,14 @@ table.table-blob { width: 100%; }.commit .commit-head a.sha { border-bottom: 1px dotted #999; }.commit .commit-head a.sha:hover { border-bottom: none; }-.commit .commit-head .avatar { width: 64px; height: 64px; position: absolute; right: 0; top: 0; }-.commit .commit-head .title-message { color: #333; font-size: 16px; font-weight: bold; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }-.commit .author-info, .commit .committer-info { color: #999; margin: 0; }-.commit .author-info .name,-.commit .committer-info .name { font-weight: bold; color: #555; }+.commit .commit-head .author-avatar { position: absolute; right: 0; top: 0; }+.commit-head .author-avatar .avatar { width: 64px; height: 64px; }+.commit .commit-head .title-message { color: #333; font-size: 16px; font-weight: bold; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; margin: 0; }+.commit .author-info .name, .commit .committer-info .name { font-weight: bold; color: #555; }+.commit-head .piped li { border-color: #ddd; }-.commit-head a.inref { margin-right: 6px; color: #555; font-weight: bold;}+.commit-head .in-refs a { margin-right: 6px; color: #555; font-weight: bold;}.commit .commit-message { border-bottom: 1px solid #ddd; margin-bottom: 9px; }.commit .commit-message .detailed-message { display: block; color: #666; border-width: 0 0 0 1px; background: transparent; border-width: 0; padding: 0; font-size: 14px; }@@ -523,11 +530,14 @@ a.diffstat:hover { text-decoration: none; }.table-diff { border-collapse: collapse !important; width: 100%; font-family: Consolas, 'Liberation Mono', Courier, monospace; }.panel-diff .table-diff { margin: 0; }.table-diff td { padding: 0; border: none; white-space: nowrap; font-size: 12px; line-height: 20px; -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4;}+.table-diff tbody>tr:last-child>td:first-child { border-radius: 0 0 0 3px; }+.table-diff tbody>tr:last-child>td:last-child { border-radius: 0 0 3px 0; }+.table-diff tbody + tbody { border: none; }.diff-line .diff-line-code pre { background: transparent; margin: 0; padding: 0; word-break: normal; word-wrap: normal; border: none; font-size: 12px; line-height: 20px; white-space: pre; }.hunk-head .diff-line-code pre { color: #999; }-.diff-line .diff-line-num { text-align: right; border-right: 1px solid #ddd; padding: 0 5px 0 0; width: 70px; color: #999; }+.diff-line .diff-line-num { text-align: right; border-right: 1px solid #ddd; padding: 0 6px 0 12px; width: 1%; color: #999; vertical-align: top; }.diff-line .diff-line-code { padding: 0 10px; }.diff-line-num.expander { text-align: center; }.diff-line-num.expander a { color: #999; display: block; }@@ -535,23 +545,39 @@ a.diffstat:hover { text-decoration: none; }.diff-line-num.expander a:hover { color: #333; text-decoration: none; }.diff-line-num.expander em .icon:before { content: ' '; } /* disabled expander */-tr.diff-line.old { background: #fdd; }-tr.diff-line.new { background: #cfc; }+.table-diff tr.diff-line.old { background: #fdd; }+.table-diff tr.diff-line.new { background: #cfc; }.diff-line.new .diff-line-num { background: #afa; color: #008f00; }.diff-line.old .diff-line-num { background: #faa; color: #8f0000; }.diff-line:hover .diff-line-code, .diff-line.hunk-head:hover .diff-line-code { background: #fea; }.diff-line:hover .diff-line-num { background: #ffe066; }-.diff-line.hunk-head { background: #eef; }-.diff-line .add-comment { position: absolute; left: 0px; width: 20px; height: 20px; margin-left: -20px; opacity: 0.0; filter: alpha(opacity=0); z-index: 10; }.diff-line:hover .add-comment { opacity:1.0; filter: alpha(opacity=1); }.diff-line .add-comment .icon { line-height: 20px; }.diff-line .add-comment:hover { text-decoration: none; }+.table-diff .inline-comment-holder { background: #f1eae0; }+.table-diff .inline-comment-holder td { border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; }+.inline-comment-holder td.comment-count { border-right: 1px solid #ddd; text-align: center; vertical-align: top; padding-top: 10px; }+.inline-comment-holder td.line-comment { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; }+.form-comment { margin-top: 10px; }+.form-comment .head { padding: 0; }+.form-comment .head .nav-tabs { padding-left: 18px; }+.form-comment .body { background: white; padding: 12px; }+.form-comment textarea { display: block; width: 100%; resize: vertical; padding: 10px; min-height: 100px; border-color: #aaa; }++.inline-comment { padding: 0 12px; margin: 10px 0; }+.inline-comment .panel-comment { margin: 0; }+.panel-comment .panel-heading { padding-top: 5px; padding-bottom: 5px; background: #fffcf5; color: #555; }+.panel-comment .panel-heading .left a { color: #333; font-weight: bold;}+.panel-comment .panel-heading .right a { margin-left: 5px; color: #555; }+.panel-comment .panel-heading .right a:hover { color: #09f; text-decoration: none; }++.panel-comment .panel-body { padding: 8px 12px; }.panel-diff .image-diff { padding: 30px; text-align: center; position: relative; background: #999; }.image-diff .btn-group.compares { margin-bottom: 18px; }diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/component/comment/CommentEditor.html b/gitop.web/src/main/java/com/pmease/gitop/web/component/comment/CommentEditor.htmlnew file mode 100644index 0000000000..1d4be0a9b5--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/component/comment/CommentEditor.html@@ -0,0 +1,10 @@+<html xmlns:wicket>+<wicket:panel>+ <form class="comment-editor" wicket:id="form">+ <div class="heading">+ <ul class="nav nav-tabs">+ </ul>+ </div>+ </form>+</wicket:panel>+</html>\ No newline at end of filediff --git a/gitop.web/src/main/java/com/pmease/gitop/web/component/comment/CommentEditor.java b/gitop.web/src/main/java/com/pmease/gitop/web/component/comment/CommentEditor.javanew file mode 100644index 0000000000..8acc7fc6a9--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/component/comment/CommentEditor.java@@ -0,0 +1,19 @@+package com.pmease.gitop.web.component.comment;++import org.apache.wicket.markup.html.panel.Panel;+import org.apache.wicket.model.IModel;++@SuppressWarnings("serial")+public class CommentEditor extends Panel {++ public CommentEditor(String id, IModel<String> textModel) {+ super(id, textModel);+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();+++ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/component/wiki/WikiTextPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/component/wiki/WikiTextPanel.javaindex 5242bd64dc..e78534d3a5 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/component/wiki/WikiTextPanel.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/component/wiki/WikiTextPanel.java@@ -7,6 +7,7 @@ import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;+import org.apache.wicket.model.Model;import com.google.common.base.Strings;import com.google.common.base.Throwables;@@ -18,6 +19,10 @@ public class WikiTextPanel extends Panel {private final IModel<WikiType> langModel;+ public WikiTextPanel(String id, IModel<String> model) {+ this(id, model, Model.of(WikiType.MARKDOWN));+ }+public WikiTextPanel(String id, IModel<String> model, IModel<WikiType> lang) {super(id, model);this.langModel = lang;@@ -62,7 +67,7 @@ public class WikiTextPanel extends Panel {super.renderHead(response);response.render(JavaScriptHeaderItem.forReference(HighlightJsResourceReference.getInstance()));response.render(OnDomReadyHeaderItem.forScript(- ("$('.wiki pre code').each(function(i, e) { hljs.highlightBlock(e)});")));+ ("$('#" + getMarkupId(true) + " .wiki pre code').each(function(i, e) { hljs.highlightBlock(e)});")));}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/model/CommitCommentModel.java b/gitop.web/src/main/java/com/pmease/gitop/web/model/CommitCommentModel.javanew file mode 100644index 0000000000..1fad34b110--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/model/CommitCommentModel.java@@ -0,0 +1,12 @@+package com.pmease.gitop.web.model;++import com.pmease.gitop.model.CommitComment;++public class CommitCommentModel extends EntityModel<CommitComment> {++ private static final long serialVersionUID = 1L;++ public CommitCommentModel(CommitComment entity) {+ super(entity);+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/BasePage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/BasePage.javaindex ad5ac89dfb..5ad0822bb1 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/BasePage.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/BasePage.java@@ -38,7 +38,7 @@ public abstract class BasePage extends WebPage {private WebMarkupContainer body;- private boolean shouldInitialize = true;+// private boolean shouldInitialize = true;// protected Modal modal;@@ -77,7 +77,7 @@ public abstract class BasePage extends WebPage {redirect(ServerInitPage.class);}- shouldInitialize = true;+// shouldInitialize = true;}@Override@@ -133,51 +133,51 @@ public abstract class BasePage extends WebPage {}}- public final void onException(RuntimeException e) {- shouldInitialize = false;- throw e;- }-+// public final void onException(RuntimeException e) {+// shouldInitialize = false;+// throw e;+// }+//public final void redirectWithInterception(final Class<? extends Page> clazz) {- shouldInitialize = true;+// shouldInitialize = true;throw new RestartResponseAtInterceptPageException(clazz);}public final void redirectWithInterception(final Class<? extends Page> clazz, final PageParameters pageParams) {- shouldInitialize = true;+// shouldInitialize = true;throw new RestartResponseAtInterceptPageException(clazz, pageParams);}public final void redirectWithInterception(final Page page) {- shouldInitialize = true;+// shouldInitialize = true;throw new RestartResponseAtInterceptPageException(page);}public final void redirect(final Class<? extends Page> clazz) {- shouldInitialize = false;+// shouldInitialize = false;throw new RestartResponseException(clazz);}public final void redirect(final Class<? extends Page> clazz,PageParameters parameters) {- shouldInitialize = false;+// shouldInitialize = false;throw new RestartResponseException(clazz, parameters);}public final void redirect(final Page page) {- shouldInitialize = false;+// shouldInitialize = false;throw new RestartResponseException(page);}public final void redirect(String url) {- shouldInitialize = false;+// shouldInitialize = false;throw new RedirectToUrlException(url);}public final void redirectToOriginal() {- shouldInitialize = false;+// shouldInitialize = false;continueToOriginalDestination();- shouldInitialize = true;+// shouldInitialize = true;}protected String getPageCssClass() {@@ -226,9 +226,9 @@ public abstract class BasePage extends WebPage {protected final void onInitialize() {super.onInitialize();- if (shouldInitialize) {+// if (shouldInitialize) {onPageInitialize();- }+// }}protected String getPageTitle() {diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.htmlindex 22ed477a47..405da33a6b 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html@@ -4,30 +4,25 @@<div class="commit"><div class="commit-head"><p class="title-message" wicket:id="shortmessage"></p>- <p class="author-info"><wicket:container wicket:id="author"></wicket:container> authored <span class="age" wicket:id="authorday"></span></p>- <wicket:enclosure child="committer">- <p class="committer-info">- <i class="icon icon-arrow-right"></i>- <wicket:container wicket:id="committer"></wicket:container>- committed <span class="age" wicket:id="committerday"></span>- </p>- </wicket:enclosure>+ <wicket:container wicket:id="meta"></wicket:container><ul class="piped"><li><span class="text-muted">commit</span> <span class="sha" wicket:id="commitsha"></span></li>- <li><wicket:container wicket:id="parentslabel"></wicket:container>- <wicket:container wicket:id="parents">- <span wicket:id="connector">+</span>- <a class="sha" wicket:id="link"><span wicket:id="sha"></span></a>- </wicket:container>- </li>+ <li><a wicket:id="treelink">Browse Code →</a></li></ul>+ <p>+ <wicket:container wicket:id="parentslabel"></wicket:container>+ <wicket:container wicket:id="parents">+ <span wicket:id="connector">+</span>+ <a class="sha" wicket:id="link"><span wicket:id="sha"></span></a>+ </wicket:container>+ </p><div class="in-refs"><div wicket:id="branches"></div><div wicket:id="tags"></div></div>- <wicket:container wicket:id="authoravatar"></wicket:container>+ <div class="author-avatar" wicket:id="authoravatar"></div></div><div class="commit-message">diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.javaindex f6bd41a42f..dc8feeb411 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java@@ -1,6 +1,5 @@package com.pmease.gitop.web.page.project.source.commit;-import java.util.Date;import java.util.List;import org.apache.wicket.Component;@@ -19,12 +18,11 @@ import org.apache.wicket.model.Model;import org.apache.wicket.model.PropertyModel;import org.apache.wicket.request.mapper.parameter.PageParameters;-import com.google.common.base.Objects;import com.google.common.collect.Iterables;import com.pmease.commons.git.Commit;import com.pmease.gitop.model.Project;import com.pmease.gitop.web.common.wicket.bootstrap.Icon;-import com.pmease.gitop.web.component.label.AgeLabel;+import com.pmease.gitop.web.component.commit.CommitMetaPanel;import com.pmease.gitop.web.component.link.GitPersonLink;import com.pmease.gitop.web.component.link.GitPersonLink.Mode;import com.pmease.gitop.web.git.GitUtils;@@ -90,45 +88,13 @@ public class SourceCommitPage extends ProjectCategoryPage {}};- add(new GitPersonLink("authoravatar", authorModel, Mode.AVATAR_ONLY));-- add(new GitPersonLink("author", authorModel, Mode.NAME_ONLY));-- add(new AgeLabel("authorday", new AbstractReadOnlyModel<Date>() {-- @Override- public Date getObject() {- return getCommit().getAuthor().getDate();- }- }));-- add(new GitPersonLink("committer", new AbstractReadOnlyModel<GitPerson>() {-- @Override- public GitPerson getObject() {- Commit commit = getCommit();- return GitPerson.of(commit.getCommitter());- }-- }, Mode.NAME_ONLY) {- @Override- protected void onConfigure() {- super.onConfigure();-- setVisibilityAllowed(!Objects.equal(getCommit().getAuthor(),- getCommit().getCommitter()));- }- });+ add(new BookmarkablePageLink<Void>("treelink",+ SourceTreePage.class,+ SourceTreePage.newParams(getProject(), getRevision())));- add(new AgeLabel("committerday", new AbstractReadOnlyModel<Date>() {-- @Override- public Date getObject() {- return getCommit().getCommitter().getDate();- }-- }));+ add(new GitPersonLink("authoravatar", authorModel, Mode.AVATAR_ONLY).enableTooltip("left"));+ add(new CommitMetaPanel("meta", commitModel));add(new Label("commitsha", new PropertyModel<String>(commitModel, "hash")));IModel<List<String>> parentsModel = new AbstractReadOnlyModel<List<String>>() {diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/AddInlineCommentEvent.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/AddInlineCommentEvent.javanew file mode 100644index 0000000000..6439426fc6--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/AddInlineCommentEvent.java@@ -0,0 +1,10 @@+package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;++import org.apache.wicket.ajax.AjaxRequestTarget;++public class AddInlineCommentEvent extends InlineCommentEvent {++ public AddInlineCommentEvent(AjaxRequestTarget target, int position) {+ super(target, position);+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CloseInlineCommentEvent.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CloseInlineCommentEvent.javanew file mode 100644index 0000000000..f1413eda0b--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CloseInlineCommentEvent.java@@ -0,0 +1,10 @@+package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;++import org.apache.wicket.ajax.AjaxRequestTarget;++public class CloseInlineCommentEvent extends InlineCommentEvent {++ public CloseInlineCommentEvent(AjaxRequestTarget target, int position) {+ super(target, position);+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.htmlindex 7567aaae0b..269a4f1ef5 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.html@@ -1,32 +1,26 @@<html xmlns:wicket><wicket:panel>- <form wicket:id="form">- <div class="comment-form-head">- <ul class="nav nav-tab">- <li class="active"><a href="#write-comment">Write</a></li>- <li><a href="#preview-comment">Preview</a></li>+ <form class="form-comment" wicket:id="form">+ <div class="head">+ <ul class="nav nav-tabs">+ <li wicket:id="li"><a wicket:id="link" href="javascript:void(0);)"><span wicket:id="name"></span></a></li></ul></div>- <div class="tab-content">- <div id="write-comment">- <textarea></textarea>+ <div class="body">+ <div wicket:id="tabcontent"></div>+ <div class="form-actions">+ <wicket:container wicket:id="actions"></wicket:container></div>- <div id="preview-comment">- <div class="panel panel-default panel-comment">- <div class="panel-heading">- <span wicket:id="user"></span>- </div>- <div class="panel-body">- here is the preview- </div>- </div>- </div>- </div>-- <div class="form-actions">- <button class="btn btn-gray">Close form</button>- <button class="btn btn-success">Comment on this line</button></div></form>++ <wicket:fragment wicket:id="writefrag">+ <div wicket:id="feedback"></div>+ <textarea class="focusable" placeholder="Leave a comment" wicket:id="input"></textarea>+ </wicket:fragment>++ <wicket:fragment wicket:id="previewfrag">+ here is a comment+ </wicket:fragment></wicket:panel></html>\ No newline at end of filediff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.javaindex 0f4ff3a014..d3d4afb8d2 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentFormPanel.java@@ -1,28 +1,109 @@package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;+import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.markup.html.form.AjaxButton;+import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;+import org.apache.wicket.markup.html.form.TextArea;+import org.apache.wicket.markup.html.list.Loop;+import org.apache.wicket.markup.html.list.LoopItem;+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.Model;-import com.pmease.gitop.core.Gitop;-import com.pmease.gitop.core.manager.UserManager;-import com.pmease.gitop.web.component.link.UserAvatarLink;-import com.pmease.gitop.web.model.UserModel;+import com.google.common.base.CaseFormat;+import com.pmease.gitop.web.common.wicket.form.BaseForm;-public class CommitCommentFormPanel extends Panel {- private static final long serialVersionUID = 1L;+import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;++@SuppressWarnings("serial")+public abstract class CommitCommentFormPanel extends Panel {public CommitCommentFormPanel(String id) {- super(id);+ this(id, Model.of(""));}-++ public CommitCommentFormPanel(String id, IModel<String> textModel) {+ super(id, textModel);+ setOutputMarkupId(true);+ }++ private static enum ViewMode {+ WRITE, PREVIEW+ }++ private ViewMode viewMode = ViewMode.WRITE;+@Overrideprotected void onInitialize() {super.onInitialize();- Form<?> form = new Form<Void>("form");+ final Form<?> form = new BaseForm<Void>("form");add(form);- form.add(new UserAvatarLink("user",- new UserModel(Gitop.getInstance(UserManager.class).getCurrent())));+ Loop tabLinks = new Loop("li", ViewMode.values().length) {++ @Override+ protected void populateItem(LoopItem item) {+ final ViewMode m = ViewMode.values()[item.getIndex()];+ item.add(AttributeAppender.append("class", m == viewMode ? "active" : ""));+ AjaxButton tabLink = new AjaxButton("link", form) {++ @Override+ public void onSubmit(AjaxRequestTarget target, Form<?> form) {+ if (m == viewMode)+ return;++ viewMode = m;+ form.addOrReplace(createContent("tabcontent"));+ target.add(form);+ }++ };++ item.add(tabLink);++ tabLink.add(new Label("name", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, m.name())));+ }++ };++ form.add(tabLinks);++ form.add(createContent("tabcontent"));+ form.add(newSubmitButtons("actions", form));+ }++ abstract protected Component newSubmitButtons(String id, Form<?> form);++ private Component createContent(String id) {+ if (viewMode == ViewMode.WRITE) {+ return createWritePanel(id);+ } else {+ return createPreviewPanel(id);+ }+ }++ @SuppressWarnings("unchecked")+ private Component createWritePanel(String id) {+ Fragment frag = new Fragment(id, "writefrag", this);+ frag.setOutputMarkupId(true);+ frag.add(new NotificationPanel("feedback", frag));+ frag.add(new TextArea<String>("input", (IModel<String>) getDefaultModel()));+ return frag;+ }++ private Component createPreviewPanel(String id) {+ Fragment frag = new Fragment(id, "previewfrag", this);+ frag.setOutputMarkupId(true);+ return frag;+ }++ protected String getComment() {+ return (String) getDefaultModelObject();}+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentPanel.htmlnew file mode 100644index 0000000000..648ecd90f8--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentPanel.html@@ -0,0 +1,27 @@+<html xmlns:wicket>+<wicket:panel>+ <div class="panel panel-default panel-comment">+ <div class="panel-heading">+ <div class="clearfix">+ <div class="left">+ <wicket:container wicket:id="author"></wicket:container>+ <span class="label " wicket:id="authorType"></span>+ </div>+ <div class="right">+ <span wicket:id="age"></span>+ <a wicket:id="editlink"><i class="icon icon-pencil"></i></a>+ <a wicket:id="removelink"><i class="icon icon-delete"></i></a>+ </div>+ </div>+ </div>+ <div class="panel-body">+ <div wicket:id="content"></div>+ </div>+ </div>++ <wicket:fragment wicket:id="submitfrag">+ <button class="btn btn-default" wicket:id="btnCancel">Cancel</button>+ <button class="btn btn-gray" wicket:id="btnUpdate">Update Comment</button>+ </wicket:fragment>+</wicket:panel>+</html>\ No newline at end of filediff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentPanel.javanew file mode 100644index 0000000000..60ac9304a1--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/CommitCommentPanel.java@@ -0,0 +1,176 @@+package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;++import java.util.Date;++import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.ajax.markup.html.form.AjaxButton;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.form.Form;+import org.apache.wicket.markup.html.panel.Fragment;+import org.apache.wicket.markup.html.panel.Panel;+import org.apache.wicket.model.AbstractReadOnlyModel;+import org.apache.wicket.model.IModel;+import org.apache.wicket.model.Model;++import com.google.common.base.Objects;+import com.google.common.base.Strings;+import com.pmease.gitop.core.Gitop;+import com.pmease.gitop.core.manager.CommitCommentManager;+import com.pmease.gitop.core.manager.UserManager;+import com.pmease.gitop.model.CommitComment;+import com.pmease.gitop.model.User;+import com.pmease.gitop.web.common.wicket.component.vex.AjaxConfirmLink;+import com.pmease.gitop.web.component.label.AgeLabel;+import com.pmease.gitop.web.component.link.UserAvatarLink;+import com.pmease.gitop.web.component.wiki.WikiTextPanel;+import com.pmease.gitop.web.model.UserModel;++@SuppressWarnings("serial")+public class CommitCommentPanel extends Panel {++ public CommitCommentPanel(String id, IModel<CommitComment> model) {+ super(id, model);++ this.setOutputMarkupId(true);+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(new UserAvatarLink("author", new UserModel(getCommitComment().getAuthor())));+ add(new WebMarkupContainer("authorType") {++ });++ add(new AgeLabel("age", new AbstractReadOnlyModel<Date>() {++ @Override+ public Date getObject() {+ return getCommitComment().getCreatedDate();+ }++ }).setOutputMarkupId(true));++ add(new AjaxLink<Void>("editlink") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ onEdit(target);+ }++ @Override+ protected void onConfigure() {+ super.onConfigure();++ User current = Gitop.getInstance(UserManager.class).getCurrent();++ if (current == null) {+ setVisibilityAllowed(false);+ } else {+ setVisibilityAllowed(Objects.equal(current, getCommitComment().getAuthor()));+ }+ }+ });++ add(new AjaxConfirmLink<Void>("removelink", Model.of("Are you sure you want to delete this comment?")) {++ @Override+ public void onClick(AjaxRequestTarget target) {+ onDelete(target);+ }++ @Override+ protected void onConfigure() {+ super.onConfigure();++ User current = Gitop.getInstance(UserManager.class).getCurrent();+ if (current == null) {+ setVisibilityAllowed(false);+ } else {+ setVisibilityAllowed(Objects.equal(current, getCommitComment().getAuthor())+ || current.isAdmin());+ }+ }+ });++ add(newCommentLabel());+ }++ private Component newCommentLabel() {+ return new WikiTextPanel("content", new AbstractReadOnlyModel<String>() {++ @Override+ public String getObject() {+ return getCommitComment().getContent();+ }++ }).setOutputMarkupId(true);+ }++ protected void onEdit(AjaxRequestTarget target) {+ Component c = new CommitCommentFormPanel("content", Model.of(getCommitComment().getContent())) {++ @Override+ protected Component newSubmitButtons(String id, Form<?> form) {+ Fragment frag = new Fragment(id, "submitfrag", CommitCommentPanel.this);+ frag.add(new AjaxLink<Void>("btnCancel") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ updateCommentLabel(target);+ }+ });++ frag.add(new AjaxButton("btnUpdate", form) {++ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ String comment = getComment();+ if (Strings.isNullOrEmpty(comment)) {+ form.error("Comment can not be empty");+ target.add(form);+ return;+ }++ CommitComment cc = getCommitComment();+ cc.setUpdatedDate(new Date());+ cc.setContent(comment);++ Gitop.getInstance(CommitCommentManager.class).save(cc);+ updateCommentLabel(target);+// updateAgeLabel(target);+ }+ });++ return frag;+ }++ private void updateCommentLabel(AjaxRequestTarget target) {+ Component label = newCommentLabel();+ CommitCommentPanel.this.addOrReplace(label);+ target.add(label);+ }+ };++ c.setOutputMarkupId(true);+ addOrReplace(c);+ target.add(c);+ }++// private void updateAgeLabel(AjaxRequestTarget target) {+// Component ageLabel = get("age");+// target.add(ageLabel);+// target.appendJavaScript(JQuery.$(ageLabel).chain("tooltip").get());+// }++ protected void onDelete(AjaxRequestTarget target) {++ }++ private CommitComment getCommitComment() {+ return (CommitComment) getDefaultModelObject();+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/ExpandContextEvent.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/ExpandContextEvent.javanew file mode 100644index 0000000000..b373c32e30--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/ExpandContextEvent.java@@ -0,0 +1,24 @@+package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;++import org.apache.wicket.ajax.AjaxRequestTarget;++import com.pmease.gitop.web.common.wicket.event.AjaxEvent;++public class ExpandContextEvent extends AjaxEvent {++ public static enum Direction {+ ABOVE, BELOW+ }++ private final Direction direction;++ public ExpandContextEvent(AjaxRequestTarget target, Direction direction) {+ super(target);+ this.direction = direction;+ }++ public Direction getDirection() {+ return direction;+ }++}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.htmlindex 9770600149..6780acd6ce 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.html@@ -31,19 +31,26 @@</td></wicket:fragment>- <wicket:fragment wicket:id="inlinecommentfrag">+ <wicket:fragment wicket:id="commentfrag"><td class="comment-count" colspan="2"><i class="icon icon-comment"></i> <b wicket:id="count"></b></td>+<td class="line-comment"><div wicket:id="commentsholder"><div class="inline-comment" wicket:id="comments"><div wicket:id="comment"></div></div></div>- <wicket:container wicket:id="commentform">- </wicket:container>++ <div wicket:id="commentform"></div></td></wicket:fragment>++ <wicket:fragment wicket:id="commentformsubmitsfrag">+ <button class="btn btn-gray" wicket:id="close">Close form</button>+ <button class="btn btn-success btn-submit" wicket:id="comment">Comment on this line</button>+ </wicket:fragment>+</wicket:panel></html>\ No newline at end of filediff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.javaindex a19a5b3e33..fa75333801 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/HunkPanel.java@@ -1,15 +1,18 @@package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;-import java.util.Collection;+import java.util.Collections;import java.util.List;-import org.apache.commons.lang3.StringUtils;import org.apache.wicket.Component;import org.apache.wicket.ajax.AjaxRequestTarget;import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.ajax.markup.html.form.AjaxButton;import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.event.Broadcast;+import org.apache.wicket.event.IEvent;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.list.Loop;import org.apache.wicket.markup.html.list.LoopItem;import org.apache.wicket.markup.html.panel.Fragment;@@ -19,16 +22,22 @@ 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 org.apache.wicket.util.iterator.ComponentHierarchyIterator;import org.eclipse.jgit.diff.DiffEntry.ChangeType;+import org.parboiled.common.Preconditions;import com.google.common.base.Strings;import com.google.common.collect.Iterables;import com.google.common.collect.LinkedListMultimap;+import com.google.common.collect.Lists;import com.google.common.collect.Multimap;import com.pmease.gitop.core.Gitop;import com.pmease.gitop.core.manager.CommitCommentManager;+import com.pmease.gitop.core.manager.UserManager;import com.pmease.gitop.model.CommitComment;+import com.pmease.gitop.model.Project;import com.pmease.gitop.web.Constants;+import com.pmease.gitop.web.model.CommitCommentModel;import com.pmease.gitop.web.page.project.source.commit.diff.patch.FileHeader;import com.pmease.gitop.web.page.project.source.commit.diff.patch.HunkHeader;import com.pmease.gitop.web.page.project.source.commit.diff.patch.HunkLine;@@ -37,8 +46,10 @@ import com.pmease.gitop.web.page.project.source.commit.diff.patch.HunkLine.LineT@SuppressWarnings("serial")public class HunkPanel extends Panel {+ private final IModel<Project> projectModel;private final IModel<FileHeader> fileModel;private final IModel<List<String>> blobLinesModel;+ private final IModel<String> commitModel;private RepeatingView linesView;@@ -51,7 +62,9 @@ public class HunkPanel extends Panel {final static String INSERT_ROW_TEMPLATE = "var item = document.createElement('tr'); item.id='%s'; $(item).insertAfter($('#%s'));";- public HunkPanel(String id,+ public HunkPanel(String id,+ IModel<Project> projectModel,+ IModel<String> commitModel,IModel<Integer> indexModel,IModel<FileHeader> fileModel,IModel<List<String>> blobLinesModel,@@ -59,6 +72,8 @@ public class HunkPanel extends Panel {super(id, indexModel);+ this.projectModel = projectModel;+ this.commitModel = commitModel;this.fileModel = fileModel;this.blobLinesModel = blobLinesModel;this.commentsModel = new LoadableDetachableModel<Multimap<String, Long>>() {@@ -68,10 +83,10 @@ public class HunkPanel extends Panel {List<CommitComment> comments = commentsModel.getObject();Multimap<String, Long> map = LinkedListMultimap.<String, Long>create();- String pathId = getPathId();+ String fileId = getFileId();for (CommitComment each : comments) {String line = each.getLine();- if (!Strings.isNullOrEmpty(line) && line.startsWith(pathId)) {+ if (!Strings.isNullOrEmpty(line) && line.startsWith(fileId)) {map.put(line, each.getId());}}@@ -81,173 +96,54 @@ public class HunkPanel extends Panel {};}- private String getPathId() {+ private String getFileId() {FileHeader file = getFile();- String path;if (file.getChangeType() == ChangeType.DELETE) {- path = file.getOldPath();+ return file.getOldId().name();} else {- path = file.getNewPath();+ return file.getNewId().name();}-- return StringUtils.replace(StringUtils.replace(path, "/", "-"), ".", "-");}- @Override- protected void onInitialize() {- super.onInitialize();-- add(createHunkLines());- add(createAboveExpander());- add(createBelowExpander());- }-- private Multimap<String, Long> getInlineComments() {- return commentsModel.getObject();+ private String getLineId(int position) {+ return getFileId() + "-L" + position;}- private Component createHunkLines() {- linesView = new RepeatingView("hunklines");- List<HunkLine> lines = getCurrentHunk().getLines();-- Multimap<String, Long> inlineComments = getInlineComments();-- for (int i = 0; i < lines.size(); i++) {- HunkLine line = lines.get(i);- Component item = newLineRow(linesView.newChildId(), line, i + 1, true);- linesView.add(item);-- String lineId = item.getMarkupId();- if (inlineComments.containsKey(lineId)) {- // create inline comment block- createInlineCommentBlock(i+1, false);- }-- if (i == lines.size() - 1) {- belowMarkupId = item.getMarkupId();+ /*+ static String toPathId(String original) {+ StringBuffer sb = new StringBuffer();+ for (int i = 0; i < original.length(); i++) {+ char c = original.charAt(i);+ if (CharMatcher.JAVA_LETTER_OR_DIGIT.matches(c)) {+ sb.append(c);+ } else {+ sb.append('-');}}- if (!lines.isEmpty()) {- HunkLine line = Iterables.getFirst(lines, null);- startLine = line.getNewLineNo();- line = Iterables.getLast(lines);- endLine = line.getNewLineNo();- }-- return linesView;+ return sb.toString();}- int getPreviousTotalLines() {- int lines = 0;- for (int i = 0; i < getHunkIndex(); i++) {- lines += getHunk(i).getLines().size();- }-- return lines;- }-- private Component createInlineCommentBlock(int position, boolean showForm) {- String markupId = getPathId() + "-C" + getHunkIndex() + "-" + position;- WebMarkupContainer item = new WebMarkupContainer(linesView.newChildId());- item.setMarkupId(markupId);- item.add(AttributeAppender.append("class", Model.of("inline-comment-holder")));-- Fragment frag = new Fragment("line", "inlinecommentfrag", this);- Multimap<String, Long> map = getInlineComments();- final Collection<Long> ids = map.get(markupId);- frag.add(new Label("count", ids.size()));-- WebMarkupContainer commentsHolder = new WebMarkupContainer("commentsholder");- frag.add(commentsHolder);-- Loop commentsView = new Loop("comments", ids.size()) {-- @Override- protected void populateItem(LoopItem item) {- int index = item.getIndex();- Long id = Iterables.get(ids, index);- CommitComment comment = Gitop.getInstance(CommitCommentManager.class).get(id);- item.add(new Label("comment", comment.getContent()));- }- };- commentsHolder.add(commentsView);-- if (showForm) {- frag.add(new CommitCommentFormPanel("commentform"));- } else {- frag.add(new WebMarkupContainer("commentform"));- }-- return item;- }-- private Component newLineRow(String id, HunkLine line, final int position, boolean original) {- final WebMarkupContainer item = new WebMarkupContainer(id);- String markupId = getPathId() + "-P" + getHunkIndex() + "-" + position;- if (original) {- item.setMarkupId(markupId);- }-- item.add(AttributeAppender.append("class", "diff-line " + line.getLineType().name().toLowerCase()));- Fragment frag = new Fragment("line", "linefrag", this);- item.add(frag);- String oldLineNo, newLineNo;- if (line.getLineType() == LineType.CONTEXT) {- oldLineNo = String.valueOf(line.getOldLineNo());- newLineNo = String.valueOf(line.getNewLineNo());- } else if (line.getLineType() == LineType.OLD) {- oldLineNo = "- " + line.getOldLineNo();- newLineNo = " ";- } else {- oldLineNo = " ";- newLineNo = "+ " + line.getNewLineNo();- }-- frag.add(new Label("oldnum", oldLineNo).setEscapeModelStrings(false));- frag.add(new Label("newnum", newLineNo).setEscapeModelStrings(false));- frag.add(new Label("code", Model.of(line.getText())));- if (Strings.isNullOrEmpty(markupId)) {- frag.add(new WebMarkupContainer("commentlink").setVisibilityAllowed(false));+ private String getPathId() {+ FileHeader file = getFile();+ String path;+ if (file.getChangeType() == ChangeType.DELETE) {+ path = file.getOldPath();} else {- frag.add(new AjaxLink<Void>("commentlink") {-- @Override- public void onClick(AjaxRequestTarget target) {- String markupId = getPathId() + "-C" + getHunkIndex() + "-" + position;- WebMarkupContainer holder = (WebMarkupContainer) linesView.get(markupId);- Component c = null;- if (holder != null) {- c = holder.get("commitform");- }-- if (c != null) {- return;- }-- Component commentRow = newLineCommentRow(markupId);- commentRow.setMarkupId(markupId);- commentRow.setOutputMarkupId(true);- target.prependJavaScript(- String.format(INSERT_ROW_TEMPLATE,- commentRow.getMarkupId(true),- item.getMarkupId()));-- linesView.addOrReplace(commentRow);- target.add(commentRow);- }- });+ path = file.getNewPath();}- return item;+ return toPathId(path);}+ */- private Component newLineCommentRow(String id) {- WebMarkupContainer item = new WebMarkupContainer(id);- item.add(AttributeAppender.append("class", "inline-comments"));- Fragment frag = new Fragment("line", "inlinecommentfrag", this);- item.add(frag);- return item;+ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(createAboveExpander());+ add(createHunkLines());+ add(createBelowExpander());}private Component createAboveExpander() {@@ -308,15 +204,14 @@ public class HunkPanel extends Panel {@Overrideprotected void onConfigure() {super.onConfigure();-setVisibilityAllowed(isAboveExpandable());}- }).setOutputMarkupId(true);+ }.setOutputMarkupId(true));return aboveExpander;}- private int expandTo() {+ private int expandAboveTo() {int start = Math.max(startLine - 20, 1);HunkHeader previous = getPreviousHunk();if (previous != null) {@@ -328,7 +223,7 @@ public class HunkPanel extends Panel {}private void expandAbove(AjaxRequestTarget target) {- int newStart = expandTo();+ int newStart = expandAboveTo();if (newStart == startLine) {return;}@@ -355,22 +250,27 @@ public class HunkPanel extends Panel {.build();String markupId = linesView.newChildId();- Component item = newLineRow(markupId, line, 0, false);+ Component item = newLineRow(markupId, line, -1);item.setOutputMarkupId(true);- target.prependJavaScript(- String.format(INSERT_ROW_TEMPLATE,- item.getMarkupId(true), aboveMarkupId));++ insertRow(target, item.getMarkupId(), aboveMarkupId);+// target.prependJavaScript(+// String.format(INSERT_ROW_TEMPLATE,+// item.getMarkupId(true), aboveMarkupId));linesView.addOrReplace(item);target.add(item);oldStart++;aboveMarkupId = item.getMarkupId();-// oldLineNo--;}startLine = newStart;}+ private void insertRow(AjaxRequestTarget target, String markupId, String afterId) {+ target.prependJavaScript(String.format(INSERT_ROW_TEMPLATE, markupId, afterId));+ }+private boolean isAboveExpandable() {if (startLine == 1 || startLine < 0) {return false;@@ -384,6 +284,325 @@ public class HunkPanel extends Panel {return startLine > previous.getNewEndLine() + 1;}+ private Multimap<String, Long> getInlineComments() {+ return commentsModel.getObject();+ }++ @Override+ public void onEvent(IEvent<?> event) {+ if (event.getPayload() instanceof AddInlineCommentEvent) {+ AddInlineCommentEvent e = (AddInlineCommentEvent) event.getPayload();+ int position = e.getPosition();+ CommentRow commentRow = findCommentRow(position);++ if (commentRow == null) {+ // insert a comment row+ Component row = newCommentRow(position, true);+ Component lineRow = findLineRow(position);+ insertRow(e.getTarget(), row.getMarkupId(), lineRow.getParent().getMarkupId());+ linesView.addOrReplace(row);+ e.getTarget().add(row);+ }+ }+ }++ private LineRow findLineRow(int position) {+ ComponentHierarchyIterator it = linesView.visitChildren(LineRow.class);+ LineRow row = null;+ while (it.hasNext()) {+ LineRow each = (LineRow) it.next();+ if (each.position == position) {+ row = each;+ break;+ }+ }++ Preconditions.checkState(row != null, "line row " + position + " doesn't exist");+ return row;+ }++ private CommentRow findCommentRow(int position) {+ ComponentHierarchyIterator it = linesView.visitChildren(CommentRow.class);+ CommentRow row = null;+ while (it.hasNext()) {+ CommentRow each = (CommentRow) it.next();+ if (each.position == position) {+ row = each;+ break;+ }+ }++ return row;+ }++ private Component createHunkLines() {+ linesView = new RepeatingView("hunklines");++ List<HunkLine> lines = getCurrentHunk().getLines();++ Multimap<String, Long> inlineComments = getInlineComments();++ for (int i = 0; i < lines.size(); i++) {+ HunkLine line = lines.get(i);+ Component item = newLineRow(linesView.newChildId(), line, i + 1);+ linesView.add(item);++ String lineId = getLineId(i + 1);+ if (inlineComments.containsKey(lineId)) {+ // create inline comment block+ linesView.add(newCommentRow(i+1, false));+ }++ if (i == lines.size() - 1) {+ belowMarkupId = item.getMarkupId();+ }+ }++ if (!lines.isEmpty()) {+ HunkLine line = Iterables.getFirst(lines, null);+ startLine = line.getNewLineNo();+ line = Iterables.getLast(lines);+ endLine = line.getNewLineNo();+ }++ return linesView;+ }++ int getPreviousTotalLines() {+ int lines = 0;+ for (int i = 0; i < getHunkIndex(); i++) {+ lines += getHunk(i).getLines().size();+ }++ return lines;+ }++ private WebMarkupContainer newCommentForm(final int position) {+ return new CommitCommentFormPanel("commentform") {++ @Override+ protected Component newSubmitButtons(String id, final Form<?> form) {+ Fragment frag = new Fragment(id, "commentformsubmitsfrag", HunkPanel.this);+ frag.add(new AjaxLink<Void>("close") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ send(HunkPanel.this, Broadcast.DEPTH, new CloseInlineCommentEvent(target, position));+ }+ });++ AjaxButton submit = new AjaxButton("comment", form) {+ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ String lineId = getLineId(position);+ CommitComment comment = new CommitComment();+ comment.setAuthor(Gitop.getInstance(UserManager.class).getCurrent());+ comment.setCommit(commitModel.getObject());+ comment.setLine(lineId);+ comment.setProject(projectModel.getObject());+ comment.setContent(getComment());+ Gitop.getInstance(CommitCommentManager.class).save(comment);++ send(HunkPanel.this, Broadcast.DEPTH, new InlineCommentAddedEvent(target, position, comment.getId()));+ }+ };++ frag.add(submit);+ form.setDefaultButton(submit);++ return frag;+ }+ };+ }++ private class LineRow extends Fragment {++ private final int position;++ public LineRow(String id, IModel<HunkLine> model, int position) {+ super(id, "linefrag", HunkPanel.this, model);++ this.position = position;+ }++ private HunkLine getLine() {+ return (HunkLine) getDefaultModelObject();+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ HunkLine line = getLine();+ String oldLineNo, newLineNo;+ if (line.getLineType() == LineType.CONTEXT) {+ oldLineNo = String.valueOf(line.getOldLineNo());+ newLineNo = String.valueOf(line.getNewLineNo());+ } else if (line.getLineType() == LineType.OLD) {+ oldLineNo = "- " + line.getOldLineNo();+ newLineNo = " ";+ } else {+ oldLineNo = " ";+ newLineNo = "+ " + line.getNewLineNo();+ }++ add(new Label("oldnum", oldLineNo).setEscapeModelStrings(false));+ add(new Label("newnum", newLineNo).setEscapeModelStrings(false));+ add(new Label("code", Model.of(line.getText())));++ if (position < 0) {+ add(new WebMarkupContainer("commentlink").setVisibilityAllowed(false));+ } else {+ add(new AjaxLink<Void>("commentlink") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ send(HunkPanel.this, Broadcast.BREADTH, new AddInlineCommentEvent(target, position));+ }+ });+ }+ }+ }++ /**+ * Create a hunk line row, the row including old line number, new line number+ * and line code, the line can be one of OLD, NEW or CONTEXT+ *+ * @param id+ * @param line+ * @param position+ * @return+ */+ private Component newLineRow(String id, HunkLine line, final int position) {+ WebMarkupContainer item = new WebMarkupContainer(id);+ item.setOutputMarkupId(true);+ item.add(AttributeAppender.append("class", "diff-line " + line.getLineType().name().toLowerCase()));+ item.add(new LineRow("line", Model.of(line), position));+ return item;+ }++ private class CommentRow extends Fragment {++ final int position;+ boolean withForm;++ WebMarkupContainer commentForm;+ WebMarkupContainer commentsHolder;++ public CommentRow(String id, int position, boolean withForm) {+ super(id, "commentfrag", HunkPanel.this);++ this.position = position;+ this.withForm = withForm;+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ IModel<Integer> sizeModel = new AbstractReadOnlyModel<Integer>() {++ @Override+ public Integer getObject() {+ return getCommentIds().size();+ }+ };++ add(new Label("count", sizeModel).setOutputMarkupId(true));++ commentsHolder = new WebMarkupContainer("commentsholder");+ commentsHolder.setOutputMarkupId(true);+ add(commentsHolder);++ Loop commentsView = new Loop("comments", sizeModel) {++ @Override+ protected void populateItem(LoopItem item) {+ int index = item.getIndex();+ CommitComment comment = getComment(index);+ item.add(new CommitCommentPanel("comment", new CommitCommentModel(comment)));+ }+ };++ commentsHolder.add(commentsView);+ if (withForm) {+ commentForm = newCommentForm(position);+ } else {+ commentForm = newEmptyForm();+ }++ add(commentForm);+ }++ private WebMarkupContainer newEmptyForm() {+ WebMarkupContainer commentForm = new WebMarkupContainer("commentform");+ commentForm.setOutputMarkupId(true);+ return commentForm;+ }++ private CommitComment getComment(int index) {+ Long id = Iterables.get(getCommentIds(), index);+ return Gitop.getInstance(CommitCommentManager.class).get(id);+ }++ private List<Long> getCommentIds() {+ Multimap<String, Long> map = getInlineComments();+ final String lineId = getLineId(position);+ List<Long> ids = Lists.newArrayList(map.get(lineId));+ Collections.sort(ids);+ return ids;+ }++ @Override+ public void onEvent(IEvent<?> sink) {+ if (sink.getPayload() instanceof InlineCommentEvent) {+ InlineCommentEvent e = (InlineCommentEvent) sink.getPayload();+ if (e.getPosition() != position) {+ return;+ }++ if (e instanceof CloseInlineCommentEvent) {+ List<Long> ids = getCommentIds();+ if (ids.isEmpty()) {+ // remove the whole row+ Component parent = getParent();+ linesView.remove(parent);+ e.getTarget().appendJavaScript("$('#" + parent.getMarkupId() + "').remove()");+ } else {+ // only hide comment form+ commentForm = newEmptyForm();+ addOrReplace(commentForm);+ e.getTarget().add(commentForm);+ }+ } else if (e instanceof AddInlineCommentEvent) {+ if (commentForm instanceof CommitCommentFormPanel) {+ // form maybe hidden+ e.getTarget().appendJavaScript("$('#" + commentForm.getMarkupId(true) + "').show()");+ } else {+ commentForm = newCommentForm(position);+ addOrReplace(commentForm);+ e.getTarget().add(commentForm);+ }+ } else if (e instanceof InlineCommentAddedEvent) {+ e.getTarget().add(get("count"));+ e.getTarget().add(commentsHolder);+ commentForm = newEmptyForm();+ addOrReplace(commentForm);+ e.getTarget().add(commentForm);+ }+ }+ }+ }++ private Component newCommentRow(int position, boolean withForm) {+ WebMarkupContainer item = new WebMarkupContainer(linesView.newChildId());+ item.setOutputMarkupId(true);+ item.add(AttributeAppender.append("class", "inline-comment-holder"));+ item.add(new CommentRow("line", position, withForm));++ return item;+ }+private Component createBelowExpander() {WebMarkupContainer expanderTr = new WebMarkupContainer("belowexpander") {@Override@@ -434,12 +653,9 @@ public class HunkPanel extends Panel {.lineType(LineType.CONTEXT).build();- Component item = newLineRow(linesView.newChildId(), line, 0, false);+ Component item = newLineRow(linesView.newChildId(), line, -1);item.setOutputMarkupId(true);- target.prependJavaScript(- String.format(INSERT_ROW_TEMPLATE,- item.getMarkupId(true), belowMarkupId));-+ insertRow(target, item.getMarkupId(), belowMarkupId);linesView.addOrReplace(item);target.add(item);oldLineNo++;@@ -492,6 +708,14 @@ public class HunkPanel extends Panel {@Overridepublic void onDetach() {+ if (projectModel != null) {+ projectModel.detach();+ }++ if (commitModel != null) {+ commitModel.detach();+ }+if (fileModel != null) {fileModel.detach();}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/InlineCommentAddedEvent.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/InlineCommentAddedEvent.javanew file mode 100644index 0000000000..342219ad9b--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/InlineCommentAddedEvent.java@@ -0,0 +1,18 @@+package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;++import org.apache.wicket.ajax.AjaxRequestTarget;++public class InlineCommentAddedEvent extends InlineCommentEvent {++ private final Long commentId;++ public InlineCommentAddedEvent(AjaxRequestTarget target, int position, Long commentId) {+ super(target, position);++ this.commentId = commentId;+ }++ public Long getCommentId() {+ return commentId;+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/InlineCommentEvent.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/InlineCommentEvent.javanew file mode 100644index 0000000000..be6966c442--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/InlineCommentEvent.java@@ -0,0 +1,21 @@+package com.pmease.gitop.web.page.project.source.commit.diff.renderer.text;++import org.apache.wicket.ajax.AjaxRequestTarget;++import com.pmease.gitop.web.common.wicket.event.AjaxEvent;++public class InlineCommentEvent extends AjaxEvent {++ private final int position;++ public InlineCommentEvent(AjaxRequestTarget target, int position) {+ super(target);++ this.position = position;+ }++ public int getPosition() {+ return position;+ }++}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/TextDiffTable.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/TextDiffTable.javaindex aecc208e0d..88bf338853 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/TextDiffTable.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/renderer/text/TextDiffTable.java@@ -78,7 +78,8 @@ public class TextDiffTable extends Panel {@Overrideprotected void populateItem(ListItem<HunkHeader> item) {- item.add(new HunkPanel("hunk",+ item.add(new HunkPanel("hunk",+ projectModel, untilModel,Model.of(item.getIndex()),fileModel,new LoadableDetachableModel<List<String>>() {diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.htmlindex faf69c1dbc..6f92419648 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.html@@ -3,16 +3,17 @@<div class="panel panel-default panel-sourcetree"><div class="panel-heading panel-message"><wicket:container wicket:id="message"></wicket:container>+ <a class="history-link" wicket:id="history"><i class="icon icon-history"></i> History</a></div><div class="panel-body"><div class="last-commit clearfix">- <div wicket:id="meta"></div>- <div class="commitish">+ <div class="left" wicket:id="meta"></div>+ <div class="commitish right"><a wicket:id="commitlink">latest commit <span wicket:id="sha" class="sha"></span></a></div></div>- <table class="table files">+ <table class="table table-files"><wicket:enclosure><tr><td class="file-icon"><i class="icon icon-back"></i></td>diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.javaindex ae3f24e378..26d391bfcb 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/tree/SourceTreePanel.java@@ -32,6 +32,7 @@ import com.pmease.gitop.web.git.GitUtils;import com.pmease.gitop.web.page.PageSpec;import com.pmease.gitop.web.page.project.source.blob.SourceBlobPage;import com.pmease.gitop.web.page.project.source.commit.SourceCommitPage;+import com.pmease.gitop.web.page.project.source.commits.CommitsPage;import com.pmease.gitop.web.page.project.source.component.AbstractSourcePagePanel;@SuppressWarnings("serial")@@ -73,6 +74,12 @@ public class SourceTreePanel extends AbstractSourcePagePanel {add(new CommitMessagePanel("message", lastCommitModel, projectModel));add(new CommitMetaPanel("meta", lastCommitModel));+ BookmarkablePageLink<Void> historyLink = new BookmarkablePageLink<Void>(+ "history",+ CommitsPage.class,+ CommitsPage.newParams(getProject(), getRevision(), 0));++ add(historyLink);BookmarkablePageLink<Void> commitLink = new BookmarkablePageLink<Void>("commitlink",SourceCommitPage.class,