Skip to content

The Unified and Autonomous Development Platform

Fix some bugs

robin shineba2801c13913
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/markdown/markdown.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/markdown/markdown.js
index f53ce2ff28..66bcf7d0db 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/markdown/markdown.js
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/markdown/markdown.js
@@ -1,341 +1,341 @@
-pmease.commons.markdown = {
- init: function(inputId, atWhoLimit, callback, uploadUrl, attachmentSupport, attachmentMaxSize) {
- var $input = $("#" + inputId);
- function onSelectUrl(isImage) {
- var $modal = $("" +
- "<div class='modal'>" +
- "<div class='modal-dialog'>" +
- "<div class='modal-content'>" +
- "<div id='" + inputId + "-urlselector'></div>" +
- "</div>" +
- "</div>" +
- "</div>");
- // make sure to append to body to avoid z-index issues causing modal to sit in background
- $("body").append($modal);
- $modal.modal({show: true, backdrop: "static", keyboard: true});
- $modal.on('hidden.bs.modal', function (e) {
- $modal.remove();
- $input.focus();
- });
- $modal.keydown(function(e) {
- if (e.keyCode == 27)
- $input.data("ignoreEsc", true);
- });
- $modal.keyup(function(e) {
- if (e.keyCode == 27)
- $input.data("ignoreEsc", true);
- });
- if (isImage)
- callback("selectImage");
- else
- callback("selectLink");
- }
-
- $input.markdown({
- onShow: function(e) {
- var $mdEditor = $input.closest(".md-editor");
- $mdEditor.attr("tabindex", "0");
- $mdEditor.bind("keydown", "Ctrl+E", function(e) {
- $mdEditor.find(">.md-header .fa-search").parent().click();
- e.preventDefault();
- e.stopPropagation();
- });
- $input.bind("keydown", "F11", function(e) {
- if ($mdEditor.hasClass("md-fullscreen-mode"))
- $mdEditor.find(".exit-fullscreen").click();
- else
- $mdEditor.find(".md-control-fullscreen").click();
- e.preventDefault();
- e.stopPropagation();
- });
- },
- onFullscreen: function(e) {
- $input.trigger("fullscreen");
- },
- onExitFullscreen: function(e) {
- $input.trigger("exitFullscreen");
- },
- onPreview: function(e) {
- callback("markdownPreview", e.getContent());
- return "";
- },
- onFocus: function(e) {
- var $mask = $input.prevAll(".md-emojis").find(".mask");
- if ($input.is(":visible"))
- $mask.hide();
- else
- $mask.show();
- },
- additionalButtons: [[{
- name: "custom",
- data: [{
- name: "cmdHelp",
- toggle: true,
- title: "Help",
- icon: "fa fa-question",
- callback: function(e){
- $input.prevAll(".md-help").toggle();
- $input.trigger("resized");
- }
- }, {
- name: "cmdEmojis",
- toggle: true,
- title: "Emojis",
- icon: "fa fa-smile-o",
- callback: function(e){
- var $emojis = $input.prevAll(".md-emojis");
- if ($emojis.find(".emoji").length == 0)
- callback("loadEmojis");
- $emojis.toggle();
- $input.trigger("resized");
- }
- }, {
- name: "cmdURL2",
- title: "Image",
- hotkey: 'Ctrl+L',
- icon: "fa fa-link",
- callback: function(e){
- onSelectUrl(false);
- }
- }, {
- name: "cmdImage2",
- title: "Image",
- hotkey: 'Ctrl+G',
- icon: "fa fa-picture-o",
- callback: function(e){
- onSelectUrl(true);
- }
- }]
- }]],
- iconlibrary: "fa",
- resize: "vertical"
- });
-
- $input.css({resize: "vertical"});
- $input.before(
- "<div class='md-help'>" +
- " <a href='https://help.github.com/articles/github-flavored-markdown/' target='_blank'>GitHub flavored markdown</a> " +
- " is accepted here. You can also input <b>:<em>emoji</em>:</b> to insert an emoji." +
- "</div>");
- $input.before(
- "<div class='md-emojis'>" +
- " <div class='loading'>Loading emojis...</div>" +
- "</div>");
-
- var $btnGroup2 = $input.parent().find(".md-header .btn-group:nth-child(2)");
- $btnGroup2.find(".fa-link").parent().remove();
- $btnGroup2.find(".fa-picture-o").parent().remove();
- $btnGroup2.append($input.parent().find(".md-header .fa-link").parent());
- $btnGroup2.append($input.parent().find(".md-header .fa-picture-o").parent());
- $btnGroup2.append($input.parent().find(".md-header .fa-smile-o").parent());
-
- $input[0].cachedEmojis = [];
-
- $input.atwho({
- at: ':',
- callbacks: {
- remoteFilter: function(query, renderCallback) {
- $input.data("atWhoEmojiRenderCallback", renderCallback);
- callback("emojiQuery", query);
- }
- },
- displayTpl: "<li><i class='emoji' style='background-image:url(${url})'></i> ${name} </li>",
- insertTpl: ':${name}:',
- limit: atWhoLimit
- });
-
- if (attachmentSupport) {
- var input = $input[0];
-
- input.addEventListener("paste", function(e) {
- for (var i = 0; i < e.clipboardData.items.length; i++) {
- var item = e.clipboardData.items[i];
- if (item.type.indexOf("image") != -1) {
- var file = item.getAsFile();
- if (!file.name) {
- if (item.type.indexOf("png") != -1)
- file.name = "image.png";
- else if (item.type.indexOf("gif") != -1)
- file.name = "image.gif";
- else
- file.name = "image.jpg";
- }
- uploadFile(file);
- break;
- }
- }
- });
-
- input.addEventListener("dragover", function(e) {
- $input.addClass("drag-over");
- e.stopPropagation();
- e.preventDefault();
- }, false);
-
- input.addEventListener("dragleave", function(e) {
- $input.removeClass("drag-over");
- e.stopPropagation();
- e.preventDefault();
- }, false);
-
- input.addEventListener("drop", function(e) {
- $input.removeClass("drag-over");
- e.stopPropagation();
- e.preventDefault();
- var files = e.target.files || e.dataTransfer.files;
- if (files && files.length != 0)
- uploadFile(files[0]);
- }, false);
-
- function uploadFile(file) {
- if (file.size> attachmentMaxSize) {
- var message = "!!Upload should be less than " + Math.round(attachmentMaxSize/1024/1024) + " Mb!!";
- pmease.commons.markdown.updateUploadMessage($input, message);
- } else {
- var xhr = new XMLHttpRequest();
- var val = $input.val();
- var i=1;
- var message = "[Uploading file...]";
- while (val.indexOf(message) != -1) {
- message = "[Uploading file" + (++i) + "...]";
- }
-
- xhr.replaceMessage = message;
- if ($input.range().length == 0) {
- $input.caret(message);
- } else {
- $input.range(message);
- $input.caret($input.caret()+message.length);
- }
-
- xhr.onload = function() {
- if (xhr.status == 200) {
- callback("insertUrl", xhr.responseText, xhr.replaceMessage);
- } else {
- pmease.commons.markdown.updateUploadMessage($input,
- "!!" + xhr.responseText + "!!", xhr.replaceMessage);
- }
- };
- xhr.onerror = function() {
- pmease.commons.markdown.updateUploadMessage($input,
- "!!Unable to connect to server!!", xhr.replaceMessage);
- };
- xhr.open("POST", uploadUrl, true);
- xhr.setRequestHeader("File-Name", encodeURIComponent(file.name));
- xhr.setRequestHeader("Attachment-Support", attachmentSupport);
- xhr.send(file);
- }
- }
- }
- },
- onEmojisLoaded: function(inputId, emojis) {
- var $input = $("#" + inputId);
- var $emojis = $input.prevAll(".md-emojis");
- $emojis.html("<div class='mask'></div><div class='content'><div>");
- var contentHtml = "";
- for (var i in emojis) {
- var emoji = emojis[i];
- contentHtml += "<a class='emoji' title='" + emoji.name + "'><img src='" + emoji.url + "'></img></a> ";
- }
- var $content = $emojis.find(".content");
- $content.html(contentHtml);
- $content.find(".emoji").click(function() {
- if (!$input.is(":visible"))
- return;
-
- var emojiName = $(this).attr("title");
-
- var beforeChar, afterChar;
- var index = $input.caret();
- var content = $input.val();
- var length = content.length;
- if (length == 0) {
- beforeChar = afterChar = ' ';
- } else if (index == 0) {
- beforeChar = ' ';
- afterChar = content.charAt(0);
- } else if (index == length) {
- beforeChar = content.charAt(index-1);
- afterChar = ' ';
- } else {
- beforeChar = content.charAt(index-1);
- afterChar = content.charAt(index);
- }
-
- if (!/\s/.test(beforeChar))
- beforeChar = ' ';
- else
- beforeChar = '';
-
- if (!/\s/.test(afterChar))
- afterChar = ' ';
- else
- afterChar = '';
-
- $input.caret(beforeChar + ":" + emojiName + ":" + afterChar);
- });
- $input.trigger("resized");
- },
-
- insertUrl: function(inputId, isImage, url, name, replaceMessage) {
- var $input = $("#" + inputId);
-
- var sanitizedUrl = $('<div>'+url+'</div>').text();
- var message;
- var defaultDescription = "Enter description here";
- if (name)
- message = '['+name+']('+sanitizedUrl+')';
- else
- message = '[' + defaultDescription + ']('+sanitizedUrl+')';
-
- if (isImage)
- message = "!" + message;
-
- pmease.commons.markdown.updateUploadMessage($input, message, replaceMessage);
- if (!name)
- $input.range($input.caret()-message.length+1, $input.caret()-message.length+defaultDescription.length+1);
-
- pmease.commons.form.markDirty($input.closest("form.leave-confirm"));
- },
-
- updateUploadMessage: function($input, message, replaceMessage) {
- var isError = message.indexOf("!!") == 0;
- var pos = $input.val().indexOf(replaceMessage);
- if (pos != -1) {
- var currentPos = $input.caret();
- $input.range(pos, pos+ replaceMessage.length).range(message);
- if (!isError) {
- if (currentPos<pos)
- $input.caret(currentPos);
- else if (currentPos>pos+replaceMessage.length)
- $input.caret(currentPos + message.length - replaceMessage.length);
- else
- $input.caret($input.caret()+message.length);
- }
- } else {
- if ($input.range().length != 0) {
- $input.range(message);
- if (!isError)
- $input.caret($input.caret() + message.length);
- } else {
- $input.caret(message);
- if (isError)
- $input.range($input.caret()-message.length, $input.caret());
- }
- }
- },
-
- initFileUpload: function(uploadId, maxSize, maxSizeForDisplay) {
- var $upload = $('#' + uploadId);
- $upload.change(function() {
- if ($upload[0].files[0].size>maxSize) {
- $upload.closest('form').prepend("<div class='alert alert-danger'>Size of upload file should be less than "
- + maxSizeForDisplay + "<button type='button' class='close' data-dismiss='alert' aria-label='Close'>" +
- "<span aria-hidden='true'>&times;</span></button></div>");
- } else {
- $upload.closest('form').children(".alert").remove();
- $upload.next().click();
- }
- })
- }
-}
+pmease.commons.markdown = {
+ init: function(inputId, atWhoLimit, callback, uploadUrl, attachmentSupport, attachmentMaxSize) {
+ var $input = $("#" + inputId);
+ function onSelectUrl(isImage) {
+ var $modal = $("" +
+ "<div class='modal'>" +
+ "<div class='modal-dialog'>" +
+ "<div class='modal-content'>" +
+ "<div id='" + inputId + "-urlselector'></div>" +
+ "</div>" +
+ "</div>" +
+ "</div>");
+ // make sure to append to body to avoid z-index issues causing modal to sit in background
+ $("body").append($modal);
+ $modal.modal({show: true, backdrop: "static", keyboard: true});
+ $modal.on('hidden.bs.modal', function (e) {
+ $modal.remove();
+ $input.focus();
+ });
+ $modal.keydown(function(e) {
+ if (e.keyCode == 27)
+ $input.data("ignoreEsc", true);
+ });
+ $modal.keyup(function(e) {
+ if (e.keyCode == 27)
+ $input.data("ignoreEsc", true);
+ });
+ if (isImage)
+ callback("selectImage");
+ else
+ callback("selectLink");
+ }
+
+ $input.markdown({
+ onShow: function(e) {
+ var $mdEditor = $input.closest(".md-editor");
+ $mdEditor.attr("tabindex", "0");
+ $mdEditor.bind("keydown", "Ctrl+E", function(e) {
+ $mdEditor.find(">.md-header .fa-search").parent().click();
+ e.preventDefault();
+ e.stopPropagation();
+ });
+ $input.bind("keydown", "F11", function(e) {
+ if ($mdEditor.hasClass("md-fullscreen-mode"))
+ $mdEditor.find(".exit-fullscreen").click();
+ else
+ $mdEditor.find(".md-control-fullscreen").click();
+ e.preventDefault();
+ e.stopPropagation();
+ });
+ },
+ onFullscreen: function(e) {
+ $input.trigger("fullscreen");
+ },
+ onExitFullscreen: function(e) {
+ $input.trigger("exitFullscreen");
+ },
+ onPreview: function(e) {
+ callback("markdownPreview", e.getContent());
+ return "";
+ },
+ onFocus: function(e) {
+ var $mask = $input.prevAll(".md-emojis").find(".mask");
+ if ($input.is(":visible"))
+ $mask.hide();
+ else
+ $mask.show();
+ },
+ additionalButtons: [[{
+ name: "custom",
+ data: [{
+ name: "cmdHelp",
+ toggle: true,
+ title: "Help",
+ icon: "fa fa-question",
+ callback: function(e){
+ $input.prevAll(".md-help").toggle();
+ $input.trigger("resized");
+ }
+ }, {
+ name: "cmdEmojis",
+ toggle: true,
+ title: "Emojis",
+ icon: "fa fa-smile-o",
+ callback: function(e){
+ var $emojis = $input.prevAll(".md-emojis");
+ if ($emojis.find(".emoji").length == 0)
+ callback("loadEmojis");
+ $emojis.toggle();
+ $input.trigger("resized");
+ }
+ }, {
+ name: "cmdURL2",
+ title: "Attachment",
+ hotkey: 'Ctrl+L',
+ icon: "fa fa-link",
+ callback: function(e){
+ onSelectUrl(false);
+ }
+ }, {
+ name: "cmdImage2",
+ title: "Image",
+ hotkey: 'Ctrl+G',
+ icon: "fa fa-picture-o",
+ callback: function(e){
+ onSelectUrl(true);
+ }
+ }]
+ }]],
+ iconlibrary: "fa",
+ resize: "vertical"
+ });
+
+ $input.css({resize: "vertical"});
+ $input.before(
+ "<div class='md-help'>" +
+ " <a href='https://help.github.com/articles/github-flavored-markdown/' target='_blank'>GitHub flavored markdown</a> " +
+ " is accepted here. You can also input <b>:<em>emoji</em>:</b> to insert an emoji." +
+ "</div>");
+ $input.before(
+ "<div class='md-emojis'>" +
+ " <div class='loading'>Loading emojis...</div>" +
+ "</div>");
+
+ var $btnGroup2 = $input.parent().find(".md-header .btn-group:nth-child(2)");
+ $btnGroup2.find(".fa-link").parent().remove();
+ $btnGroup2.find(".fa-picture-o").parent().remove();
+ $btnGroup2.append($input.parent().find(".md-header .fa-link").parent());
+ $btnGroup2.append($input.parent().find(".md-header .fa-picture-o").parent());
+ $btnGroup2.append($input.parent().find(".md-header .fa-smile-o").parent());
+
+ $input[0].cachedEmojis = [];
+
+ $input.atwho({
+ at: ':',
+ callbacks: {
+ remoteFilter: function(query, renderCallback) {
+ $input.data("atWhoEmojiRenderCallback", renderCallback);
+ callback("emojiQuery", query);
+ }
+ },
+ displayTpl: "<li><i class='emoji' style='background-image:url(${url})'></i> ${name} </li>",
+ insertTpl: ':${name}:',
+ limit: atWhoLimit
+ });
+
+ if (attachmentSupport) {
+ var input = $input[0];
+
+ input.addEventListener("paste", function(e) {
+ for (var i = 0; i < e.clipboardData.items.length; i++) {
+ var item = e.clipboardData.items[i];
+ if (item.type.indexOf("image") != -1) {
+ var file = item.getAsFile();
+ if (!file.name) {
+ if (item.type.indexOf("png") != -1)
+ file.name = "image.png";
+ else if (item.type.indexOf("gif") != -1)
+ file.name = "image.gif";
+ else
+ file.name = "image.jpg";
+ }
+ uploadFile(file);
+ break;
+ }
+ }
+ });
+
+ input.addEventListener("dragover", function(e) {
+ $input.addClass("drag-over");
+ e.stopPropagation();
+ e.preventDefault();
+ }, false);
+
+ input.addEventListener("dragleave", function(e) {
+ $input.removeClass("drag-over");
+ e.stopPropagation();
+ e.preventDefault();
+ }, false);
+
+ input.addEventListener("drop", function(e) {
+ $input.removeClass("drag-over");
+ e.stopPropagation();
+ e.preventDefault();
+ var files = e.target.files || e.dataTransfer.files;
+ if (files && files.length != 0)
+ uploadFile(files[0]);
+ }, false);
+
+ function uploadFile(file) {
+ if (file.size> attachmentMaxSize) {
+ var message = "!!Upload should be less than " + Math.round(attachmentMaxSize/1024/1024) + " Mb!!";
+ pmease.commons.markdown.updateUploadMessage($input, message);
+ } else {
+ var xhr = new XMLHttpRequest();
+ var val = $input.val();
+ var i=1;
+ var message = "[Uploading file...]";
+ while (val.indexOf(message) != -1) {
+ message = "[Uploading file" + (++i) + "...]";
+ }
+
+ xhr.replaceMessage = message;
+ if ($input.range().length == 0) {
+ $input.caret(message);
+ } else {
+ $input.range(message);
+ $input.caret($input.caret()+message.length);
+ }
+
+ xhr.onload = function() {
+ if (xhr.status == 200) {
+ callback("insertUrl", xhr.responseText, xhr.replaceMessage);
+ } else {
+ pmease.commons.markdown.updateUploadMessage($input,
+ "!!" + xhr.responseText + "!!", xhr.replaceMessage);
+ }
+ };
+ xhr.onerror = function() {
+ pmease.commons.markdown.updateUploadMessage($input,
+ "!!Unable to connect to server!!", xhr.replaceMessage);
+ };
+ xhr.open("POST", uploadUrl, true);
+ xhr.setRequestHeader("File-Name", encodeURIComponent(file.name));
+ xhr.setRequestHeader("Attachment-Support", attachmentSupport);
+ xhr.send(file);
+ }
+ }
+ }
+ },
+ onEmojisLoaded: function(inputId, emojis) {
+ var $input = $("#" + inputId);
+ var $emojis = $input.prevAll(".md-emojis");
+ $emojis.html("<div class='mask'></div><div class='content'><div>");
+ var contentHtml = "";
+ for (var i in emojis) {
+ var emoji = emojis[i];
+ contentHtml += "<a class='emoji' title='" + emoji.name + "'><img src='" + emoji.url + "'></img></a> ";
+ }
+ var $content = $emojis.find(".content");
+ $content.html(contentHtml);
+ $content.find(".emoji").click(function() {
+ if (!$input.is(":visible"))
+ return;
+
+ var emojiName = $(this).attr("title");
+
+ var beforeChar, afterChar;
+ var index = $input.caret();
+ var content = $input.val();
+ var length = content.length;
+ if (length == 0) {
+ beforeChar = afterChar = ' ';
+ } else if (index == 0) {
+ beforeChar = ' ';
+ afterChar = content.charAt(0);
+ } else if (index == length) {
+ beforeChar = content.charAt(index-1);
+ afterChar = ' ';
+ } else {
+ beforeChar = content.charAt(index-1);
+ afterChar = content.charAt(index);
+ }
+
+ if (!/\s/.test(beforeChar))
+ beforeChar = ' ';
+ else
+ beforeChar = '';
+
+ if (!/\s/.test(afterChar))
+ afterChar = ' ';
+ else
+ afterChar = '';
+
+ $input.caret(beforeChar + ":" + emojiName + ":" + afterChar);
+ });
+ $input.trigger("resized");
+ },
+
+ insertUrl: function(inputId, isImage, url, name, replaceMessage) {
+ var $input = $("#" + inputId);
+
+ var sanitizedUrl = $('<div>'+url+'</div>').text();
+ var message;
+ var defaultDescription = "Enter description here";
+ if (name)
+ message = '['+name+']('+sanitizedUrl+')';
+ else
+ message = '[' + defaultDescription + ']('+sanitizedUrl+')';
+
+ if (isImage)
+ message = "!" + message;
+
+ pmease.commons.markdown.updateUploadMessage($input, message, replaceMessage);
+ if (!name)
+ $input.range($input.caret()-message.length+1, $input.caret()-message.length+defaultDescription.length+1);
+
+ pmease.commons.form.markDirty($input.closest("form.leave-confirm"));
+ },
+
+ updateUploadMessage: function($input, message, replaceMessage) {
+ var isError = message.indexOf("!!") == 0;
+ var pos = $input.val().indexOf(replaceMessage);
+ if (pos != -1) {
+ var currentPos = $input.caret();
+ $input.range(pos, pos+ replaceMessage.length).range(message);
+ if (!isError) {
+ if (currentPos<pos)
+ $input.caret(currentPos);
+ else if (currentPos>pos+replaceMessage.length)
+ $input.caret(currentPos + message.length - replaceMessage.length);
+ else
+ $input.caret($input.caret()+message.length);
+ }
+ } else {
+ if ($input.range().length != 0) {
+ $input.range(message);
+ if (!isError)
+ $input.caret($input.caret() + message.length);
+ } else {
+ $input.caret(message);
+ if (isError)
+ $input.range($input.caret()-message.length, $input.caret());
+ }
+ }
+ },
+
+ initFileUpload: function(uploadId, maxSize, maxSizeForDisplay) {
+ var $upload = $('#' + uploadId);
+ $upload.change(function() {
+ if ($upload[0].files[0].size>maxSize) {
+ $upload.closest('form').prepend("<div class='alert alert-danger'>Size of upload file should be less than "
+ + maxSizeForDisplay + "<button type='button' class='close' data-dismiss='alert' aria-label='Close'>" +
+ "<span aria-hidden='true'>&times;</span></button></div>");
+ } else {
+ $upload.closest('form').children(".alert").remove();
+ $upload.next().click();
+ }
+ })
+ }
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java
index 4b52b553ef..6261c857cb 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java
@@ -34,7 +34,7 @@ public class PullRequestReference extends AbstractEntity {
private PullRequest referencedBy;
@Column(nullable=false)
- private Date date = new Date();
+ private Date date;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(nullable=false)
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/PullRequestReferenceGenerator.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/PullRequestReferenceGenerator.java
deleted file mode 100644
index 421d7357b4..0000000000
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/PullRequestReferenceGenerator.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.pmease.gitplex.core.entity.persistlistener;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.apache.wicket.util.lang.Objects;
-import org.hibernate.CallbackException;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.type.Type;
-
-import com.pmease.commons.hibernate.PersistListener;
-import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.hibernate.dao.EntityCriteria;
-import com.pmease.commons.markdown.MarkdownManager;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.PullRequestComment;
-import com.pmease.gitplex.core.entity.PullRequestReference;
-import com.pmease.gitplex.core.entity.PullRequestStatusChange;
-import com.pmease.gitplex.core.manager.AccountManager;
-import com.pmease.gitplex.core.manager.UrlManager;
-import com.pmease.gitplex.core.util.markdown.PullRequestParser;
-
-@Singleton
-public class PullRequestReferenceGenerator implements PersistListener {
-
- private final MarkdownManager markdownManager;
-
- private final Dao dao;
-
- private final AccountManager userManager;
-
- @Inject
- public PullRequestReferenceGenerator(MarkdownManager markdownManager,
- Dao dao, AccountManager userManager,
- UrlManager urlManager) {
- this.markdownManager = markdownManager;
- this.dao = dao;
- this.userManager = userManager;
- }
-
- @Override
- public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
- throws CallbackException {
- return false;
- }
-
- @Override
- public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
- String[] propertyNames, Type[] types) throws CallbackException {
- if (entity instanceof PullRequest) {
- PullRequest request = (PullRequest) entity;
- for (int i=0; i<propertyNames.length; i++) {
- if (propertyNames[i].equals("description")) {
- String description = (String) currentState[i];
- String prevDescription = (String) previousState[i];
- if (!Objects.equal(description, prevDescription) && description != null) {
- String html = markdownManager.parse(description);
- for (PullRequest referenced: new PullRequestParser().parseRequests(html))
- saveReference(referenced, request);
- }
- break;
- }
- }
- } else if (entity instanceof PullRequestComment) {
- PullRequestComment comment = (PullRequestComment) entity;
- for (int i=0; i<propertyNames.length; i++) {
- if (propertyNames[i].equals("content")) {
- String content = (String) currentState[i];
- String prevContent = (String) previousState[i];
- if (!content.equals(prevContent)) {
- String html = markdownManager.parse(content);
- Collection<PullRequest> requests = new PullRequestParser().parseRequests(html);
- for (PullRequest request: requests)
- saveReference(request, comment.getRequest());
- }
- break;
- }
- }
- } else if (entity instanceof PullRequestStatusChange) {
- PullRequestStatusChange statusChange = (PullRequestStatusChange) entity;
- for (int i=0; i<propertyNames.length; i++) {
- if (propertyNames[i].equals("note")) {
- String note = (String) currentState[i];
- String prevNote = (String) previousState[i];
- if (!note.equals(prevNote)) {
- String html = markdownManager.parse(note);
- Collection<PullRequest> requests = new PullRequestParser().parseRequests(html);
- for (PullRequest request: requests)
- saveReference(request, statusChange.getRequest());
- }
- break;
- }
- }
- }
-
- return false;
- }
-
- private void saveReference(PullRequest referenced, PullRequest referencedBy) {
- if (!referenced.equals(referencedBy)) {
- EntityCriteria<PullRequestReference> criteria = EntityCriteria.of(PullRequestReference.class);
- criteria.add(Restrictions.eq("referenced", referenced));
- criteria.add(Restrictions.eq("referencedBy", referencedBy));
- if (dao.find(criteria) == null) {
- PullRequestReference reference = new PullRequestReference();
- reference.setReferencedBy(referencedBy);
- reference.setReferenced(referenced);
- reference.setUser(userManager.getCurrent());
- dao.persist(reference);
- }
- }
- }
-
- @Override
- public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
- throws CallbackException {
- if (entity instanceof PullRequest) {
- PullRequest request = (PullRequest) entity;
- for (int i=0; i<propertyNames.length; i++) {
- if (propertyNames[i].equals("description")) {
- String description = (String) state[i];
- if (description != null) {
- String html = markdownManager.parse(description);
- for (PullRequest referenced: new PullRequestParser().parseRequests(html))
- saveReference(referenced, request);
- }
- break;
- }
- }
- } else if (entity instanceof PullRequestComment) {
- PullRequestComment comment = (PullRequestComment) entity;
- for (int i=0; i<propertyNames.length; i++) {
- if (propertyNames[i].equals("content")) {
- String content = (String) state[i];
- String html = markdownManager.parse(content);
- Collection<PullRequest> requests = new PullRequestParser().parseRequests(html);
- for (PullRequest request: requests)
- saveReference(request, comment.getRequest());
- break;
- }
- }
- } else if (entity instanceof PullRequestStatusChange) {
- PullRequestStatusChange statusChange = (PullRequestStatusChange) entity;
- for (int i=0; i<propertyNames.length; i++) {
- if (propertyNames[i].equals("note")) {
- String note = (String) state[i];
- if (note != null) {
- String html = markdownManager.parse(note);
- Collection<PullRequest> requests = new PullRequestParser().parseRequests(html);
- for (PullRequest request: requests)
- saveReference(request, statusChange.getRequest());
- }
- break;
- }
- }
- }
-
- return true;
- }
-
- @Override
- public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
- throws CallbackException {
- }
-
-}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestReferenceManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestReferenceManager.java
index b865fcf030..2f676577a2 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestReferenceManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestReferenceManager.java
@@ -1,20 +1,67 @@
package com.pmease.gitplex.core.manager.impl;
+import java.util.Date;
+
import javax.inject.Inject;
import javax.inject.Singleton;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.AbstractEntityManager;
import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.commons.loader.Listen;
+import com.pmease.commons.markdown.MarkdownManager;
+import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.PullRequestReference;
+import com.pmease.gitplex.core.event.pullrequest.MarkdownAware;
+import com.pmease.gitplex.core.event.pullrequest.PullRequestChangeEvent;
+import com.pmease.gitplex.core.manager.AccountManager;
import com.pmease.gitplex.core.manager.PullRequestReferenceManager;
+import com.pmease.gitplex.core.util.markdown.PullRequestParser;
@Singleton
public class DefaultPullRequestReferenceManager extends AbstractEntityManager<PullRequestReference>
implements PullRequestReferenceManager {
+ private final MarkdownManager markdownManager;
+
+ private final AccountManager accountManager;
+
@Inject
- public DefaultPullRequestReferenceManager(Dao dao) {
+ public DefaultPullRequestReferenceManager(Dao dao, AccountManager accountManager,
+ MarkdownManager markdownManager) {
super(dao);
+ this.markdownManager = markdownManager;
+ this.accountManager = accountManager;
}
+ @Transactional
+ @Listen
+ public void on(PullRequestChangeEvent event) {
+ if (event instanceof MarkdownAware) {
+ String markdown = ((MarkdownAware)event).getMarkdown();
+ if (markdown != null) {
+ String html = markdownManager.parse(markdown);
+
+ for (PullRequest referenced: new PullRequestParser().parseRequests(html)) {
+ if (!referenced.equals(event.getRequest())) {
+ EntityCriteria<PullRequestReference> criteria = EntityCriteria.of(PullRequestReference.class);
+ criteria.add(Restrictions.eq("referenced", referenced));
+ criteria.add(Restrictions.eq("referencedBy", event.getRequest()));
+ if (dao.find(criteria) == null) {
+ PullRequestReference reference = new PullRequestReference();
+ reference.setReferencedBy(event.getRequest());
+ reference.setReferenced(referenced);
+ reference.setDate(new Date());
+ reference.setUser(accountManager.getCurrent());
+ save(reference);
+ }
+ }
+ }
+ }
+ }
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java
index 50a49f1e29..cf14334b04 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java
@@ -85,8 +85,6 @@ public class DefaultPullRequestWatchManager extends AbstractEntityManager<PullRe
PullRequest request = event.getRequest();
Account user = event.getUser();
- Collection<Account> mentionUsers = new HashSet<>();
-
/*
* verification is often performed automatically by robots (such as CI system), and it does not make
* sense to make them watching the pull request
@@ -105,7 +103,13 @@ public class DefaultPullRequestWatchManager extends AbstractEntityManager<PullRe
makeContributorsWatching(request.getLatestUpdate());
} else if (event instanceof PullRequestAssigned) {
watch(request, request.getAssignee(), "You are set to watch this pull request as you are assigned to integrate it.");
- } else if (event instanceof MarkdownAware) {
+ } else if (event instanceof PullRequestUpdated) {
+ PullRequestUpdated updated = (PullRequestUpdated) event;
+ makeContributorsWatching(updated.getUpdate());
+ }
+
+ Collection<Account> mentionUsers = new HashSet<>();
+ if (event instanceof MarkdownAware) {
MarkdownAware markdownAware = (MarkdownAware) event;
String markdown = markdownAware.getMarkdown();
if (markdown != null) {
@@ -115,11 +119,7 @@ public class DefaultPullRequestWatchManager extends AbstractEntityManager<PullRe
watch(request, mention, "You are set to watch this pull request as you are mentioned in code comment.");
}
}
- } else if (event instanceof PullRequestUpdated) {
- PullRequestUpdated updated = (PullRequestUpdated) event;
- makeContributorsWatching(updated.getUpdate());
- }
-
+ }
Collection<Account> watchUsers = new HashSet<>();
for (PullRequestWatch watch: request.getWatches()) {
@@ -139,6 +139,8 @@ public class DefaultPullRequestWatchManager extends AbstractEntityManager<PullRe
}
}
+ // mentioned users will be receiving email separately, so we do not need to notify
+ // them here
watchUsers.removeAll(mentionUsers);
if ((event instanceof PullRequestOpened || event instanceof PullRequestAssigned)
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilter.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilter.java
index ed495c7e4c..ec14607334 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilter.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentFilter.java
@@ -130,7 +130,7 @@ public class CodeCommentFilter implements Serializable {
String pathQuery = path.replace('*', '%');
if (pathQuery.endsWith("/"))
pathQuery += "%";
- criteria.add(Restrictions.ilike("path", pathQuery));
+ criteria.add(Restrictions.ilike("commentPos.path", pathQuery));
}
if (title != null)
criteria.add(Restrictions.ilike("title", "%" + title + "%"));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html
index bbba66217c..29335ed19f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentListPanel.html
@@ -1,44 +1,44 @@
-<wicket:panel>
- <table class="code-comments">
- <tr>
- <td class="filter">
- <div class="head">Filter options</div>
- <div class="body">
- <div class="btn-group shortcuts">
- <a wicket:id="myComments" class="btn btn-sm btn-default">My</a>
- <a wicket:id="myUnresolvedComments" class="btn btn-sm btn-default">My unresolved</a>
- <a wicket:id="unresolvedComments" class="btn btn-sm btn-default">Unresolved</a>
- <a wicket:id="allComments" class="btn btn-sm btn-default">All</a>
- </div>
- <form wicket:id="filterForm">
- <div wicket:id="editor"></div>
- <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
- </form>
- </div>
- </td>
- <td class="spacing">&nbsp;</td>
- <td class="result">
- <div wicket:id="alert" class="alert alert-warning"></div>
- <table wicket:id="comments"></table>
- </td>
- </tr>
- </table>
- <wicket:fragment wicket:id="commentFrag">
- <div class="first-line">
- <a wicket:id="title" class="title"><span wicket:id="label"></span></a>
- <span wicket:id="resolved" title="This comment is resolved" class="resolved fa fa-check-circle"></span>
- </div>
- <div class="second-line">
- commented by
- <a wicket:id="user" class="user"></a>
- on
- <a wicket:id="file" class="file"><span wicket:id="label"></span></a>
- <span wicket:id="date"></span>
- </div>
- <div wicket:id="lastEvent" class="third-line">
- <a wicket:id="user" class="user"></a>
- <span wicket:id="description"></span>
- <span wicket:id="date"></span>
- </div>
- </wicket:fragment>
+<wicket:panel>
+ <table class="code-comments">
+ <tr>
+ <td class="filter">
+ <div class="head">Filter options</div>
+ <div class="body">
+ <div class="btn-group shortcuts">
+ <a wicket:id="myComments" class="btn btn-sm btn-default">My</a>
+ <a wicket:id="myUnresolvedComments" class="btn btn-sm btn-default">My unresolved</a>
+ <a wicket:id="unresolvedComments" class="btn btn-sm btn-default">Unresolved</a>
+ <a wicket:id="allComments" class="btn btn-sm btn-default">All</a>
+ </div>
+ <form wicket:id="filterForm">
+ <div wicket:id="editor" class="nofocus"></div>
+ <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
+ </form>
+ </div>
+ </td>
+ <td class="spacing">&nbsp;</td>
+ <td class="result">
+ <div wicket:id="alert" class="alert alert-warning"></div>
+ <table wicket:id="comments"></table>
+ </td>
+ </tr>
+ </table>
+ <wicket:fragment wicket:id="commentFrag">
+ <div class="first-line">
+ <a wicket:id="title" class="title"><span wicket:id="label"></span></a>
+ <span wicket:id="resolved" title="This comment is resolved" class="resolved fa fa-check-circle"></span>
+ </div>
+ <div class="second-line">
+ commented by
+ <a wicket:id="user" class="user"></a>
+ on
+ <a wicket:id="file" class="file"><span wicket:id="label"></span></a>
+ <span wicket:id="date"></span>
+ </div>
+ <div wicket:id="lastEvent" class="third-line">
+ <a wicket:id="user" class="user"></a>
+ <span wicket:id="description"></span>
+ <span wicket:id="date"></span>
+ </div>
+ </wicket:fragment>
</wicket:panel>
\ No newline at end of file
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.css
index fed7dab4e2..7a99d6f1e5 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
@@ -77,12 +77,10 @@
padding: 10px 0;
}
-#request-detail div.activity, #request-detail div.activity a {
+#request-detail div.activity>.head, #request-detail div.activity>.head a,
+#request-detail div.activity>.body>.actions a {
color: #999;
}
-#request-detail div.activity>div.body {
- color: #444;
-}
#request-detail div.activity .operations>* {
color: #DDD;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.html
index 3320ff0948..6450ca0c3f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestlist/RequestListPage.html
@@ -1,49 +1,49 @@
-<wicket:extend>
- <div id="request-list">
- <div class="head">
- <a wicket:id="filters" class="btn btn-default"><i class="fa fa-filter"></i> Filters <span class="caret"></span></a>
- <a wicket:id="sortBy" class="btn btn-default"> <i class="fa fa-sort"></i> Sort by <span class="caret"></span></a>
- <a wicket:id="newRequest" class="btn btn-default"><i class="fa fa-plus"></i> Open New</a>
- </div>
- <table class="body">
- <tr>
- <td class="filter">
- <div class="head">Filter options</div>
- <div class="body">
- <form wicket:id="filterForm">
- <div wicket:id="editor"></div>
- <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
- </form>
- </div>
- </td>
- <td class="spacing">&nbsp;</td>
- <td class="result">
- <table wicket:id="requests"></table>
- </td>
- </tr>
- </table>
- </div>
- <wicket:fragment wicket:id="requestFrag">
- <div class="first-line clearfix">
- <a wicket:id="title" class="title pull-left"></a>
- <span wicket:id="number" class="number pull-left"></span>
- <span class="branches pull-left">
- <a wicket:id="target" class="branch"></a>
- <span class="fa fa-long-arrow-left"></span>
- <a wicket:id="source" class="branch"></a>
- </span>
- <span wicket:id="status" class="status pull-right"></span>
- </div>
- <div class="second-line">
- <a wicket:id="submitter" class="user"></a>
- submitted
- <span wicket:id="date"></span>
- <span wicket:id="lastEvent">
- ,
- <a wicket:id="user"></a>
- <span wicket:id="description"></span>
- <span wicket:id="date"></span>
- </span>
- </div>
- </wicket:fragment>
+<wicket:extend>
+ <div id="request-list">
+ <div class="head">
+ <a wicket:id="filters" class="btn btn-default"><i class="fa fa-filter"></i> Filters <span class="caret"></span></a>
+ <a wicket:id="sortBy" class="btn btn-default"> <i class="fa fa-sort"></i> Sort by <span class="caret"></span></a>
+ <a wicket:id="newRequest" class="btn btn-default"><i class="fa fa-plus"></i> Open New</a>
+ </div>
+ <table class="body">
+ <tr>
+ <td class="filter">
+ <div class="head">Filter options</div>
+ <div class="body">
+ <form wicket:id="filterForm">
+ <div wicket:id="editor" class="nofocus"></div>
+ <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
+ </form>
+ </div>
+ </td>
+ <td class="spacing">&nbsp;</td>
+ <td class="result">
+ <table wicket:id="requests"></table>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <wicket:fragment wicket:id="requestFrag">
+ <div class="first-line clearfix">
+ <a wicket:id="title" class="title pull-left"></a>
+ <span wicket:id="number" class="number pull-left"></span>
+ <span class="branches pull-left">
+ <a wicket:id="target" class="branch"></a>
+ <span class="fa fa-long-arrow-left"></span>
+ <a wicket:id="source" class="branch"></a>
+ </span>
+ <span wicket:id="status" class="status pull-right"></span>
+ </div>
+ <div class="second-line">
+ <a wicket:id="submitter" class="user"></a>
+ submitted
+ <span wicket:id="date"></span>
+ <span wicket:id="lastEvent">
+ ,
+ <a wicket:id="user"></a>
+ <span wicket:id="description"></span>
+ <span wicket:id="date"></span>
+ </span>
+ </div>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file