Skip to content

The Unified and Autonomous Development Platform

Complete the new pull request page.

robin shinef9d0ad310afb
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js
index 16fa88d9ac..0a0abf000e 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.js
@@ -282,19 +282,6 @@ pmease.commons = {
},
- decorateTable: function(table) {
- if ($(table).attr("class") == undefined)
- $(table).addClass("table table-striped table-hover table-condensed");
- },
-
- decorateElements: function(scope) {
- if ($(scope).is("table"))
- pmease.commons.decorateTable(scope);
- $(scope).find("table").each(function() {
- pmease.commons.decorateTable(this);
- });
- },
-
setupCollapse: function(triggerId, targetId) {
var trigger = $("#" + triggerId);
var target = $("#" + targetId);
@@ -571,11 +558,6 @@ $(function() {
pmease.commons.dropdown.hideExcept(source);
});
- Wicket.Event.subscribe("/dom/node/added", function(jqEvent, element) {
- pmease.commons.decorateElements(element);
- });
- pmease.commons.decorateElements(document);
-
$(document).keypress(function(e) {
if (e.keyCode == 27) { // esc
if ($(".select2-drop:visible").length == 0) {
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultProjectManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultProjectManager.java
index 87758fd95b..c80b838132 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultProjectManager.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultProjectManager.java
@@ -80,18 +80,6 @@ public class DefaultProjectManager extends AbstractGenericDao<Project> implement
checkSanity(project);
}
- private void setupHooks(Project project) {
- File hooksDir = new File(project.code().repoDir(), "hooks");
-
- File gitUpdateHookFile = new File(hooksDir, "update");
- FileUtils.writeFile(gitUpdateHookFile, gitUpdateHook);
- gitUpdateHookFile.setExecutable(true);
-
- File gitPostReceiveHookFile = new File(hooksDir, "post-receive");
- FileUtils.writeFile(gitPostReceiveHookFile, gitPostReceiveHook);
- gitPostReceiveHookFile.setExecutable(true);
- }
-
@Transactional
@Override
public void delete(Project project) {
@@ -165,7 +153,6 @@ public class DefaultProjectManager extends AbstractGenericDao<Project> implement
FileUtils.cleanDir(forked.code().repoDir());
forked.code().clone(project.code().repoDir().getAbsolutePath(), true);
- setupHooks(forked);
checkSanity(forked);
}
@@ -185,17 +172,30 @@ public class DefaultProjectManager extends AbstractGenericDao<Project> implement
@Override
public void checkSanity(Project project) {
logger.debug("Checking sanity of project '{}'...", project);
- File codeDir = project.code().repoDir();
- if (codeDir.exists() && !Project.isCode(new Git(codeDir))) {
- logger.warn("Directory '" + codeDir + "' is not a valid gitop repository, removing...");
- FileUtils.deleteDir(codeDir);
+
+ Git git = project.code();
+
+ if (git.repoDir().exists() && !git.isValid()) {
+ logger.warn("Directory '" + git.repoDir() + "' is not a valid git repository, removing...");
+ FileUtils.deleteDir(git.repoDir());
+ }
+
+ if (!git.repoDir().exists()) {
+ logger.warn("Initializing git repository in '" + git.repoDir() + "'...");
+ FileUtils.createDir(git.repoDir());
+ git.init(true);
}
- if (!codeDir.exists()) {
- logger.warn("Initializing gitop repository in '" + codeDir + "'...");
- FileUtils.createDir(codeDir);
- new Git(codeDir).init(true);
- setupHooks(project);
+ if (!Project.isCode(git)) {
+ File hooksDir = new File(project.code().repoDir(), "hooks");
+
+ File gitUpdateHookFile = new File(hooksDir, "update");
+ FileUtils.writeFile(gitUpdateHookFile, gitUpdateHook);
+ gitUpdateHookFile.setExecutable(true);
+
+ File gitPostReceiveHookFile = new File(hooksDir, "post-receive");
+ FileUtils.writeFile(gitPostReceiveHookFile, gitPostReceiveHook);
+ gitPostReceiveHookFile.setExecutable(true);
}
logger.debug("Syncing branches of project '{}'...", project);
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultPullRequestManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultPullRequestManager.java
index 9e1a6f700f..d1e06337f4 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultPullRequestManager.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/manager/impl/DefaultPullRequestManager.java
@@ -105,6 +105,7 @@ public class DefaultPullRequestManager extends AbstractGenericDao<PullRequest> i
git.clone(request.getTarget().getProject().code().repoDir().getAbsolutePath(),
false, true, true, request.getTarget().getName());
+
git.reset(null, null);
request.getTarget().getProject().setCodeSandbox(git);
@@ -116,7 +117,6 @@ public class DefaultPullRequestManager extends AbstractGenericDao<PullRequest> i
request.setMergeResult(new MergeResult(targetHead, sourceHead, targetHead, sourceHead));
} else {
git.fetch(request.getSource().getProject().code().repoDir().getAbsolutePath(), sourceHead);
-
String mergeBase = git.calcMergeBase(targetHead, sourceHead);
if (git.merge(sourceHead, null, null, null))
request.setMergeResult(new MergeResult(targetHead, sourceHead, mergeBase, git.parseRevision("HEAD", true)));
diff --git a/gitop.model/src/main/java/com/pmease/gitop/model/Project.java b/gitop.model/src/main/java/com/pmease/gitop/model/Project.java
index 3e910ed458..b681cf087c 100644
--- a/gitop.model/src/main/java/com/pmease/gitop/model/Project.java
+++ b/gitop.model/src/main/java/com/pmease/gitop/model/Project.java
@@ -224,12 +224,12 @@ public class Project extends AbstractEntity implements UserBelonging {
* <tt>true</tt> if valid; <tt>false</tt> otherwise
*/
public static boolean isCode(Git git) {
- File preReceiveHook = new File(git.repoDir(), "hooks/update");
- if (!preReceiveHook.exists())
+ File updateHook = new File(git.repoDir(), "hooks/update");
+ if (!updateHook.exists())
return false;
try {
- String content = FileUtils.readFileToString(preReceiveHook);
+ String content = FileUtils.readFileToString(updateHook);
return content.contains("GITOP_USER_ID");
} catch (IOException e) {
throw new RuntimeException(e);
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css
index 154531573e..d54548d8e2 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css
@@ -637,16 +637,53 @@ tr.diff-line.new { background: #cfc; }
.dropdown-panel .directory-chooser .title {font-weight: bold; border-bottom: 1px solid #888888;}
.dropdown-panel .alert.empty-directory-choice {margin: 0px;}
-.comparable-branch-selector .connector {margin-top: 4px; color: #888; font-weight: bold; font-size: 16px;}
-.comparable-branch-selector>div {float: left;}
-.comparable-branch-selector {clear: left;}
+.comparable-branch-selector .connector {margin-top: 4px; color: #BBB; font-weight: bold; font-size: 16px;}
/* PULL REQUESTS PAGE */
#pull-requests {padding: 20px;}
#pull-requests>table {width: 100%;}
-.new-pull-request>.title {font-size: 20px; font-weight: bold; margin-bottom: 20px;}
-.new-pull-request>.head {padding: 0;}
-.new-pull-request>.head>div {float:left;}
-.new-pull-request>.head>.icon {margin: 2px 4px 0 6px;}
-.new-pull-request>div {margin-bottom: 20px;}
+.pull-request>.title {font-size: 20px; font-weight: bold; margin-bottom: 20px;}
+.pull-request>.branches {background: #F2F2F2; padding: 8px; border-radius: 4px;}
+
+/* Fix the issue that branch selectors can not be displayed in a single line in Chrome */
+.pull-request>.branches .input-group-addon {width: auto;}
+
+.pull-request>.branches>.label {font-size: 16px; color: #444; margin-top: 4px;}
+.pull-request>.branches>.target {margin-right: 12px;}
+
+.pull-request>div {margin-bottom: 20px;}
+.pull-request>.feedback {background: #F2F2F2; padding: 4px; border-radius: 4px;}
+.pull-request>.feedback table {width: 100%; border-collapse: separate;}
+.pull-request>.feedback td {vertical-align: top;}
+
+.pull-request>.feedback td.message {width: 70%;}
+.pull-request>.feedback td.message>.title {margin: -1px 4px 8px -1px;}
+.pull-request>.feedback td.message>.comment {margin: 0 4px -1px -1px;}
+.pull-request>.feedback td.message>.comment>textarea {resize: vertical; min-height: 64px;}
+
+.pull-request>.feedback td.status {width: 30%; border:1px solid #CCC; border-radius: 4px;
+ padding: 16px; margin: 1px 0 1px 4px;}
+.pull-request>.feedback td.status .summary {font-size: 18px; margin-bottom: 16px;}
+.pull-request>.feedback td.status .detail {margin-bottom: 16px;}
+.pull-request>.feedback td.status tr>td:first-child {width: 1%;}
+.pull-request>.feedback .icon {font-size: 26px; margin-right: 8px; display: none;}
+
+.pull-request>.feedback.danger .icon-exclamation, .pull-request>.feedback.error .icon-exclamation {
+ display: block; color: #A94442;}
+.pull-request>.feedback.warning .icon-warning-sign {display: block; color: #8A6D3B;}
+.pull-request>.feedback.info .icon-info-circle {display: block; color: #31708F;}
+.pull-request>.feedback.success .icon-ok-circle {display: block; color: #3C763D;}
+
+.pull-request>.feedback.danger .status, .pull-request>.feedback.info .status {border: none;}
+.pull-request>.feedback.danger {background: #F2DEDE; border: 1px solid #EBCCD1; color: #A94442;}
+.pull-request>.feedback.info {background: #D9EDF7; border: 1px solid #BCE8F1; color: #31708F;}
+
+.pull-request>.feedback.success {color: #3C763D;}
+.pull-request>.feedback.success td.status {border-color: #BDDCA4; background-color: #DFF0D8;}
+
+.pull-request>.feedback.warning {color: #8A6D3B;}
+.pull-request>.feedback.warning td.status {border-color: #F7DEAB; background-color: #FCF8E3;}
+
+.pull-request>.feedback.error {color: #A94442;}
+.pull-request>.feedback.error td.status {border-color: #EBCCD1; background-color: #F2DEDE;}
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.html b/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.html
index 3f8cb04ccb..8c0c4aa8d0 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.html
@@ -1,15 +1,15 @@
<wicket:panel>
<div class="comparable-branch-selector clearfix">
- <div class="project">
+ <div class="project pull-left">
<div class="input-group">
- <span wicket:id="projectLabel" class="input-group-addon">Project</span>
+ <span class="input-group-addon"><span class="icon icon-repo"></span></span>
<input wicket:id="projectChoice" type="hidden" class="form-control"></input>
</div>
</div>
- <div class="connector">&mdash;</div>
- <div class="branch">
+ <div class="connector pull-left">&mdash;</div>
+ <div class="branch pull-left">
<div class="input-group">
- <span wicket:id="branchLabel" class="input-group-addon">Branch</span>
+ <span class="input-group-addon"><span class="icon icon-git-branch"></span></span>
<input wicket:id="branchChoice" type="hidden" class="form-control"></input>
</div>
</div>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.java b/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.java
index ea03cfdd47..1c8bdcf131 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/component/comparablebranchselector/ComparableBranchSelector.java
@@ -1,16 +1,15 @@
package com.pmease.gitop.web.component.comparablebranchselector;
-import javax.annotation.Nullable;
-
import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
-import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.FormComponentPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
+import com.pmease.commons.wicket.ajaxlistener.ajaxloadingindicator.AjaxLoadingIndicator;
import com.pmease.gitop.core.Gitop;
import com.pmease.gitop.core.manager.BranchManager;
import com.pmease.gitop.model.Branch;
@@ -26,10 +25,6 @@ public class ComparableBranchSelector extends FormComponentPanel<Branch> {
private IModel<Project> selectedProjectModel;
- private final String projectLabel;
-
- private final String branchLabel;
-
/**
* Construct with current project model and selected branch model.
*
@@ -39,13 +34,8 @@ public class ComparableBranchSelector extends FormComponentPanel<Branch> {
* model of current project. Note that the model object should never be null
* @param selectedBranchModel
* model of selected branch
- * @param proejctLabel
- * label of the project choice
- * @param branchLabel
- * label of the branch choice
*/
- public ComparableBranchSelector(String id, IModel<Project> currentProjectModel, IModel<Branch> selectedBranchModel,
- @Nullable String projectLabel, @Nullable String branchLabel) {
+ public ComparableBranchSelector(String id, IModel<Project> currentProjectModel, IModel<Branch> selectedBranchModel) {
super(id, selectedBranchModel);
this.currentProjectModel = currentProjectModel;
@@ -73,8 +63,6 @@ public class ComparableBranchSelector extends FormComponentPanel<Branch> {
};
- this.projectLabel = projectLabel;
- this.branchLabel = branchLabel;
}
protected void onChange(AjaxRequestTarget target) {
@@ -86,9 +74,6 @@ public class ComparableBranchSelector extends FormComponentPanel<Branch> {
setOutputMarkupId(true);
- add(new Label("projectLabel", (projectLabel != null? projectLabel: "Project")));
- add(new Label("branchLabel", (branchLabel != null? branchLabel: "Branch")));
-
add(new ComparableProjectChoice("projectChoice", currentProjectModel, selectedProjectModel).add(new OnChangeAjaxBehavior() {
@Override
@@ -96,6 +81,12 @@ public class ComparableBranchSelector extends FormComponentPanel<Branch> {
target.add(ComparableBranchSelector.this);
onChange(target);
}
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new AjaxLoadingIndicator());
+ }
}));
@@ -116,6 +107,12 @@ public class ComparableBranchSelector extends FormComponentPanel<Branch> {
onChange(target);
}
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new AjaxLoadingIndicator());
+ }
+
}));
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.html
index 43600ae3b3..0abd67caf3 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.html
@@ -1,40 +1,51 @@
<wicket:panel>
- <div class="new-pull-request">
- <div class="head">
- <div wicket:id="target" class="target"></div>
- <div class="icon icon-arrow-slim-left icon-2x"></div>
- <div wicket:id="source" class="source"></div>
+ <div class="pull-request">
+ <div class="branches clearfix">
+ <div class="pull-left label">To: </div>
+ <div wicket:id="target" class="target pull-left"></div>
+ <div class="pull-left label">From: </div>
+ <div wicket:id="source" class="source pull-left"></div>
</div>
- <div class="body clearfix">
+ <div wicket:id="feedback" class="feedback">
<table>
<tr>
- <td>
- <div wicket:id="message" class="message">
- <div class="title">
- <input wicket:id="title" type="text" class="form-control">
- </div>
- <div class="comment">
- <textarea wicket:id="comment" class="form-control"></textarea>
- </div>
+ <td wicket:id="message" class="message">
+ <div wicket:id="titleContainer" class="title">
+ <input wicket:id="title" type="text" class="form-control" placeholder="Title has to be specified">
</div>
- </td>
- <td>
- <div wicket:id="status" class="status">
- <div wicket:id="summary" class="summary"></div>
- <div wicket:id="detail" class="detail"></div>
- <wicket:enclosure child="rejectReasons">
- <ul>
- <li wicket:id="rejectReasons">
- <span wicket:id="reason"></span>
- </li>
- </ul>
- </wicket:enclosure>
- <input wicket:id="send" value="Send Pull Request" class="btn btn-lg btn-primary"></input>
- <input wicket:id="view" value="View Pull Request" class="btn btn-lg btn-primary"></input>
+ <div class="comment">
+ <textarea wicket:id="comment" class="form-control" rows="8" placeholder="Comment"></textarea>
</div>
</td>
+ <td class="status">
+ <table>
+ <tr>
+ <td>
+ <span class="icon icon-ok-circle"></span>
+ <span class="icon icon-info-circle"></span>
+ <span class="icon icon-warning-sign"></span>
+ <span class="icon icon-exclamation"></span>
+ </td>
+ <td>
+ <div wicket:id="summary" class="summary"></div>
+ <div wicket:id="detail" class="detail"></div>
+ <wicket:enclosure child="rejectReasons">
+ <ul class="detail">
+ <li wicket:id="rejectReasons">
+ <span wicket:id="reason"></span>
+ </li>
+ </ul>
+ </wicket:enclosure>
+ <input wicket:id="send" value="Send Pull Request" class="btn btn-lg btn-primary send"></input>
+ <input wicket:id="view" value="View Pull Request" class="btn btn-lg btn-primary"></input>
+ </td>
+ </tr>
+ </table>
+ </td>
</tr>
</table>
</div>
+ <div wicket:id="commits" class="commits"></div>
+ <div wicket:id="changes" class="changes"></div>
</div>
</wicket:panel>
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.java
index 303a028ce8..76190f8791 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/pullrequest/NewPullRequestPanel.java
@@ -7,8 +7,10 @@ import static com.pmease.gitop.model.PullRequest.Status.PENDING_UPDATE;
import java.util.List;
+import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+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;
@@ -31,21 +33,23 @@ import com.pmease.gitop.model.Branch;
import com.pmease.gitop.model.Project;
import com.pmease.gitop.model.PullRequest;
import com.pmease.gitop.model.User;
+import com.pmease.gitop.web.component.commit.CommitsTablePanel;
import com.pmease.gitop.web.component.comparablebranchselector.ComparableBranchSelector;
import com.pmease.gitop.web.model.EntityModel;
import com.pmease.gitop.web.page.project.AbstractProjectPage;
+import com.pmease.gitop.web.page.project.source.commit.diff.DiffViewPanel;
@SuppressWarnings("serial")
public class NewPullRequestPanel extends Panel {
- private String title;
+ private static final String IMPOSSIBLE_TITLE = "*[@TITLE IMPOSSIBLE@]*";
+
+ private String title = IMPOSSIBLE_TITLE;
@SuppressWarnings("unused")
private String comment;
- private IModel<Branch> targetModel;
-
- private IModel<Branch> sourceModel;
+ private IModel<Branch> targetModel, sourceModel;
private IModel<User> submitterModel;
@@ -53,6 +57,8 @@ public class NewPullRequestPanel extends Panel {
private IModel<PullRequest> pullRequestModel;
+ private MarkupContainer feedbackContainer, commitsPanel, diffViewPanel;
+
public NewPullRequestPanel(String id, Branch target, Branch source, User submitter) {
super(id);
@@ -107,46 +113,82 @@ public class NewPullRequestPanel extends Panel {
}
};
- final WebMarkupContainer messageContainer = new WebMarkupContainer("message") {
+
+ add(new ComparableBranchSelector("target", currentProjectModel, targetModel) {
@Override
- protected void onConfigure() {
- super.onConfigure();
- PullRequest request = getPullRequest();
- setVisible(request.isNew() && (request.getStatus() == PENDING_APPROVAL || request.getStatus() == PENDING_INTEGRATE));
+ protected void onChange(AjaxRequestTarget target) {
+ super.onChange(target);
+ onBranchChange(target);
}
- };
- messageContainer.setOutputMarkupPlaceholderTag(true);
- add(messageContainer);
-
- final WebMarkupContainer statusContainer = new WebMarkupContainer("status");
- statusContainer.setOutputMarkupId(true);
- add(statusContainer);
+ }.setRequired(true));
- add(new ComparableBranchSelector("target", currentProjectModel, targetModel, "Target Project", "Target Branch") {
+ add(new ComparableBranchSelector("source", currentProjectModel, sourceModel) {
@Override
protected void onChange(AjaxRequestTarget target) {
super.onChange(target);
- target.add(messageContainer);
- target.add(statusContainer);
+ onBranchChange(target);
}
}.setRequired(true));
+
+ add(feedbackContainer = new WebMarkupContainer("feedback"));
+ feedbackContainer.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ PullRequest request = getPullRequest();
+ if (request.isNew()) {
+ if (getTarget().equals(getSource())) {
+ return "danger";
+ } else if (request.getStatus() == INTEGRATED) {
+ return "info";
+ } else if (request.getStatus() == PENDING_UPDATE) {
+ return "danger";
+ } else if (title == null) {
+ return "error";
+ } else if (request.getMergeResult().getMergeHead() == null) {
+ return "warning";
+ } else {
+ return "success";
+ }
+ } else {
+ return "info";
+ }
+ }
+
+ }));
+ feedbackContainer.setOutputMarkupId(true);
- add(new ComparableBranchSelector("source", currentProjectModel, sourceModel, "Source Project", "Source Branch") {
+ WebMarkupContainer messageContainer;
+ feedbackContainer.add(messageContainer = new WebMarkupContainer("message") {
@Override
- protected void onChange(AjaxRequestTarget target) {
- super.onChange(target);
- target.add(messageContainer);
- target.add(statusContainer);
+ protected void onConfigure() {
+ super.onConfigure();
+ PullRequest request = getPullRequest();
+ setVisible(request.isNew() && (request.getStatus() == PENDING_APPROVAL || request.getStatus() == PENDING_INTEGRATE));
}
- }.setRequired(true));
+ });
+
+ WebMarkupContainer titleContainer = new WebMarkupContainer("titleContainer");
+ titleContainer.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
- TextField<String> titleField = new TextField<String>("title", new IModel<String>() {
+ @Override
+ public String getObject() {
+ if (title == null)
+ return "has-error";
+ else
+ return "";
+ }
+
+ }));
+ messageContainer.add(titleContainer);
+
+ final TextField<String> titleField = new TextField<String>("title", new IModel<String>() {
@Override
public void detach() {
@@ -154,10 +196,7 @@ public class NewPullRequestPanel extends Panel {
@Override
public String getObject() {
- if (title != null)
- return title;
- else
- return getDefaultTitle();
+ return getTitle();
}
@Override
@@ -171,34 +210,39 @@ public class NewPullRequestPanel extends Panel {
@Override
protected void onUpdate(AjaxRequestTarget target) {
+ titleField.processInput();
}
});
- titleField.setRequired(true);
- messageContainer.add(titleField);
+ titleContainer.add(titleField);
- TextArea<String> commentArea = new TextArea<String>("comment", new PropertyModel<String>(this, "comment"));
+ final TextArea<String> commentArea = new TextArea<String>("comment", new PropertyModel<String>(this, "comment"));
commentArea.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
+ commentArea.processInput();
}
});
messageContainer.add(commentArea);
- statusContainer.add(new Link<Void>("send") {
+ feedbackContainer.add(new Link<Void>("send") {
@Override
protected void onConfigure() {
super.onConfigure();
PullRequest request = getPullRequest();
- setVisible(request.isNew());
- setEnabled(request.getStatus() == PENDING_APPROVAL || request.getStatus() == PENDING_INTEGRATE);
+ setVisible(request.isNew()
+ && (request.getStatus() == PENDING_APPROVAL || request.getStatus() == PENDING_INTEGRATE));
}
@Override
public void onClick() {
+ String title = getTitle();
+ if (title != null) {
+
+ }
}
@Override
@@ -211,7 +255,7 @@ public class NewPullRequestPanel extends Panel {
});
- statusContainer.add(new Link<Void>("view") {
+ feedbackContainer.add(new Link<Void>("view") {
@Override
protected void onConfigure() {
@@ -226,7 +270,7 @@ public class NewPullRequestPanel extends Panel {
});
- statusContainer.add(new Label("summary", new AbstractReadOnlyModel<String>() {
+ feedbackContainer.add(new Label("summary", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
@@ -239,6 +283,8 @@ public class NewPullRequestPanel extends Panel {
return "No changes to pull.";
} else if (request.getStatus() == PENDING_UPDATE) {
return "Gate keeper of target project rejects the pull request.";
+ } else if (title == null) {
+ return "Title has to be specified.";
} else if (request.getMergeResult().getMergeHead() == null) {
return "There are merge conflicts.";
} else {
@@ -252,7 +298,7 @@ public class NewPullRequestPanel extends Panel {
}));
- statusContainer.add(new Label("detail", new AbstractReadOnlyModel<String>() {
+ feedbackContainer.add(new Label("detail", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
@@ -263,8 +309,10 @@ public class NewPullRequestPanel extends Panel {
if (request.getStatus() == INTEGRATED) {
return "Target branch '" + getTarget().getName() + "' of project '" + getTarget().getProject()
+ "' is already update to date.";
- } else if (request.getStatus() != PENDING_UPDATE) {
- return "You can still send the pull request.";
+ } else if (title != null
+ && request.getStatus() != PENDING_UPDATE
+ && request.getMergeResult().getMergeHead() == null) {
+ return "But you can still send the pull request.";
}
}
return null;
@@ -272,7 +320,7 @@ public class NewPullRequestPanel extends Panel {
}));
- statusContainer.add(new ListView<String>("rejectReasons", new LoadableDetachableModel<List<String>>() {
+ feedbackContainer.add(new ListView<String>("rejectReasons", new LoadableDetachableModel<List<String>>() {
@Override
protected List<String> load() {
@@ -295,6 +343,58 @@ public class NewPullRequestPanel extends Panel {
}
});
+
+ IModel<Project> projectModel = new AbstractReadOnlyModel<Project>() {
+
+ @Override
+ public Project getObject() {
+ return getTarget().getProject();
+ }
+
+ };
+ add(commitsPanel = new CommitsTablePanel("commits", commitsModel, projectModel) {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ setVisible(getPullRequest().getStatus() != INTEGRATED);
+ }
+
+ });
+ commitsPanel.setOutputMarkupPlaceholderTag(true);
+
+ add(diffViewPanel = new DiffViewPanel("changes", projectModel, new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ return getPullRequest().getMergeResult().getMergeBase();
+ }
+
+ }, new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ return getSource().getHeadCommit();
+ }
+
+ }) {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ setVisible(getPullRequest().getStatus() != INTEGRATED);
+ }
+
+ });
+ diffViewPanel.setOutputMarkupPlaceholderTag(true);
+ }
+
+ private void onBranchChange(AjaxRequestTarget target) {
+ target.add(feedbackContainer);
+ target.add(commitsPanel);
+ target.add(diffViewPanel);
}
private Branch getTarget() {
@@ -335,5 +435,11 @@ public class NewPullRequestPanel extends Panel {
super.onDetach();
}
-
+
+ private String getTitle() {
+ if (IMPOSSIBLE_TITLE.equals(title))
+ return getDefaultTitle();
+ else
+ return title;
+ }
}