The Unified and Autonomous Development Platform
Add copy to clipboard feature for commit hash and clone url
robin shine130eb77a8489
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/clipboard/ClipboardResourceReference.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/clipboard/ClipboardResourceReference.javanew file mode 100644index 0000000000..3bc38a9390--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/clipboard/ClipboardResourceReference.java@@ -0,0 +1,13 @@+package com.pmease.commons.wicket.assets.clipboard;++import org.apache.wicket.request.resource.JavaScriptResourceReference;++public class ClipboardResourceReference extends JavaScriptResourceReference {++ private static final long serialVersionUID = 1L;++ public ClipboardResourceReference() {+ super(ClipboardResourceReference.class, "clipboard.min.js");+ }++}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/clipboard/clipboard.min.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/clipboard/clipboard.min.jsnew file mode 100644index 0000000000..580433f1d8--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/clipboard/clipboard.min.js@@ -0,0 +1,7 @@+/*!+ * clipboard.js v1.5.12+ * https://zenorocha.github.io/clipboard.js+ *+ * Licensed MIT © Zeno Rocha+ */+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t,e,n){var o=t("matches-selector");e.exports=function(t,e,n){for(var i=n?t:t.parentNode;i&&i!==document;){if(o(i,e))return i;i=i.parentNode}}},{"matches-selector":5}],2:[function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e,!0),n.delegateTarget&&o.call(t,n)}}var r=t("closest");e.exports=o},{closest:1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return i(t,e,n);if(c.nodeList(t))return r(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return s(document.body,t,e,n)}var c=t("./is"),s=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t,e){if(r)return r.call(t,e);for(var n=t.parentNode.querySelectorAll(e),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var i=Element.prototype,r=i.matchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector;e.exports=o},{}],6:[function(t,e,n){function o(t){var e;if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)t.focus(),t.setSelectionRange(0,t.value.length),e=t.value;else{t.hasAttribute("contenteditable")&&t.focus();var n=window.getSelection(),o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o),e=n.toString()}return e}e.exports=o},{}],7:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;i>o;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;a>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function t(){this.text?this.selectFake():this.target&&this.selectTarget()},t.prototype.selectFake=function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()},t.prototype.removeFake=function t(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function t(){this.selectedText=(0,i.default)(this.target),this.copyText()},t.prototype.copyText=function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function t(){this.removeFake()},a(t,[{key:"action",set:function t(){var e=arguments.length<=0||void 0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==("undefined"==typeof e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=c})},{select:6}],9:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var l=i(e),u=i(n),f=i(o),d=function(t){function e(n,o){r(this,e);var i=a(this,t.call(this));return i.resolveOptions(o),i.listenClick(n),i}return c(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.listenClick=function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})},e.prototype.onClick=function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})},e.prototype.defaultAction=function t(e){return s("action",e)},e.prototype.defaultTarget=function t(e){var n=s("target",e);return n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return s("text",e)},e.prototype.destroy=function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(u.default);t.exports=d})},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)});\ No newline at end of filediff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/CopyClipboardBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/CopyClipboardBehavior.javanew file mode 100644index 0000000000..e156b67c30--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/CopyClipboardBehavior.java@@ -0,0 +1,36 @@+package com.pmease.commons.wicket.behavior.clipboard;++import org.apache.wicket.Component;+import org.apache.wicket.behavior.Behavior;+import org.apache.wicket.markup.head.IHeaderResponse;+import org.apache.wicket.markup.head.JavaScriptHeaderItem;+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;+import org.apache.wicket.model.IModel;+import org.unbescape.javascript.JavaScriptEscape;++public class CopyClipboardBehavior extends Behavior {++ private static final long serialVersionUID = 1L;++ private final IModel<String> textModel;++ public CopyClipboardBehavior(IModel<String> textModel) {+ this.textModel = textModel;+ }++ @Override+ public void detach(Component component) {+ textModel.detach();+ super.detach(component);+ }++ @Override+ public void renderHead(Component component, IHeaderResponse response) {+ super.renderHead(component, response);+ response.render(JavaScriptHeaderItem.forReference(new CopyClipboardResourceReference()));+ String script = String.format("pmease.commons.copyclipboard.init('%s', '%s');",+ component.getMarkupId(true), JavaScriptEscape.escapeJavaScript(textModel.getObject()));+ response.render(OnDomReadyHeaderItem.forScript(script));+ }++}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/CopyClipboardResourceReference.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/CopyClipboardResourceReference.javanew file mode 100644index 0000000000..ebfde75622--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/CopyClipboardResourceReference.java@@ -0,0 +1,26 @@+package com.pmease.commons.wicket.behavior.clipboard;++import java.util.List;++import org.apache.wicket.markup.head.HeaderItem;+import org.apache.wicket.markup.head.JavaScriptHeaderItem;++import com.pmease.commons.wicket.assets.clipboard.ClipboardResourceReference;+import com.pmease.commons.wicket.page.CommonDependentResourceReference;++public class CopyClipboardResourceReference extends CommonDependentResourceReference {++ private static final long serialVersionUID = 1L;++ public CopyClipboardResourceReference() {+ super(CopyClipboardResourceReference.class, "copy-clipboard.js");+ }++ @Override+ public List<HeaderItem> getDependencies() {+ List<HeaderItem> dependencies = super.getDependencies();+ dependencies.add(JavaScriptHeaderItem.forReference(new ClipboardResourceReference()));+ return dependencies;+ }++}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/copy-clipboard.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/copy-clipboard.jsnew file mode 100644index 0000000000..d71ae3cba2--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/clipboard/copy-clipboard.js@@ -0,0 +1,19 @@+pmease.commons.copyclipboard = {+ init: function(buttonId, text) {+ var $button = $("#" + buttonId);+ var clipboard = new Clipboard("#"+buttonId, {+ text: function(trigger) {+ return text;+ }+ });+ $button.tooltip({animation: false, delay: 0, title: "Copy"});+ clipboard.on("success", function(e) {+ $button.tooltip("destroy");+ $button.tooltip({animation: false, delay: 0, title: "Copied"}).tooltip("show");+ $button.on("mouseout", function() {+ $button.tooltip("destroy").tooltip({title: "Copy", animation: false, delay: 0});+ $button.off("mouseout");+ });+ });+ }+};\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.htmlindex 806e618546..339bcd11b4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.html@@ -1,27 +1,33 @@-<wicket:panel>- <div class="commit-list">- <div wicket:id="tooManyCommits" class="alert alert-warning"></div>- <div wicket:id="noAnyCommits" class="alert alert-warning"></div>- <div wicket:id="container">- <ul class="list-unstyled">- <li wicket:id="commits"><wicket:container wicket:id="commit"></wicket:container></li>- </ul>- </div>- </div>- <wicket:fragment wicket:id="commitFrag">- <div class="avatar pull-left">- <span wicket:id="avatar"></span>- </div>- <div class="detail pull-left">- <div class="message-and-labels clearfix">- <div wicket:id="message" class="message pull-left"></div>- <span wicket:id="labels" class="label label-default pull-left"></span>- </div>- <div wicket:id="contribution"></div>- </div>- <div wicket:id="hashAndCode" class="pull-right"></div>- </wicket:fragment>- <wicket:fragment wicket:id="dateFrag">- <i class="fa fa-calendar"></i> <span wicket:id="date"></span>- </wicket:fragment>+<wicket:panel>+ <div class="commit-list">+ <div wicket:id="tooManyCommits" class="alert alert-warning"></div>+ <div wicket:id="noAnyCommits" class="alert alert-warning"></div>+ <div wicket:id="container">+ <ul class="list-unstyled">+ <li wicket:id="commits"><wicket:container wicket:id="commit"></wicket:container></li>+ </ul>+ </div>+ </div>+ <wicket:fragment wicket:id="commitFrag">+ <div class="avatar pull-left">+ <span wicket:id="avatar"></span>+ </div>+ <div class="detail pull-left">+ <div class="message-and-labels clearfix">+ <div wicket:id="message" class="message pull-left"></div>+ <span wicket:id="labels" class="label label-default pull-left"></span>+ </div>+ <div wicket:id="contribution"></div>+ </div>+ <div class="pull-right">+ <span class="btn-group">+ <a wicket:id="hashLink" class="hash btn btn-sm btn-default"><span wicket:id="hash"></span></a>+ <a wicket:id="copyHash" class="btn btn-sm btn-default"><i class="fa fa-clipboard"></i></a>+ </span>+ <a wicket:id="browseCode" title="Browse code" class="browse btn btn-default btn-sm"><i class="fa fa-file-text-o"></i></a>+ </div>+ </wicket:fragment>+ <wicket:fragment wicket:id="dateFrag">+ <i class="fa fa-calendar"></i> <span wicket:id="date"></span>+ </wicket:fragment></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.javaindex 7dcb2dcf1c..74485cda2f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.java@@ -1,189 +1,211 @@-package com.pmease.gitplex.web.component.commitlist;--import java.util.ArrayList;-import java.util.List;-import java.util.Map;--import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.markup.head.CssHeaderItem;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.head.JavaScriptHeaderItem;-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.list.ListItem;-import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.html.panel.Panel;-import org.apache.wicket.markup.repeater.RepeatingView;-import org.apache.wicket.model.AbstractReadOnlyModel;-import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;-import org.eclipse.jgit.revwalk.RevCommit;-import org.joda.time.DateTime;--import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.web.Constants;-import com.pmease.gitplex.web.component.avatar.ContributorAvatars;-import com.pmease.gitplex.web.component.commitgraph.CommitGraphResourceReference;-import com.pmease.gitplex.web.component.commitgraph.CommitGraphUtils;-import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;-import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;-import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;-import com.pmease.gitplex.web.model.CommitRefsModel;--@SuppressWarnings("serial")-public class CommitListPanel extends Panel {-- private final IModel<Depot> depotModel;-- private final IModel<List<RevCommit>> commitsModel;-- private final IModel<Map<String, List<String>>> labelsModel = new CommitRefsModel(new AbstractReadOnlyModel<Depot>() {-- @Override- public Depot getObject() {- return depotModel.getObject();- }-- });-- private WebMarkupContainer container;-- public CommitListPanel(String id, IModel<Depot> depotModel, IModel<List<RevCommit>> commitsModel) {- super(id);- this.depotModel = depotModel;- this.commitsModel = new LoadableDetachableModel<List<RevCommit>>() {-- @Override- protected List<RevCommit> load() {- List<RevCommit> commits = commitsModel.getObject();- if (commits.size() > Constants.MAX_DISPLAY_COMMITS)- commits = commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());- CommitGraphUtils.sort(commits, 0);- return separateByDate(commits);- }-- @Override- protected void onDetach() {- commitsModel.detach();- super.onDetach();- }-- };- }-- @Override- protected void onInitialize() {- super.onInitialize();-- String tooManyMessage = "Too many commits, displaying recent " + Constants.MAX_DISPLAY_COMMITS;- add(new Label("tooManyCommits", tooManyMessage) {-- @Override- protected void onConfigure() {- super.onConfigure();- setVisible(commitsModel.getObject().size()>Constants.MAX_DISPLAY_COMMITS);- }-- });- add(new Label("noAnyCommits", "No any commits found") {-- @Override- protected void onConfigure() {- super.onConfigure();- setVisible(commitsModel.getObject().isEmpty());- }-- });-- container = new WebMarkupContainer("container");- container.setOutputMarkupId(true);- add(container);- container.add(new ListView<RevCommit>("commits", commitsModel) {-- private int itemIndex;-- @Override- protected void onBeforeRender() {- itemIndex = 0;- super.onBeforeRender();- }-- @Override- protected void populateItem(ListItem<RevCommit> item) {- RevCommit commit = item.getModelObject();-- Fragment fragment;- if (commit != null) {- fragment = new Fragment("commit", "commitFrag", CommitListPanel.this);- fragment.add(new ContributorAvatars("avatar",- commit.getAuthorIdent(), commit.getCommitterIdent()));-- fragment.add(new CommitMessagePanel("message", depotModel, item.getModel()));-- RepeatingView labelsView = new RepeatingView("labels");-- List<String> commitLabels = labelsModel.getObject().get(commit.name());- if (commitLabels == null)- commitLabels = new ArrayList<>();- for (String label: commitLabels)- labelsView.add(new Label(labelsView.newChildId(), label));- fragment.add(labelsView);-- fragment.add(new ContributorPanel("contribution",- commit.getAuthorIdent(), commit.getCommitterIdent(), true));- fragment.add(new HashAndCodePanel("hashAndCode", depotModel, commit.name()));- item.add(AttributeAppender.append("class", "commit clearfix commit-item-" + itemIndex++));- } else {- fragment = new Fragment("commit", "dateFrag", CommitListPanel.this);- DateTime dateTime = new DateTime(getModelObject().get(item.getIndex()+1).getCommitterIdent().getWhen());- fragment.add(new Label("date", Constants.DATE_FORMATTER.print(dateTime)));- if (item.getIndex() == 0)- item.add(AttributeAppender.append("class", "date first"));- else- item.add(AttributeAppender.append("class", "date"));- }- item.add(fragment);- }-- });-- }-- private List<RevCommit> separateByDate(List<RevCommit> commits) {- List<RevCommit> separated = new ArrayList<>();- DateTime groupTime = null;- for (RevCommit commit: commits) {- DateTime commitTime = new DateTime(commit.getCommitterIdent().getWhen());- if (groupTime == null || commitTime.getYear() != groupTime.getYear()- || commitTime.getDayOfYear() != groupTime.getDayOfYear()) {- groupTime = commitTime;- separated.add(null);- }- separated.add(commit);- }- return separated;- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);-- response.render(JavaScriptHeaderItem.forReference(new CommitGraphResourceReference()));- response.render(CssHeaderItem.forReference(new CommitListResourceReference()));-- String jsonOfCommits = CommitGraphUtils.asJSON(commitsModel.getObject());- String script = String.format("gitplex.commitgraph.render('%s', %s);", container.getMarkupId(), jsonOfCommits);- response.render(OnDomReadyHeaderItem.forScript(script));- }-- @Override- protected void onDetach() {- depotModel.detach();- commitsModel.detach();-- super.onDetach();- }--}+package com.pmease.gitplex.web.component.commitlist;++import java.util.ArrayList;+import java.util.List;+import java.util.Map;++import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.markup.head.CssHeaderItem;+import org.apache.wicket.markup.head.IHeaderResponse;+import org.apache.wicket.markup.head.JavaScriptHeaderItem;+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.link.BookmarkablePageLink;+import org.apache.wicket.markup.html.link.Link;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.Fragment;+import org.apache.wicket.markup.html.panel.Panel;+import org.apache.wicket.markup.repeater.RepeatingView;+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.request.mapper.parameter.PageParameters;+import org.eclipse.jgit.lib.FileMode;+import org.eclipse.jgit.revwalk.RevCommit;+import org.joda.time.DateTime;++import com.pmease.commons.git.BlobIdent;+import com.pmease.commons.git.GitUtils;+import com.pmease.commons.wicket.behavior.clipboard.CopyClipboardBehavior;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.web.Constants;+import com.pmease.gitplex.web.component.avatar.ContributorAvatars;+import com.pmease.gitplex.web.component.commitgraph.CommitGraphResourceReference;+import com.pmease.gitplex.web.component.commitgraph.CommitGraphUtils;+import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;+import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;+import com.pmease.gitplex.web.model.CommitRefsModel;+import com.pmease.gitplex.web.page.depot.commit.CommitDetailPage;+import com.pmease.gitplex.web.page.depot.file.DepotFilePage;++@SuppressWarnings("serial")+public class CommitListPanel extends Panel {++ private final IModel<Depot> depotModel;++ private final IModel<List<RevCommit>> commitsModel;++ private final IModel<Map<String, List<String>>> labelsModel = new CommitRefsModel(new AbstractReadOnlyModel<Depot>() {++ @Override+ public Depot getObject() {+ return depotModel.getObject();+ }++ });++ private WebMarkupContainer container;++ public CommitListPanel(String id, IModel<Depot> depotModel, IModel<List<RevCommit>> commitsModel) {+ super(id);+ this.depotModel = depotModel;+ this.commitsModel = new LoadableDetachableModel<List<RevCommit>>() {++ @Override+ protected List<RevCommit> load() {+ List<RevCommit> commits = commitsModel.getObject();+ if (commits.size() > Constants.MAX_DISPLAY_COMMITS)+ commits = commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());+ CommitGraphUtils.sort(commits, 0);+ return separateByDate(commits);+ }++ @Override+ protected void onDetach() {+ commitsModel.detach();+ super.onDetach();+ }++ };+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ String tooManyMessage = "Too many commits, displaying recent " + Constants.MAX_DISPLAY_COMMITS;+ add(new Label("tooManyCommits", tooManyMessage) {++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(commitsModel.getObject().size()>Constants.MAX_DISPLAY_COMMITS);+ }++ });+ add(new Label("noAnyCommits", "No any commits found") {++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(commitsModel.getObject().isEmpty());+ }++ });++ container = new WebMarkupContainer("container");+ container.setOutputMarkupId(true);+ add(container);+ container.add(new ListView<RevCommit>("commits", commitsModel) {++ private int itemIndex;++ @Override+ protected void onBeforeRender() {+ itemIndex = 0;+ super.onBeforeRender();+ }++ @Override+ protected void populateItem(ListItem<RevCommit> item) {+ RevCommit commit = item.getModelObject();++ Fragment fragment;+ if (commit != null) {+ fragment = new Fragment("commit", "commitFrag", CommitListPanel.this);+ fragment.add(new ContributorAvatars("avatar",+ commit.getAuthorIdent(), commit.getCommitterIdent()));++ fragment.add(new CommitMessagePanel("message", depotModel, item.getModel()));++ RepeatingView labelsView = new RepeatingView("labels");++ List<String> commitLabels = labelsModel.getObject().get(commit.name());+ if (commitLabels == null)+ commitLabels = new ArrayList<>();+ for (String label: commitLabels)+ labelsView.add(new Label(labelsView.newChildId(), label));+ fragment.add(labelsView);++ fragment.add(new ContributorPanel("contribution",+ commit.getAuthorIdent(), commit.getCommitterIdent(), true));++ CommitDetailPage.State commitState = new CommitDetailPage.State();+ commitState.revision = commit.name();+ PageParameters params = CommitDetailPage.paramsOf(depotModel.getObject(), commitState);+ Link<Void> hashLink = new BookmarkablePageLink<Void>("hashLink", CommitDetailPage.class, params);+ fragment.add(hashLink);+ hashLink.add(new Label("hash", GitUtils.abbreviateSHA(commit.name())));+ fragment.add(new WebMarkupContainer("copyHash").add(new CopyClipboardBehavior(Model.of(commit.name()))));++ DepotFilePage.State browseState = new DepotFilePage.State();+ browseState.blobIdent = new BlobIdent(commit.name(), null, FileMode.TYPE_TREE);+ params = DepotFilePage.paramsOf(depotModel.getObject(), browseState);+ fragment.add(new BookmarkablePageLink<Void>("browseCode", DepotFilePage.class, params));++ item.add(AttributeAppender.append("class", "commit clearfix commit-item-" + itemIndex++));+ } else {+ fragment = new Fragment("commit", "dateFrag", CommitListPanel.this);+ DateTime dateTime = new DateTime(getModelObject().get(item.getIndex()+1).getCommitterIdent().getWhen());+ fragment.add(new Label("date", Constants.DATE_FORMATTER.print(dateTime)));+ if (item.getIndex() == 0)+ item.add(AttributeAppender.append("class", "date first"));+ else+ item.add(AttributeAppender.append("class", "date"));+ }+ item.add(fragment);+ }++ });++ }++ private List<RevCommit> separateByDate(List<RevCommit> commits) {+ List<RevCommit> separated = new ArrayList<>();+ DateTime groupTime = null;+ for (RevCommit commit: commits) {+ DateTime commitTime = new DateTime(commit.getCommitterIdent().getWhen());+ if (groupTime == null || commitTime.getYear() != groupTime.getYear()+ || commitTime.getDayOfYear() != groupTime.getDayOfYear()) {+ groupTime = commitTime;+ separated.add(null);+ }+ separated.add(commit);+ }+ return separated;+ }++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);++ response.render(JavaScriptHeaderItem.forReference(new CommitGraphResourceReference()));+ response.render(CssHeaderItem.forReference(new CommitListResourceReference()));++ String jsonOfCommits = CommitGraphUtils.asJSON(commitsModel.getObject());+ String script = String.format("gitplex.commitgraph.render('%s', %s);", container.getMarkupId(), jsonOfCommits);+ response.render(OnDomReadyHeaderItem.forScript(script));+ }++ @Override+ protected void onDetach() {+ depotModel.detach();+ commitsModel.detach();++ super.onDetach();+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.cssindex 6d6894ebfd..fc27439332 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.css@@ -10,10 +10,8 @@.commit-list>div>ul .label {margin: 3px 0 0 4px;}-.commit-list>div>ul .hash-and-code {- text-align: right;- margin-top: 10px;- white-space: nowrap;+.commit-list>div>ul .browse {+ margin-left: 8px;}.commit-list>div>ul a {color: #555;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.htmldeleted file mode 100644index b21b1e521e..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.html+++ /dev/null@@ -1,8 +0,0 @@-<wicket:panel>- <div class="hash-and-code clearfix">- <div wicket:id="hash" class="commit-hash pull-left"></div>- <div class="pull-left browse-code">- <a wicket:id="code" title="Browse code at this point" class="btn btn-xs btn-default"><span class="fa fa-file-text-o"></span></a>- </div>- </div>-</wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.javadeleted file mode 100644index 4e4ab124c7..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodePanel.java+++ /dev/null@@ -1,62 +0,0 @@-package com.pmease.gitplex.web.component.hashandcode;--import javax.annotation.Nullable;--import org.apache.wicket.markup.head.CssHeaderItem;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.html.link.BookmarkablePageLink;-import org.apache.wicket.markup.html.panel.Panel;-import org.apache.wicket.model.IModel;--import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.web.component.commithash.CommitHashPanel;-import com.pmease.gitplex.web.page.depot.file.DepotFilePage;--@SuppressWarnings("serial")-public class HashAndCodePanel extends Panel {-- private final IModel<Depot> depotModel;-- private final String hash;-- private final String path;-- public HashAndCodePanel(String id, IModel<Depot> depotModel, String hash) {- this(id, depotModel, hash, null);- }-- public HashAndCodePanel(String id, IModel<Depot> depotModel, String hash, @Nullable String path) {- super(id);-- this.depotModel = depotModel;- this.hash = hash;- this.path = path;- }-- @Override- protected void onInitialize() {- super.onInitialize();-- add(new CommitHashPanel("hash", hash));-- DepotFilePage.State state = new DepotFilePage.State();- state.blobIdent.revision = hash;- state.blobIdent.path = path;- add(new BookmarkablePageLink<Void>("code", DepotFilePage.class,- DepotFilePage.paramsOf(depotModel.getObject(), state)));- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);- response.render(CssHeaderItem.forReference(new HashAndCodeResourceReference()));- }-- @Override- protected void onDetach() {- depotModel.detach();-- super.onDetach();- }--}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodeResourceReference.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodeResourceReference.javadeleted file mode 100644index 4de076c504..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/HashAndCodeResourceReference.java+++ /dev/null@@ -1,13 +0,0 @@-package com.pmease.gitplex.web.component.hashandcode;--import org.apache.wicket.request.resource.CssResourceReference;--public class HashAndCodeResourceReference extends CssResourceReference {-- private static final long serialVersionUID = 1L;-- public HashAndCodeResourceReference() {- super(HashAndCodeResourceReference.class, "hash-and-code.css");- }--}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/hash-and-code.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/hash-and-code.cssdeleted file mode 100644index f274d58536..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/hashandcode/hash-and-code.css+++ /dev/null@@ -1,11 +0,0 @@-.hash-and-code {- line-height: normal;-}-.hash-and-code input.commit-hash {- font-size: 13px;- border-radius: 3px 0 0 3px;- margin-right: -1px;-}-.hash-and-code>.browse-code>a {- border-radius: 0 3px 3px 0 !important;-}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.cssindex 3b97c48761..e811963de1 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/base/base.css@@ -1,143 +1,146 @@-html, body {- background: #F7F6F2;-}--.center-box {- padding: 50px;- width: 600px;- margin: 0 auto;- background: white;- border: 8px solid #DDD;- margin-top: 100px;- margin-bottom: 20px;- color: #333;-}--/* COMMON STYLES */-a {- cursor: pointer;-}-a.fa {- text-decoration: none;- color: #666;-}-table {- width: 100%;-}-table>tbody>tr>td {- vertical-align: top;-}-table.table>thead>tr>th>a {- color: black;- text-decoration: underline;-}--textarea {- resize: vertical;-}-form>.actions {- margin-top: 20px;-}-form>.actions>.btn {- margin-right: 12px;-}-.actions>a {- margin-right: 8px;-}-.nav-tabs>li>a {- color: #777;-}-div.center {- text-align: center;-}--.middot:before {- content: ".";- font-size: 16px;- line-height: 12px;- vertical-align: top;- color: #999;-}--.input-group>.form-control+.btn.input-group-addon {- border-radius: 0 4px 4px 0;- border-left: none;-}--li.selectable a, a.selectable {- border: 1px solid white;- text-decoration: none;- display: block;- padding: 2px 4px;- color: #333;-}-li.selectable:hover a, a.selectable:hover {- background-color: #E0F0FC;- border-color: #BBDFF9;-}-li.selectable.active a, a.selectable.active {- background-color: #CBE8FB;- border-color: #8BC8F9;-}--.ellipsis-expander {- display: inline-block;- background: #DDD;- padding: 0px 6px;- border-radius: 2px;- color: #777;- vertical-align: middle;- line-height: 16px;-}-.ellipsis-expander .fa {- color: #666;-}-.ellipsis-expander:hover {- background: #888;-}-.ellipsis-expander:hover .fa {- color: white;-}--input.search {- width: 200px;-}--.list>.head {- margin-bottom: 20px;-}-.list>.head>.pull-left {- margin-right: 20px;-}--.floating>.content>.selection {- padding: 16px;-}-.floating>.content>.selection>a {- padding: 4px;- display: block;- color: #666;- text-decoration: none;- max-width: 360px;-}-.floating>.content>.selection>a.active:BEFORE {- font-family: "FontAwesome";- content: "\f00c";- position: absolute;- left: 4px;-}-.floating>.content>.selection>a>.title {- font-weight: bold;- margin-bottom: 2px;-}-.floating>.content>.selection>a:hover {- background: #F0F0F0;-}--.nav-tabs {- margin-bottom: 20px;-}-.nav-tabs>li>a>.badge {- margin-left: 8px;-}-+html, body {+ background: #F7F6F2;+}++.center-box {+ padding: 50px;+ width: 600px;+ margin: 0 auto;+ background: white;+ border: 8px solid #DDD;+ margin-top: 100px;+ margin-bottom: 20px;+ color: #333;+}++/* COMMON STYLES */+a {+ cursor: pointer;+}+a.fa {+ text-decoration: none;+ color: #666;+}+table {+ width: 100%;+}+table>tbody>tr>td {+ vertical-align: top;+}+table.table>thead>tr>th>a {+ color: black;+ text-decoration: underline;+}++textarea {+ resize: vertical;+}+form>.actions {+ margin-top: 20px;+}+form>.actions>.btn {+ margin-right: 12px;+}+.actions>a {+ margin-right: 8px;+}+.nav-tabs>li>a {+ color: #777;+}+div.center {+ text-align: center;+}++.middot:before {+ content: ".";+ font-size: 16px;+ line-height: 12px;+ vertical-align: top;+ color: #999;+}++.input-group>.form-control+.btn.input-group-addon {+ border-radius: 0 4px 4px 0;+ border-left: none;+}++li.selectable a, a.selectable {+ border: 1px solid white;+ text-decoration: none;+ display: block;+ padding: 2px 4px;+ color: #333;+}+li.selectable:hover a, a.selectable:hover {+ background-color: #E0F0FC;+ border-color: #BBDFF9;+}+li.selectable.active a, a.selectable.active {+ background-color: #CBE8FB;+ border-color: #8BC8F9;+}++.ellipsis-expander {+ display: inline-block;+ background: #DDD;+ padding: 0px 6px;+ border-radius: 2px;+ color: #777;+ vertical-align: middle;+ line-height: 16px;+}+.ellipsis-expander .fa {+ color: #666;+}+.ellipsis-expander:hover {+ background: #888;+}+.ellipsis-expander:hover .fa {+ color: white;+}++input.search {+ width: 200px;+}++.list>.head {+ margin-bottom: 20px;+}+.list>.head>.pull-left {+ margin-right: 20px;+}++.floating>.content>.selection {+ padding: 16px;+}+.floating>.content>.selection>a {+ padding: 4px;+ display: block;+ color: #666;+ text-decoration: none;+ max-width: 360px;+}+.floating>.content>.selection>a.active:BEFORE {+ font-family: "FontAwesome";+ content: "\f00c";+ position: absolute;+ left: 4px;+}+.floating>.content>.selection>a>.title {+ font-weight: bold;+ margin-bottom: 2px;+}+.floating>.content>.selection>a:hover {+ background: #F0F0F0;+}++.nav-tabs {+ margin-bottom: 20px;+}+.nav-tabs>li>a>.badge {+ margin-left: 8px;+}++.hash {+ font-family: monospace;+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/DepotPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/DepotPage.htmlindex 7623c1f13d..cbd8c10311 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/DepotPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/DepotPage.html@@ -22,6 +22,4 @@<a wicket:id="depotMoreInfo" class="pull-left more-info"><i class="fa fa-ellipsis-h"></i></a></div></wicket:fragment>- <wicket:fragment wicket:id="depotInfoFrag">- </wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.htmlindex 6699ed5395..48a0a6caed 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.html@@ -5,10 +5,10 @@<div class="subject clearfix"><div wicket:id="text" class="pull-left"></div><div class="btn-group pull-right">- <a wicket:id="createBranch" title="Branch from this commit" class="btn btn-default btn-xs"><i class="fa fa-code-fork"></i></a>- <a wicket:id="createTag" title="Tag this commit" class="btn btn-default btn-xs"><i class="fa fa-tag"></i></a>+ <a wicket:id="browseCode" title="browse code" class="btn btn-default btn-sm"><i class="fa fa-file-text-o"></i></a>+ <a wicket:id="createBranch" title="Branch from this commit" class="btn btn-default btn-sm"><i class="fa fa-code-fork"></i></a>+ <a wicket:id="createTag" title="Tag this commit" class="btn btn-default btn-sm"><i class="fa fa-tag"></i></a></div>- <div wicket:id="hashAndCode" class="pull-right"></div></div><pre wicket:id="detail" class="detail"></pre></div>@@ -22,7 +22,7 @@<wicket:enclosure child="parent"><div class="single"><label>1 parent</label>- <a wicket:id="parent" class="parent"><span wicket:id="label"></span></a>+ <a wicket:id="parent" class="parent hash"><span wicket:id="label"></span></a></div></wicket:enclosure><wicket:enclosure child="parents">@@ -35,6 +35,9 @@</div></wicket:enclosure></div>+ <div class="commit pull-right">+ <label>commit</label> <span wicket:id="commitHash" class="hash"></span>+ </div></div></div><div wicket:id="revisionDiff"></div>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.javaindex 7ebb6d5cd4..1e5c80e6be 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java@@ -1,535 +1,540 @@-package com.pmease.gitplex.web.page.depot.commit;--import java.io.Serializable;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.List;-import java.util.Map;-import java.util.Set;-import java.util.stream.Collectors;--import javax.annotation.Nullable;--import org.apache.wicket.Component;-import org.apache.wicket.ajax.AjaxRequestTarget;-import org.apache.wicket.ajax.markup.html.AjaxLink;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.head.JavaScriptHeaderItem;-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.link.BookmarkablePageLink;-import org.apache.wicket.markup.html.link.Link;-import org.apache.wicket.markup.html.list.ListItem;-import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;-import org.apache.wicket.request.cycle.RequestCycle;-import org.apache.wicket.request.mapper.parameter.PageParameters;-import org.eclipse.jgit.lib.ObjectId;-import org.eclipse.jgit.revwalk.RevCommit;--import com.google.common.base.Preconditions;-import com.pmease.commons.git.GitUtils;-import com.pmease.commons.git.RefInfo;-import com.pmease.commons.lang.diff.WhitespaceOption;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.CodeComment;-import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.support.CommentPos;-import com.pmease.gitplex.core.manager.CodeCommentManager;-import com.pmease.gitplex.core.manager.CommitInfoManager;-import com.pmease.gitplex.web.component.avatar.ContributorAvatars;-import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;-import com.pmease.gitplex.web.component.createbranch.CreateBranchLink;-import com.pmease.gitplex.web.component.createtag.CreateTagLink;-import com.pmease.gitplex.web.component.diff.revision.CommentSupport;-import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;-import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;-import com.pmease.gitplex.web.page.depot.DepotPage;-import com.pmease.gitplex.web.page.depot.branches.DepotBranchesPage;-import com.pmease.gitplex.web.page.depot.file.DepotFilePage;-import com.pmease.gitplex.web.page.depot.tags.DepotTagsPage;--@SuppressWarnings("serial")-public class CommitDetailPage extends DepotPage implements CommentSupport {-- private static final String PARAM_REVISION = "revision";-- // make sure to use a different value from wicket:id according to wicket bug:- // https://issues.apache.org/jira/browse/WICKET-6069- private static final String PARAM_COMPARE_WITH = "compare-with";-- private static final String PARAM_BLAME_FILE = "blame-file";-- private static final String PARAM_WHITESPACE_OPTION = "whitespace-option";-- private static final String PARAM_PATH_FILTER = "path-filter";-- private static final String PARAM_COMMENT = "comment";-- private static final String PARAM_MARK = "mark";-- private State state;-- private ObjectId resolvedRevision;-- private ObjectId resolvedCompareWith;-- private RevisionDiffPanel revisionDiff;-- public CommitDetailPage(PageParameters params) {- super(params);-- state = new State(params);- resolvedRevision = getDepot().getRevCommit(state.revision).copy();- if (state.compareWith != null)- resolvedCompareWith = getDepot().getRevCommit(state.compareWith).copy();- }-- private RevCommit getCommit() {- return getDepot().getRevCommit(state.revision);- }-- private List<RevCommit> getParents() {- List<RevCommit> parents = new ArrayList<>();- for (RevCommit parent: getCommit().getParents())- parents.add(parent);- return parents;- }-- @Override- protected void onInitialize() {- super.onInitialize();-- add(new Label("text", getCommit().getShortMessage()));-- add(new HashAndCodePanel("hashAndCode", depotModel, getCommit().getId().name()));-- add(new CreateBranchLink("createBranch", depotModel, state.revision) {-- @Override- protected void onCreate(AjaxRequestTarget target, String branch) {- setResponsePage(DepotBranchesPage.class, DepotBranchesPage.paramsOf(getDepot()));- }-- });-- add(new CreateTagLink("createTag", depotModel, state.revision) {-- @Override- protected void onCreate(AjaxRequestTarget target, String tag) {- setResponsePage(DepotTagsPage.class, DepotTagsPage.paramsOf(getDepot()));- }-- });-- String message = GitUtils.getDetailMessage(getCommit());- if (message != null) {- add(new Label("detail", message));- } else {- add(new WebMarkupContainer("detail").setVisible(false));- }-- add(new AjaxLazyLoadPanel("refs") {-- @Override- public Component getLazyLoadComponent(String markupId) {- Fragment fragment = new Fragment(markupId, "refsFrag", CommitDetailPage.this) {-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);- String script = String.format("gitplex.commitdetail.initRefs('%s');", getMarkupId());- response.render(OnDomReadyHeaderItem.forScript(script));- }-- };- fragment.add(new ListView<RefInfo>("refs", new LoadableDetachableModel<List<RefInfo>>() {-- @Override- protected List<RefInfo> load() {- Set<ObjectId> descendants = GitPlex.getInstance(CommitInfoManager.class)- .getDescendants(getDepot(), getCommit().getId());- descendants.add(getCommit().getId());-- List<RefInfo> refs = new ArrayList<>();- refs.addAll(getDepot().getBranches());- refs.addAll(getDepot().getTags());- return refs.stream().filter(ref->descendants.contains(ref.getPeeledObj())).collect(Collectors.toList());- }-- }) {-- @Override- protected void populateItem(ListItem<RefInfo> item) {- String ref = item.getModelObject().getRef().getName();- String branch = GitUtils.ref2branch(ref);- if (branch != null) {- DepotFilePage.State state = new DepotFilePage.State();- state.blobIdent.revision = branch;- Link<Void> link = new BookmarkablePageLink<Void>("link", DepotFilePage.class,- DepotFilePage.paramsOf(depotModel.getObject(), state));- link.add(new Label("label", branch));- item.add(link);- item.add(AttributeAppender.append("class", "branch"));- } else {- String tag = Preconditions.checkNotNull(GitUtils.ref2tag(ref));- DepotFilePage.State state = new DepotFilePage.State();- state.blobIdent.revision = tag;- Link<Void> link = new BookmarkablePageLink<Void>("link", DepotFilePage.class,- DepotFilePage.paramsOf(depotModel.getObject(), state));- link.add(new Label("label", tag));- item.add(link);- item.add(AttributeAppender.append("class", "tag"));- }- }-- });- return fragment;- }-- });-- add(new ContributorAvatars("contributorAvatars", getCommit().getAuthorIdent(), getCommit().getCommitterIdent()));- add(new ContributorPanel("contribution", getCommit().getAuthorIdent(), getCommit().getCommitterIdent(), true));-- newParentsContainer(null);-- if (getCommit().getParentCount() != 0) {- newRevisionDiff(null);- } else {- add(new WebMarkupContainer("revisionDiff").setVisible(false));- }- }-- private void newParentsContainer(@Nullable AjaxRequestTarget target) {- WebMarkupContainer parentsContainer = new WebMarkupContainer("parents");- parentsContainer.setOutputMarkupId(true);- if (getParents().size() == 1) {- RevCommit parent = getParents().get(0);- State newState = new State();- newState.revision = parent.name();- newState.whitespaceOption = state.whitespaceOption;- newState.pathFilter = state.pathFilter;- Link<Void> link = new BookmarkablePageLink<Void>("parent", CommitDetailPage.class,- paramsOf(depotModel.getObject(), newState));- link.add(new Label("label", GitUtils.abbreviateSHA(parent.name())));- parentsContainer.add(link);- parentsContainer.add(new WebMarkupContainer("parents").setVisible(false));- } else {- parentsContainer.add(new WebMarkupContainer("parent").setVisible(false));- parentsContainer.add(new Label("count", getParents().size() + " parents"));- parentsContainer.add(new ListView<RevCommit>("parents", new LoadableDetachableModel<List<RevCommit>>() {-- @Override- protected List<RevCommit> load() {- return getParents();- }-- }) {-- @Override- protected void populateItem(ListItem<RevCommit> item) {- RevCommit parent = item.getModelObject();-- State newState = new State();- newState.revision = parent.name();- newState.whitespaceOption = state.whitespaceOption;- newState.pathFilter = state.pathFilter;-- Link<Void> link = new BookmarkablePageLink<Void>("link", CommitDetailPage.class,- paramsOf(depotModel.getObject(), newState));- link.add(new Label("label", GitUtils.abbreviateSHA(parent.name())));- item.add(link);-- item.add(new AjaxLink<Void>("diff") {-- @Override- public void onClick(AjaxRequestTarget target) {- state.compareWith = item.getModelObject().name();- resolvedCompareWith = item.getModelObject().copy();-- target.add(parentsContainer);- newRevisionDiff(target);- pushState(target);- }-- @Override- protected void onInitialize() {- super.onInitialize();- if (item.getModelObject().equals(getCompareWith()))- add(AttributeAppender.append("class", "active"));- }-- });- }-- });- }- if (target != null) {- replace(parentsContainer);- target.add(parentsContainer);- } else {- add(parentsContainer);- }- }-- private ObjectId getCompareWith() {- List<RevCommit> parents = getParents();- if (resolvedCompareWith != null) {- if (parents.contains(resolvedCompareWith))- return resolvedCompareWith;- else- return parents.get(0);- } else {- return parents.get(0);- }- }-- private void newRevisionDiff(@Nullable AjaxRequestTarget target) {- IModel<String> blameModel = new IModel<String>() {-- @Override- public void detach() {- }-- @Override- public String getObject() {- return state.blameFile;- }-- @Override- public void setObject(String object) {- state.blameFile = object;- pushState(RequestCycle.get().find(AjaxRequestTarget.class));- }-- };- IModel<String> pathFilterModel = new IModel<String>() {-- @Override- public void detach() {- }-- @Override- public String getObject() {- return state.pathFilter;- }-- @Override- public void setObject(String object) {- state.pathFilter = object;- pushState(RequestCycle.get().find(AjaxRequestTarget.class));- }-- };- IModel<WhitespaceOption> whitespaceOptionModel = new IModel<WhitespaceOption>() {-- @Override- public void detach() {- }-- @Override- public WhitespaceOption getObject() {- return state.whitespaceOption;- }-- @Override- public void setObject(WhitespaceOption object) {- state.whitespaceOption = object;- AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);- newParentsContainer(target);- pushState(target);- }-- };- revisionDiff = new RevisionDiffPanel("revisionDiff", depotModel,- Model.of((PullRequest)null), getCompareWith().name(), state.revision,- pathFilterModel, whitespaceOptionModel, blameModel, this);- revisionDiff.setOutputMarkupId(true);- if (target != null) {- replace(revisionDiff);- target.add(revisionDiff);- } else {- add(revisionDiff);- }- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);- response.render(JavaScriptHeaderItem.forReference(new CommitDetailResourceReference()));- }-- public static PageParameters paramsOf(Depot depot, State state) {- PageParameters params = paramsOf(depot);- params.set(PARAM_REVISION, state.revision);- if (state.compareWith != null)- params.set(PARAM_COMPARE_WITH, state.compareWith);- if (state.whitespaceOption != WhitespaceOption.DEFAULT)- params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());- if (state.pathFilter != null)- params.set(PARAM_PATH_FILTER, state.pathFilter);- if (state.blameFile != null)- params.set(PARAM_BLAME_FILE, state.blameFile);- if (state.commentId != null)- params.set(PARAM_COMMENT, state.commentId);- if (state.mark != null)- params.set(PARAM_MARK, state.mark.toString());- return params;- }-- public static PageParameters paramsOf(Depot depot, String revision) {- State state = new State();- state.revision = revision;- return paramsOf(depot, state);- }-- @Override- protected void onSelect(AjaxRequestTarget target, Depot depot) {- setResponsePage(DepotCommitsPage.class, paramsOf(depot));- }-- private void pushState(AjaxRequestTarget target) {- PageParameters params = paramsOf(getDepot(), state);- CharSequence url = RequestCycle.get().urlFor(CommitDetailPage.class, params);- pushState(target, url.toString(), state);- }-- @Override- protected void onPopState(AjaxRequestTarget target, Serializable data) {- super.onPopState(target, data);-- state = (State) data;- newRevisionDiff(target);- }-- public static class State implements Serializable {-- private static final long serialVersionUID = 1L;-- public String revision;-- @Nullable- public String compareWith;-- @Nullable- public Long commentId;-- public WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;-- @Nullable- public String pathFilter;-- @Nullable- public String blameFile;-- @Nullable- public CommentPos mark;-- public State() {- }-- public State(PageParameters params) {- revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());- compareWith = params.get(PARAM_COMPARE_WITH).toString();- whitespaceOption = WhitespaceOption.ofNullableName(params.get(PARAM_WHITESPACE_OPTION).toString());- pathFilter = params.get(PARAM_PATH_FILTER).toString();- blameFile = params.get(PARAM_BLAME_FILE).toString();- commentId = params.get(PARAM_COMMENT).toOptionalLong();- mark = CommentPos.fromString(params.get(PARAM_MARK).toString());- }-- }-- @Override- public CommentPos getMark() {- return state.mark;- }-- @Override- public String getMarkUrl(CommentPos mark) {- State markState = new State();- markState.mark = mark;- markState.whitespaceOption = state.whitespaceOption;- markState.compareWith = state.compareWith;- markState.pathFilter = state.pathFilter;- markState.revision = resolvedRevision.name();- return urlFor(CommitDetailPage.class, paramsOf(getDepot(), markState)).toString();- }-- @Override- public String getCommentUrl(CodeComment comment) {- State commentState = new State();- String compareWith = getCompareWith().name();- commentState.mark = comment.getCommentPos();- commentState.commentId = comment.getId();- commentState.whitespaceOption = state.whitespaceOption;- commentState.compareWith = compareWith;- commentState.pathFilter = state.pathFilter;- commentState.revision = resolvedRevision.name();- return urlFor(CommitDetailPage.class, paramsOf(getDepot(), commentState)).toString();- }-- @Override- public CodeComment getOpenComment() {- if (state.commentId != null)- return GitPlex.getInstance(CodeCommentManager.class).load(state.commentId);- else- return null;- }-- @Override- public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {- if (comment != null) {- state.commentId = comment.getId();- state.mark = comment.getCommentPos();- } else {- state.commentId = null;- state.mark = null;- }- pushState(target);- }-- @Override- public void onMark(AjaxRequestTarget target, CommentPos mark) {- state.mark = mark;- pushState(target);- }-- @Override- public void onAddComment(AjaxRequestTarget target, CommentPos mark) {- state.commentId = null;- state.mark = mark;- pushState(target);- }-- /*- * In case we are on a branch, this operation makes sure that the branch resolves- * to a certain commit during the life cycle of our page, unless the page is- * refreshed. This can avoid the issue that displayed file content and subsequent- * operations encounters different commit if someone commits to the branch while- * we are staying on the page.- */- @Override- protected Map<String, ObjectId> getObjectIdCache() {- Map<String, ObjectId> objectIdCache = new HashMap<>();- if (resolvedRevision != null)- objectIdCache.put(state.revision, resolvedRevision);- if (resolvedCompareWith != null)- objectIdCache.put(state.compareWith, resolvedCompareWith);- return objectIdCache;- }-- @Override- public String getAnchor() {- return null;- }--}+package com.pmease.gitplex.web.page.depot.commit;++import java.io.Serializable;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.List;+import java.util.Map;+import java.util.Set;+import java.util.stream.Collectors;++import javax.annotation.Nullable;++import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.markup.html.AjaxLink;+import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;+import org.apache.wicket.markup.head.IHeaderResponse;+import org.apache.wicket.markup.head.JavaScriptHeaderItem;+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.link.BookmarkablePageLink;+import org.apache.wicket.markup.html.link.Link;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.Fragment;+import org.apache.wicket.model.IModel;+import org.apache.wicket.model.LoadableDetachableModel;+import org.apache.wicket.model.Model;+import org.apache.wicket.request.cycle.RequestCycle;+import org.apache.wicket.request.mapper.parameter.PageParameters;+import org.eclipse.jgit.lib.FileMode;+import org.eclipse.jgit.lib.ObjectId;+import org.eclipse.jgit.revwalk.RevCommit;++import com.google.common.base.Preconditions;+import com.pmease.commons.git.BlobIdent;+import com.pmease.commons.git.GitUtils;+import com.pmease.commons.git.RefInfo;+import com.pmease.commons.lang.diff.WhitespaceOption;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.entity.CodeComment;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.support.CommentPos;+import com.pmease.gitplex.core.manager.CodeCommentManager;+import com.pmease.gitplex.core.manager.CommitInfoManager;+import com.pmease.gitplex.web.component.avatar.ContributorAvatars;+import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;+import com.pmease.gitplex.web.component.createbranch.CreateBranchLink;+import com.pmease.gitplex.web.component.createtag.CreateTagLink;+import com.pmease.gitplex.web.component.diff.revision.CommentSupport;+import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;+import com.pmease.gitplex.web.page.depot.DepotPage;+import com.pmease.gitplex.web.page.depot.branches.DepotBranchesPage;+import com.pmease.gitplex.web.page.depot.file.DepotFilePage;+import com.pmease.gitplex.web.page.depot.tags.DepotTagsPage;++@SuppressWarnings("serial")+public class CommitDetailPage extends DepotPage implements CommentSupport {++ private static final String PARAM_REVISION = "revision";++ // make sure to use a different value from wicket:id according to wicket bug:+ // https://issues.apache.org/jira/browse/WICKET-6069+ private static final String PARAM_COMPARE_WITH = "compare-with";++ private static final String PARAM_BLAME_FILE = "blame-file";++ private static final String PARAM_WHITESPACE_OPTION = "whitespace-option";++ private static final String PARAM_PATH_FILTER = "path-filter";++ private static final String PARAM_COMMENT = "comment";++ private static final String PARAM_MARK = "mark";++ private State state;++ private ObjectId resolvedRevision;++ private ObjectId resolvedCompareWith;++ private RevisionDiffPanel revisionDiff;++ public CommitDetailPage(PageParameters params) {+ super(params);++ state = new State(params);+ resolvedRevision = getDepot().getRevCommit(state.revision).copy();+ if (state.compareWith != null)+ resolvedCompareWith = getDepot().getRevCommit(state.compareWith).copy();+ }++ private RevCommit getCommit() {+ return getDepot().getRevCommit(state.revision);+ }++ private List<RevCommit> getParents() {+ List<RevCommit> parents = new ArrayList<>();+ for (RevCommit parent: getCommit().getParents())+ parents.add(parent);+ return parents;+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(new Label("text", getCommit().getShortMessage()));++ DepotFilePage.State browseState = new DepotFilePage.State();+ browseState.blobIdent = new BlobIdent(getCommit().name(), null, FileMode.TYPE_TREE);+ PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), browseState);+ add(new BookmarkablePageLink<Void>("browseCode", DepotFilePage.class, params));++ add(new CreateBranchLink("createBranch", depotModel, state.revision) {++ @Override+ protected void onCreate(AjaxRequestTarget target, String branch) {+ setResponsePage(DepotBranchesPage.class, DepotBranchesPage.paramsOf(getDepot()));+ }++ });++ add(new CreateTagLink("createTag", depotModel, state.revision) {++ @Override+ protected void onCreate(AjaxRequestTarget target, String tag) {+ setResponsePage(DepotTagsPage.class, DepotTagsPage.paramsOf(getDepot()));+ }++ });++ String message = GitUtils.getDetailMessage(getCommit());+ if (message != null) {+ add(new Label("detail", message));+ } else {+ add(new WebMarkupContainer("detail").setVisible(false));+ }++ add(new AjaxLazyLoadPanel("refs") {++ @Override+ public Component getLazyLoadComponent(String markupId) {+ Fragment fragment = new Fragment(markupId, "refsFrag", CommitDetailPage.this) {++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);+ String script = String.format("gitplex.commitdetail.initRefs('%s');", getMarkupId());+ response.render(OnDomReadyHeaderItem.forScript(script));+ }++ };+ fragment.add(new ListView<RefInfo>("refs", new LoadableDetachableModel<List<RefInfo>>() {++ @Override+ protected List<RefInfo> load() {+ Set<ObjectId> descendants = GitPlex.getInstance(CommitInfoManager.class)+ .getDescendants(getDepot(), getCommit().getId());+ descendants.add(getCommit().getId());++ List<RefInfo> refs = new ArrayList<>();+ refs.addAll(getDepot().getBranches());+ refs.addAll(getDepot().getTags());+ return refs.stream().filter(ref->descendants.contains(ref.getPeeledObj())).collect(Collectors.toList());+ }++ }) {++ @Override+ protected void populateItem(ListItem<RefInfo> item) {+ String ref = item.getModelObject().getRef().getName();+ String branch = GitUtils.ref2branch(ref);+ if (branch != null) {+ DepotFilePage.State state = new DepotFilePage.State();+ state.blobIdent.revision = branch;+ Link<Void> link = new BookmarkablePageLink<Void>("link", DepotFilePage.class,+ DepotFilePage.paramsOf(depotModel.getObject(), state));+ link.add(new Label("label", branch));+ item.add(link);+ item.add(AttributeAppender.append("class", "branch"));+ } else {+ String tag = Preconditions.checkNotNull(GitUtils.ref2tag(ref));+ DepotFilePage.State state = new DepotFilePage.State();+ state.blobIdent.revision = tag;+ Link<Void> link = new BookmarkablePageLink<Void>("link", DepotFilePage.class,+ DepotFilePage.paramsOf(depotModel.getObject(), state));+ link.add(new Label("label", tag));+ item.add(link);+ item.add(AttributeAppender.append("class", "tag"));+ }+ }++ });+ return fragment;+ }++ });++ add(new ContributorAvatars("contributorAvatars", getCommit().getAuthorIdent(), getCommit().getCommitterIdent()));+ add(new ContributorPanel("contribution", getCommit().getAuthorIdent(), getCommit().getCommitterIdent(), true));+ add(new Label("commitHash", getCommit().name()));++ newParentsContainer(null);++ if (getCommit().getParentCount() != 0) {+ newRevisionDiff(null);+ } else {+ add(new WebMarkupContainer("revisionDiff").setVisible(false));+ }+ }++ private void newParentsContainer(@Nullable AjaxRequestTarget target) {+ WebMarkupContainer parentsContainer = new WebMarkupContainer("parents");+ parentsContainer.setOutputMarkupId(true);+ if (getParents().size() == 1) {+ RevCommit parent = getParents().get(0);+ State newState = new State();+ newState.revision = parent.name();+ newState.whitespaceOption = state.whitespaceOption;+ newState.pathFilter = state.pathFilter;+ Link<Void> link = new BookmarkablePageLink<Void>("parent", CommitDetailPage.class,+ paramsOf(depotModel.getObject(), newState));+ link.add(new Label("label", GitUtils.abbreviateSHA(parent.name())));+ parentsContainer.add(link);+ parentsContainer.add(new WebMarkupContainer("parents").setVisible(false));+ } else {+ parentsContainer.add(new WebMarkupContainer("parent").setVisible(false));+ parentsContainer.add(new Label("count", getParents().size() + " parents"));+ parentsContainer.add(new ListView<RevCommit>("parents", new LoadableDetachableModel<List<RevCommit>>() {++ @Override+ protected List<RevCommit> load() {+ return getParents();+ }++ }) {++ @Override+ protected void populateItem(ListItem<RevCommit> item) {+ RevCommit parent = item.getModelObject();++ State newState = new State();+ newState.revision = parent.name();+ newState.whitespaceOption = state.whitespaceOption;+ newState.pathFilter = state.pathFilter;++ Link<Void> link = new BookmarkablePageLink<Void>("link", CommitDetailPage.class,+ paramsOf(depotModel.getObject(), newState));+ link.add(new Label("label", GitUtils.abbreviateSHA(parent.name())));+ item.add(link);++ item.add(new AjaxLink<Void>("diff") {++ @Override+ public void onClick(AjaxRequestTarget target) {+ state.compareWith = item.getModelObject().name();+ resolvedCompareWith = item.getModelObject().copy();++ target.add(parentsContainer);+ newRevisionDiff(target);+ pushState(target);+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();+ if (item.getModelObject().equals(getCompareWith()))+ add(AttributeAppender.append("class", "active"));+ }++ });+ }++ });+ }+ if (target != null) {+ replace(parentsContainer);+ target.add(parentsContainer);+ } else {+ add(parentsContainer);+ }+ }++ private ObjectId getCompareWith() {+ List<RevCommit> parents = getParents();+ if (resolvedCompareWith != null) {+ if (parents.contains(resolvedCompareWith))+ return resolvedCompareWith;+ else+ return parents.get(0);+ } else {+ return parents.get(0);+ }+ }++ private void newRevisionDiff(@Nullable AjaxRequestTarget target) {+ IModel<String> blameModel = new IModel<String>() {++ @Override+ public void detach() {+ }++ @Override+ public String getObject() {+ return state.blameFile;+ }++ @Override+ public void setObject(String object) {+ state.blameFile = object;+ pushState(RequestCycle.get().find(AjaxRequestTarget.class));+ }++ };+ IModel<String> pathFilterModel = new IModel<String>() {++ @Override+ public void detach() {+ }++ @Override+ public String getObject() {+ return state.pathFilter;+ }++ @Override+ public void setObject(String object) {+ state.pathFilter = object;+ pushState(RequestCycle.get().find(AjaxRequestTarget.class));+ }++ };+ IModel<WhitespaceOption> whitespaceOptionModel = new IModel<WhitespaceOption>() {++ @Override+ public void detach() {+ }++ @Override+ public WhitespaceOption getObject() {+ return state.whitespaceOption;+ }++ @Override+ public void setObject(WhitespaceOption object) {+ state.whitespaceOption = object;+ AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);+ newParentsContainer(target);+ pushState(target);+ }++ };+ revisionDiff = new RevisionDiffPanel("revisionDiff", depotModel,+ Model.of((PullRequest)null), getCompareWith().name(), state.revision,+ pathFilterModel, whitespaceOptionModel, blameModel, this);+ revisionDiff.setOutputMarkupId(true);+ if (target != null) {+ replace(revisionDiff);+ target.add(revisionDiff);+ } else {+ add(revisionDiff);+ }+ }++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);+ response.render(JavaScriptHeaderItem.forReference(new CommitDetailResourceReference()));+ }++ public static PageParameters paramsOf(Depot depot, State state) {+ PageParameters params = paramsOf(depot);+ params.set(PARAM_REVISION, state.revision);+ if (state.compareWith != null)+ params.set(PARAM_COMPARE_WITH, state.compareWith);+ if (state.whitespaceOption != WhitespaceOption.DEFAULT)+ params.set(PARAM_WHITESPACE_OPTION, state.whitespaceOption.name());+ if (state.pathFilter != null)+ params.set(PARAM_PATH_FILTER, state.pathFilter);+ if (state.blameFile != null)+ params.set(PARAM_BLAME_FILE, state.blameFile);+ if (state.commentId != null)+ params.set(PARAM_COMMENT, state.commentId);+ if (state.mark != null)+ params.set(PARAM_MARK, state.mark.toString());+ return params;+ }++ public static PageParameters paramsOf(Depot depot, String revision) {+ State state = new State();+ state.revision = revision;+ return paramsOf(depot, state);+ }++ @Override+ protected void onSelect(AjaxRequestTarget target, Depot depot) {+ setResponsePage(DepotCommitsPage.class, paramsOf(depot));+ }++ private void pushState(AjaxRequestTarget target) {+ PageParameters params = paramsOf(getDepot(), state);+ CharSequence url = RequestCycle.get().urlFor(CommitDetailPage.class, params);+ pushState(target, url.toString(), state);+ }++ @Override+ protected void onPopState(AjaxRequestTarget target, Serializable data) {+ super.onPopState(target, data);++ state = (State) data;+ newRevisionDiff(target);+ }++ public static class State implements Serializable {++ private static final long serialVersionUID = 1L;++ public String revision;++ @Nullable+ public String compareWith;++ @Nullable+ public Long commentId;++ public WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;++ @Nullable+ public String pathFilter;++ @Nullable+ public String blameFile;++ @Nullable+ public CommentPos mark;++ public State() {+ }++ public State(PageParameters params) {+ revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());+ compareWith = params.get(PARAM_COMPARE_WITH).toString();+ whitespaceOption = WhitespaceOption.ofNullableName(params.get(PARAM_WHITESPACE_OPTION).toString());+ pathFilter = params.get(PARAM_PATH_FILTER).toString();+ blameFile = params.get(PARAM_BLAME_FILE).toString();+ commentId = params.get(PARAM_COMMENT).toOptionalLong();+ mark = CommentPos.fromString(params.get(PARAM_MARK).toString());+ }++ }++ @Override+ public CommentPos getMark() {+ return state.mark;+ }++ @Override+ public String getMarkUrl(CommentPos mark) {+ State markState = new State();+ markState.mark = mark;+ markState.whitespaceOption = state.whitespaceOption;+ markState.compareWith = state.compareWith;+ markState.pathFilter = state.pathFilter;+ markState.revision = resolvedRevision.name();+ return urlFor(CommitDetailPage.class, paramsOf(getDepot(), markState)).toString();+ }++ @Override+ public String getCommentUrl(CodeComment comment) {+ State commentState = new State();+ String compareWith = getCompareWith().name();+ commentState.mark = comment.getCommentPos();+ commentState.commentId = comment.getId();+ commentState.whitespaceOption = state.whitespaceOption;+ commentState.compareWith = compareWith;+ commentState.pathFilter = state.pathFilter;+ commentState.revision = resolvedRevision.name();+ return urlFor(CommitDetailPage.class, paramsOf(getDepot(), commentState)).toString();+ }++ @Override+ public CodeComment getOpenComment() {+ if (state.commentId != null)+ return GitPlex.getInstance(CodeCommentManager.class).load(state.commentId);+ else+ return null;+ }++ @Override+ public void onCommentOpened(AjaxRequestTarget target, CodeComment comment) {+ if (comment != null) {+ state.commentId = comment.getId();+ state.mark = comment.getCommentPos();+ } else {+ state.commentId = null;+ state.mark = null;+ }+ pushState(target);+ }++ @Override+ public void onMark(AjaxRequestTarget target, CommentPos mark) {+ state.mark = mark;+ pushState(target);+ }++ @Override+ public void onAddComment(AjaxRequestTarget target, CommentPos mark) {+ state.commentId = null;+ state.mark = mark;+ pushState(target);+ }++ /*+ * In case we are on a branch, this operation makes sure that the branch resolves+ * to a certain commit during the life cycle of our page, unless the page is+ * refreshed. This can avoid the issue that displayed file content and subsequent+ * operations encounters different commit if someone commits to the branch while+ * we are staying on the page.+ */+ @Override+ protected Map<String, ObjectId> getObjectIdCache() {+ Map<String, ObjectId> objectIdCache = new HashMap<>();+ if (resolvedRevision != null)+ objectIdCache.put(state.revision, resolvedRevision);+ if (resolvedCompareWith != null)+ objectIdCache.put(state.compareWith, resolvedCompareWith);+ return objectIdCache;+ }++ @Override+ public String getAnchor() {+ return null;+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.htmlindex 81e4db8b83..bc1dea4f15 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.html@@ -33,12 +33,20 @@</div><div wicket:id="contribution"></div></div>- <wicket:enclosure>- <div class="pull-right">- <a wicket:id="compare" class="compare btn btn-xs btn-default" title="Compare"><i class="fa fa-ext fa-file-diff"></i></a>+ <div class="pull-right actions">+ <span class="btn-group">+ <a wicket:id="browseCode" title="Browse code" class="btn btn-sm btn-default"><i class="fa fa-file-text-o"></i></a>+ <wicket:enclosure>+ <a wicket:id="compare" class="compare btn-sm btn btn-default" title="Compare with base revision"><i class="fa fa-ext fa-file-diff"></i></a>+ </wicket:enclosure>+ </span>+ </div>+ <div class="pull-right hash">+ <span class="btn-group">+ <a wicket:id="hashLink" class="btn btn-sm btn-default"><span wicket:id="hash"></span></a>+ <a wicket:id="copyHash" class="btn btn-sm btn-default"><i class="fa fa-clipboard"></i></a>+ </span></div>- </wicket:enclosure>- <div wicket:id="hashAndCode" class="pull-right"></div></wicket:fragment><wicket:fragment wicket:id="dateFrag"><i class="fa fa-calendar"></i> <span wicket:id="date"></span>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.javaindex 96a27a5554..d6f92b1597 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java@@ -27,12 +27,15 @@ import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.form.TextField;import org.apache.wicket.markup.html.link.BookmarkablePageLink;+import org.apache.wicket.markup.html.link.Link;import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.markup.repeater.RepeatingView;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;+import org.apache.wicket.model.Model;import org.apache.wicket.request.cycle.RequestCycle;import org.apache.wicket.request.mapper.parameter.PageParameters;+import org.eclipse.jgit.lib.FileMode;import org.eclipse.jgit.lib.ObjectId;import org.eclipse.jgit.revwalk.RevCommit;import org.eclipse.jgit.revwalk.RevWalk;@@ -43,10 +46,13 @@ import org.unbescape.java.JavaEscape;import com.google.common.base.Optional;import com.google.common.base.Throwables;+import com.pmease.commons.git.BlobIdent;+import com.pmease.commons.git.GitUtils;import com.pmease.commons.git.command.RevListCommand;import com.pmease.commons.util.StringUtils;import com.pmease.commons.util.concurrent.PrioritizedCallable;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;+import com.pmease.commons.wicket.behavior.clipboard.CopyClipboardBehavior;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.support.DepotAndRevision;@@ -57,12 +63,12 @@ import com.pmease.gitplex.web.component.commitgraph.CommitGraphResourceReferenceimport com.pmease.gitplex.web.component.commitgraph.CommitGraphUtils;import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;-import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;import com.pmease.gitplex.web.model.CommitRefsModel;import com.pmease.gitplex.web.page.depot.DepotPage;import com.pmease.gitplex.web.page.depot.commit.CommitQueryParser.CriteriaContext;import com.pmease.gitplex.web.page.depot.commit.CommitQueryParser.QueryContext;import com.pmease.gitplex.web.page.depot.compare.RevisionComparePage;+import com.pmease.gitplex.web.page.depot.file.DepotFilePage;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;import jersey.repackaged.com.google.common.collect.Lists;@@ -433,6 +439,12 @@ public class DepotCommitsPage extends DepotPage {}}}++ DepotFilePage.State browseState = new DepotFilePage.State();+ browseState.blobIdent = new BlobIdent(commit.name(), null, FileMode.TYPE_TREE);+ PageParameters params = DepotFilePage.paramsOf(depotModel.getObject(), browseState);+ item.add(new BookmarkablePageLink<Void>("browseCode", DepotFilePage.class, params));+if (state.getCompareWith() != null) {RevisionComparePage.State compareState = new RevisionComparePage.State();compareState.leftSide = new DepotAndRevision(getDepot(), commit.name());@@ -440,12 +452,19 @@ public class DepotCommitsPage extends DepotPage {compareState.pathFilter = path;compareState.tabPanel = RevisionComparePage.TabPanel.CHANGES;- PageParameters params = RevisionComparePage.paramsOf(getDepot(), compareState);+ params = RevisionComparePage.paramsOf(getDepot(), compareState);item.add(new BookmarkablePageLink<Void>("compare", RevisionComparePage.class, params));} else {item.add(new WebMarkupContainer("compare").setVisible(false));}- item.add(new HashAndCodePanel("hashAndCode", depotModel, commit.name(), path));++ CommitDetailPage.State commitState = new CommitDetailPage.State();+ commitState.revision = commit.name();+ params = CommitDetailPage.paramsOf(depotModel.getObject(), commitState);+ Link<Void> hashLink = new BookmarkablePageLink<Void>("hashLink", CommitDetailPage.class, params);+ item.add(hashLink);+ hashLink.add(new Label("hash", GitUtils.abbreviateSHA(commit.name())));+ item.add(new WebMarkupContainer("copyHash").add(new CopyClipboardBehavior(Model.of(commit.name()))));item.add(AttributeAppender.append("class", "commit clearfix"));} else {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.cssindex 567af8887a..c81a69c04d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.css@@ -12,12 +12,13 @@#commit-detail>.info>.message {background: #F9F9F9;border-bottom: 1px dashed #BBB;- padding: 12px;+ padding: 8px 12px;border-radius: 4px 4px 0 0;}#commit-detail>.info>.message>.subject>.pull-left {font-size: 17px;font-weight: bold;+ padding-top: 2px;color: #555;}#commit-detail>.info>.message>.subject>.pull-right {@@ -65,7 +66,13 @@#commit-detail>.info>.contribution-and-parents .contributor-avatars {margin-right: 4px;}-#commit-detail>.info>.contribution-and-parents>.parents label {+#commit-detail>.info>.contribution-and-parents .commit {+ margin: 7px 20px 0 20px;+}+#commit-detail>.info>.contribution-and-parents .hash {+ color: #444;+}+#commit-detail>.info>.contribution-and-parents label {color: #666;font-weight: normal;margin-right: 8px;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.cssindex d271f63fad..7953c1d528 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css@@ -19,14 +19,6 @@#repo-commits>.body .label {margin: 3px 0 0 4px;}-#repo-commits>.body .hash-and-code {- text-align: right;- margin-top: 10px;- white-space: nowrap;-}-#repo-commits>.body .compare {- margin: 10px 0 0 8px;-}#repo-commits>.body a {color: #555;}@@ -47,12 +39,15 @@#repo-commits>.body li.commit .contribution {font-size: 12px;}-#repo-commits>.body li.commit .compare {- color: #888;-}#repo-commits>.body .message-and-labels {margin-bottom: 4px;}+#repo-commits>.body .actions {+ margin-left: 8px;+}+#repo-commits>.body .actions .compare {+ color: #777;+}#repo-commits>.body>.list {margin-bottom: 0;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.htmlindex 4db2142232..ca773e9f31 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.html@@ -17,7 +17,8 @@<div class="clone"><div class="input-group"><div class="input-group-addon">Clone URL</div>- <input wicket:id="cloneUrl" readonly="readonly" class="form-control" onfocus="setTimeout(function(){$('.depot.more-info>.clone input').select();}, 100);"/>+ <input wicket:id="cloneUrl" readonly="readonly" class="form-control"/>+ <a wicket:id="copyUrl" class="input-group-addon"><i class="fa fa-clipboard"></i></a></div></div></div>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.javaindex 9082bf4d63..161abd29b7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/moreinfo/MoreInfoPanel.java@@ -18,6 +18,7 @@ import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.model.Model;import org.eclipse.jgit.lib.Constants;+import com.pmease.commons.wicket.behavior.clipboard.CopyClipboardBehavior;import com.pmease.commons.wicket.component.DropdownLink;import com.pmease.commons.wicket.component.markdown.MarkdownPanel;import com.pmease.commons.wicket.component.modal.ModalLink;@@ -62,6 +63,7 @@ public abstract class MoreInfoPanel extends Panel {UrlManager urlManager = GitPlex.getInstance(UrlManager.class);Model<String> cloneUrlModel = Model.of(urlManager.urlFor(getDepot()));add(new TextField<String>("cloneUrl", cloneUrlModel));+ add(new WebMarkupContainer("copyUrl").add(new CopyClipboardBehavior(cloneUrlModel)));if (getDepot().getDescription() != null) {add(new MarkdownPanel("description", Model.of(getDepot().getDescription()), null));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.htmlindex 9b9947af74..fd01439cf3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.html@@ -1,18 +1,24 @@-<wicket:panel>- <div class="update activity">- <div wicket:id="tooManyCommits" class="alert alert-warning"></div>- <table>- <tr wicket:id="commits">- <td class="icon"><i class="fa fa-ext fa-commit"></i></td>- <td class="detail">- <span wicket:id="author"></span>- <span wicket:id="message"></span>- </td>- <td class="status clearfix">- <div wicket:id="hashAndCode" class="pull-right"></div>- <div wicket:id="verification" class="pull-right"></div >- </td>- </tr>- </table>- </div>+<wicket:panel>+ <div class="update activity">+ <div wicket:id="tooManyCommits" class="alert alert-warning"></div>+ <table>+ <tr wicket:id="commits">+ <td class="icon"><i class="fa fa-ext fa-commit"></i></td>+ <td class="detail">+ <span wicket:id="author"></span>+ <span wicket:id="message"></span>+ </td>+ <td class="hash-and-status clearfix">+ <div class="pull-right">+ <span class="btn-group">+ <a wicket:id="hashLink" class="hash btn btn-xs btn-default"><span wicket:id="hash"></span></a>+ <a wicket:id="copyHash" class="btn btn-xs btn-default"><i class="fa fa-clipboard"></i></a>+ </span>+ <a wicket:id="browseCode" title="Browse code" class="btn btn-default btn-xs"><i class="fa fa-file-text-o"></i></a>+ </div>+ <div wicket:id="verification" class="pull-right"></div>+ </td>+ </tr>+ </table>+ </div></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.javaindex b5022a86e9..9d7dd7f04c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/activity/UpdatedPanel.java@@ -1,165 +1,178 @@-package com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview.activity;--import java.util.List;--import org.apache.wicket.Component;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.markup.ComponentTag;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.list.ListItem;-import org.apache.wicket.markup.html.list.ListView;-import org.apache.wicket.markup.html.panel.GenericPanel;-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.eclipse.jgit.revwalk.RevCommit;--import com.pmease.gitplex.core.entity.Depot;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.PullRequestUpdate;-import com.pmease.gitplex.core.entity.PullRequestVerification;-import com.pmease.gitplex.web.Constants;-import com.pmease.gitplex.web.component.avatar.AvatarLink;-import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;-import com.pmease.gitplex.web.component.hashandcode.HashAndCodePanel;-import com.pmease.gitplex.web.component.pullrequest.verificationstatus.VerificationStatusPanel;--import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;--@SuppressWarnings("serial")-class UpdatedPanel extends GenericPanel<PullRequestUpdate> {-- public UpdatedPanel(String id, IModel<PullRequestUpdate> model) {- super(id, model);- }-- @Override- protected void onInitialize() {- super.onInitialize();-- String tooManyMessage = "Too many commits, displaying recent " + Constants.MAX_DISPLAY_COMMITS;- add(new Label("tooManyCommits", tooManyMessage) {-- @Override- protected void onConfigure() {- super.onConfigure();- setVisible(getUpdate().getCommits().size()>Constants.MAX_DISPLAY_COMMITS);- }-- });- add(new ListView<RevCommit>("commits", new LoadableDetachableModel<List<RevCommit>>() {-- @Override- protected List<RevCommit> load() {- List<RevCommit> commits = getUpdate().getCommits();- if (commits.size() > Constants.MAX_DISPLAY_COMMITS)- return commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());- else- return commits;- }-- }) {-- @Override- protected void populateItem(final ListItem<RevCommit> item) {- RevCommit commit = item.getModelObject();-- item.add(new AvatarLink("author", commit.getAuthorIdent(), new TooltipConfig()));-- IModel<Depot> depotModel = new AbstractReadOnlyModel<Depot>() {-- @Override- public Depot getObject() {- return getUpdate().getRequest().getTarget().getDepot();- }-- };- item.add(new CommitMessagePanel("message", depotModel, item.getModel()));-- IModel<PullRequest> requestModel = new AbstractReadOnlyModel<PullRequest>() {-- @Override- public PullRequest getObject() {- return getUpdate().getRequest();- }-- };- item.add(new VerificationStatusPanel("verification", requestModel, Model.of(commit.name())) {-- @Override- protected Component newStatusComponent(String id, final IModel<PullRequestVerification.Status> statusModel) {- return new Label(id, new AbstractReadOnlyModel<String>() {-- @Override- public String getObject() {- if (statusModel.getObject() == PullRequestVerification.Status.SUCCESSFUL)- return "<i class='fa fa-check'></i><i class='caret'></i> ";- else if (statusModel.getObject() == PullRequestVerification.Status.RUNNING)- return "<i class='fa fa-clock-o'></i><i class='caret'></i> ";- else if (statusModel.getObject() == PullRequestVerification.Status.FAILED)- return "<i class='fa fa-times'></i><i class='caret'></i>";- else- return "";- }-- }) {-- @Override- protected void onComponentTag(ComponentTag tag) {- super.onComponentTag(tag);-- if (statusModel.getObject() == PullRequestVerification.Status.SUCCESSFUL) {- tag.put("class", "successful");- tag.put("title", "Build is successful");- } else if (statusModel.getObject() == PullRequestVerification.Status.RUNNING) {- tag.put("class", "running");- tag.put("title", "Build is running");- } else if (statusModel.getObject() == PullRequestVerification.Status.FAILED) {- tag.put("class", "failed");- tag.put("title", "Build is failed");- }- }-- @Override- protected void onDetach() {- statusModel.detach();-- super.onDetach();- }-- }.setEscapeModelStrings(false);- }-- });-- item.add(new HashAndCodePanel("hashAndCode", new AbstractReadOnlyModel<Depot>() {-- @Override- public Depot getObject() {- return getUpdate().getRequest().getTargetDepot();- }-- }, commit.name(), null));-- if (getUpdate().getRequest().getTarget().getObjectId(false) != null) {- if (getUpdate().getRequest().getMergedCommits().contains(commit)) {- item.add(AttributeAppender.append("class", " integrated"));- item.add(AttributeAppender.append("title", "This commit has been integrated"));- } else if (!getUpdate().getRequest().getPendingCommits().contains(commit)) {- item.add(AttributeAppender.append("class", " rebased"));- item.add(AttributeAppender.append("title", "This commit has been rebased"));- }- }-- }-- });-- }-- private PullRequestUpdate getUpdate() {- return getModelObject();- }--}+package com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview.activity;++import java.util.List;++import org.apache.wicket.Component;+import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.markup.ComponentTag;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.link.BookmarkablePageLink;+import org.apache.wicket.markup.html.link.Link;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.GenericPanel;+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.request.mapper.parameter.PageParameters;+import org.eclipse.jgit.lib.FileMode;+import org.eclipse.jgit.revwalk.RevCommit;++import com.pmease.commons.git.BlobIdent;+import com.pmease.commons.git.GitUtils;+import com.pmease.commons.wicket.behavior.clipboard.CopyClipboardBehavior;+import com.pmease.gitplex.core.entity.Depot;+import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestUpdate;+import com.pmease.gitplex.core.entity.PullRequestVerification;+import com.pmease.gitplex.web.Constants;+import com.pmease.gitplex.web.component.avatar.AvatarLink;+import com.pmease.gitplex.web.component.commitmessage.CommitMessagePanel;+import com.pmease.gitplex.web.component.pullrequest.verificationstatus.VerificationStatusPanel;+import com.pmease.gitplex.web.page.depot.commit.CommitDetailPage;+import com.pmease.gitplex.web.page.depot.file.DepotFilePage;++import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;++@SuppressWarnings("serial")+class UpdatedPanel extends GenericPanel<PullRequestUpdate> {++ public UpdatedPanel(String id, IModel<PullRequestUpdate> model) {+ super(id, model);+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ String tooManyMessage = "Too many commits, displaying recent " + Constants.MAX_DISPLAY_COMMITS;+ add(new Label("tooManyCommits", tooManyMessage) {++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(getUpdate().getCommits().size()>Constants.MAX_DISPLAY_COMMITS);+ }++ });+ add(new ListView<RevCommit>("commits", new LoadableDetachableModel<List<RevCommit>>() {++ @Override+ protected List<RevCommit> load() {+ List<RevCommit> commits = getUpdate().getCommits();+ if (commits.size() > Constants.MAX_DISPLAY_COMMITS)+ return commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());+ else+ return commits;+ }++ }) {++ @Override+ protected void populateItem(final ListItem<RevCommit> item) {+ RevCommit commit = item.getModelObject();++ item.add(new AvatarLink("author", commit.getAuthorIdent(), new TooltipConfig()));++ IModel<Depot> depotModel = new AbstractReadOnlyModel<Depot>() {++ @Override+ public Depot getObject() {+ return getUpdate().getRequest().getTarget().getDepot();+ }++ };+ item.add(new CommitMessagePanel("message", depotModel, item.getModel()));++ IModel<PullRequest> requestModel = new AbstractReadOnlyModel<PullRequest>() {++ @Override+ public PullRequest getObject() {+ return getUpdate().getRequest();+ }++ };+ item.add(new VerificationStatusPanel("verification", requestModel, Model.of(commit.name())) {++ @Override+ protected Component newStatusComponent(String id, final IModel<PullRequestVerification.Status> statusModel) {+ return new Label(id, new AbstractReadOnlyModel<String>() {++ @Override+ public String getObject() {+ if (statusModel.getObject() == PullRequestVerification.Status.SUCCESSFUL)+ return "<i class='fa fa-check'></i><i class='caret'></i> ";+ else if (statusModel.getObject() == PullRequestVerification.Status.RUNNING)+ return "<i class='fa fa-clock-o'></i><i class='caret'></i> ";+ else if (statusModel.getObject() == PullRequestVerification.Status.FAILED)+ return "<i class='fa fa-times'></i><i class='caret'></i>";+ else+ return "";+ }++ }) {++ @Override+ protected void onComponentTag(ComponentTag tag) {+ super.onComponentTag(tag);++ if (statusModel.getObject() == PullRequestVerification.Status.SUCCESSFUL) {+ tag.put("class", "successful");+ tag.put("title", "Build is successful");+ } else if (statusModel.getObject() == PullRequestVerification.Status.RUNNING) {+ tag.put("class", "running");+ tag.put("title", "Build is running");+ } else if (statusModel.getObject() == PullRequestVerification.Status.FAILED) {+ tag.put("class", "failed");+ tag.put("title", "Build is failed");+ }+ }++ @Override+ protected void onDetach() {+ statusModel.detach();++ super.onDetach();+ }++ }.setEscapeModelStrings(false);+ }++ });++ CommitDetailPage.State commitState = new CommitDetailPage.State();+ commitState.revision = commit.name();+ PageParameters params = CommitDetailPage.paramsOf(depotModel.getObject(), commitState);+ Link<Void> hashLink = new BookmarkablePageLink<Void>("hashLink", CommitDetailPage.class, params);+ item.add(hashLink);+ hashLink.add(new Label("hash", GitUtils.abbreviateSHA(commit.name())));+ item.add(new WebMarkupContainer("copyHash").add(new CopyClipboardBehavior(Model.of(commit.name()))));++ DepotFilePage.State browseState = new DepotFilePage.State();+ browseState.blobIdent = new BlobIdent(commit.name(), null, FileMode.TYPE_TREE);+ params = DepotFilePage.paramsOf(depotModel.getObject(), browseState);+ item.add(new BookmarkablePageLink<Void>("browseCode", DepotFilePage.class, params));++ if (getUpdate().getRequest().getTarget().getObjectId(false) != null) {+ if (getUpdate().getRequest().getMergedCommits().contains(commit)) {+ item.add(AttributeAppender.append("class", " integrated"));+ item.add(AttributeAppender.append("title", "This commit has been integrated"));+ } else if (!getUpdate().getRequest().getPendingCommits().contains(commit)) {+ item.add(AttributeAppender.append("class", " rebased"));+ item.add(AttributeAppender.append("title", "This commit has been rebased"));+ }+ }++ }++ });++ }++ private PullRequestUpdate getUpdate() {+ return getModelObject();+ }++}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/request-overview.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/request-overview.cssindex 7a99d6f1e5..d2ab473b81 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/request-overview.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/request-overview.css@@ -149,7 +149,7 @@#request-detail .activities tr.activity>.content>.update td {padding: 4px 0;}-#request-detail .activities tr.activity>.content>.update td.status {+#request-detail .activities tr.activity>.content>.update td.hash-and-status {width: 120px;}#request-detail .update+.update>td.content>div {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.htmlindex 795b443f3a..e8a32b1e9a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html@@ -1,3 +1,2 @@-<wicket:extend>- <a wicket:id="test">test</a>+<wicket:extend></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.javaindex 1e9b227661..f729b0ec24 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java@@ -1,35 +1,13 @@-package com.pmease.gitplex.web.page.test;--import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.html.link.Link;--import com.pmease.commons.loader.Plugin;-import com.pmease.commons.loader.PluginManager;-import com.pmease.commons.wicket.page.CommonPage;-import com.pmease.gitplex.core.GitPlex;--@SuppressWarnings("serial")-public class TestPage extends CommonPage {-- @Override- protected void onInitialize() {- super.onInitialize();-- add(new Link<Void>("test") {-- @Override- public void onClick() {- for (Plugin plugin: GitPlex.getInstance(PluginManager.class).getPlugins()) {- System.out.println(plugin.getId() + ":" + plugin.getVersion());- }- }-- });- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);- }--}+package com.pmease.gitplex.web.page.test;++import com.pmease.commons.wicket.page.CommonPage;++@SuppressWarnings("serial")+public class TestPage extends CommonPage {++ @Override+ protected void onInitialize() {+ super.onInitialize();+ }++}