Skip to content

The Unified and Autonomous Development Platform

midwork

robin shine285bfccbed4c
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchAffinalBranchesByNames.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchAffinalBranchesByNames.java
index a967f3318f..b5935ccf71 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchAffinalBranchesByNames.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchAffinalBranchesByNames.java
@@ -17,25 +17,26 @@ import com.pmease.gitplex.core.model.Repository;
@Editable(name="Specify Branch Names", order=100)
public class MatchAffinalBranchesByNames implements AffinalBranchMatcher {
- private List<RepoAndBranch> repoAndBranches = new ArrayList<>();
+ private List<String> repoAndBranches = new ArrayList<>();
@Editable(name="Branch Names")
@BranchChoice(Scope.AFFINAL)
@OmitName
@NotNull
@Size(min=1, message="At least one branch has to be selected.")
- public List<RepoAndBranch> getRepoAndBranches() {
+ public List<String> getRepoAndBranches() {
return repoAndBranches;
}
- public void setRepoAndBranches(List<RepoAndBranch> repoAndBranches) {
+ public void setRepoAndBranches(List<String> repoAndBranches) {
this.repoAndBranches = repoAndBranches;
}
@Override
public boolean matches(Repository repository, String branch) {
- for (RepoAndBranch each: getRepoAndBranches()) {
- if (each.getRepoId().equals(repository.getId()) && each.getBranch().equals(branch))
+ for (String each: getRepoAndBranches()) {
+ RepoAndBranch repoAndBranch = new RepoAndBranch(each);
+ if (repoAndBranch.getRepoId().equals(repository.getId()) && repoAndBranch.getBranch().equals(branch))
return true;
}
return false;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchGlobalBranchesByNames.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchGlobalBranchesByNames.java
index c139dc586e..a8c4480884 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchGlobalBranchesByNames.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/branchmatcher/MatchGlobalBranchesByNames.java
@@ -17,25 +17,26 @@ import com.pmease.gitplex.core.model.Repository;
@Editable(name="Specify Branch Names", order=100)
public class MatchGlobalBranchesByNames implements GlobalBranchMatcher {
- private List<RepoAndBranch> repoAndBranches = new ArrayList<>();
+ private List<String> repoAndBranches = new ArrayList<>();
@Editable(name="Branch Names")
@BranchChoice(Scope.GLOBAL)
@OmitName
@NotNull
@Size(min=1, message="At least one branch has to be selected.")
- public List<RepoAndBranch> getRepoAndBranches() {
+ public List<String> getRepoAndBranches() {
return repoAndBranches;
}
- public void setRepoAndBranches(List<RepoAndBranch> repoAndBranches) {
+ public void setRepoAndBranches(List<String> repoAndBranches) {
this.repoAndBranches = repoAndBranches;
}
@Override
public boolean matches(Repository repository, String branch) {
- for (RepoAndBranch each: getRepoAndBranches()) {
- if (each.getRepoId().equals(repository.getId()) && each.getBranch().equals(branch))
+ for (String each: getRepoAndBranches()) {
+ RepoAndBranch repoAndBranch = new RepoAndBranch(each);
+ if (repoAndBranch.getRepoId().equals(repository.getId()) && repoAndBranch.getBranch().equals(branch))
return true;
}
return false;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/RepoAndRevision.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/RepoAndRevision.java
index 074143f36d..6f83a5d431 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/RepoAndRevision.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/RepoAndRevision.java
@@ -77,10 +77,11 @@ public class RepoAndRevision implements Serializable {
return getRepository().getRevCommit(getObjectId());
}
- public static void trim(Collection<? extends RepoAndRevision> repoAndBranches) {
+ public static void trim(Collection<String> repoAndBranches) {
Dao dao = GitPlex.getInstance(Dao.class);
- for (Iterator<? extends RepoAndRevision> it = repoAndBranches.iterator(); it.hasNext();) {
- if (dao.get(Repository.class, it.next().getRepoId()) == null)
+ for (Iterator<String> it = repoAndBranches.iterator(); it.hasNext();) {
+ RepoAndRevision repoAndRevision = new RepoAndRevision(it.next());
+ if (dao.get(Repository.class, repoAndRevision.getRepoId()) == null)
it.remove();
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchMultiChoice.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchMultiChoice.java
index 4a109d5c67..9142e1ad1e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchMultiChoice.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchMultiChoice.java
@@ -136,7 +136,14 @@ public class AffinalBranchMultiChoice extends FormComponentPanel<Collection<Stri
@Override
protected void convertInput() {
- setConvertedInput(branchChoice.getConvertedInput());
+ Collection<String> branchIds = new ArrayList<>();
+ Collection<String> branches = branchChoice.getConvertedInput();
+ if (branches != null) {
+ for (String branch: branches)
+ branchIds.add(new RepoAndBranch(selectedRepoModel.getObject(), branch).toString());
+ }
+
+ setConvertedInput(branchIds);
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchSingleChoice.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchSingleChoice.java
index 518cbffd76..bf01cafacd 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchSingleChoice.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/AffinalBranchSingleChoice.java
@@ -120,7 +120,15 @@ public class AffinalBranchSingleChoice extends FormComponentPanel<String> {
@Override
protected void convertInput() {
- setConvertedInput(branchChoice.getConvertedInput());
+ String branchId;
+ String branch = branchChoice.getConvertedInput();
+ if (branch != null) {
+ branchId = new RepoAndBranch(selectedRepoModel.getObject(), branch).toString();
+ } else {
+ branchId = null;
+ }
+
+ setConvertedInput(branchId);
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchMultiChoice.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchMultiChoice.java
index 037492c5d3..ac4101b77a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchMultiChoice.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchMultiChoice.java
@@ -129,7 +129,14 @@ public class GlobalBranchMultiChoice extends FormComponentPanel<Collection<Strin
@Override
protected void convertInput() {
- setConvertedInput(branchChoice.getConvertedInput());
+ Collection<String> branchIds = new ArrayList<>();
+ Collection<String> branches = branchChoice.getConvertedInput();
+ if (branches != null) {
+ for (String branch: branches)
+ branchIds.add(new RepoAndBranch(repoModel.getObject(), branch).toString());
+ }
+
+ setConvertedInput(branchIds);
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchSingleChoice.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchSingleChoice.java
index 55a5d396a8..472babd6fa 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchSingleChoice.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchchoice/GlobalBranchSingleChoice.java
@@ -111,7 +111,15 @@ public class GlobalBranchSingleChoice extends FormComponentPanel<String> {
@Override
protected void convertInput() {
- setConvertedInput(branchChoice.getConvertedInput());
+ String branchId;
+ String branch = branchChoice.getConvertedInput();
+ if (branch != null) {
+ branchId = new RepoAndBranch(repoModel.getObject(), branch).toString();
+ } else {
+ branchId = null;
+ }
+
+ setConvertedInput(branchId);
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.html
new file mode 100644
index 0000000000..a78a369b08
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.html
@@ -0,0 +1,6 @@
+<wicket:panel>
+ <span class="repository-and-branch">
+ <a wicket:id="repositoryPicker" class="repository"></a>
+ <a wicket:id="branchPicker" class="branch"></a>
+ </span>
+</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.java
new file mode 100644
index 0000000000..ab9fd3d39f
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.java
@@ -0,0 +1,89 @@
+package com.pmease.gitplex.web.component.branchpicker;
+
+import javax.annotation.Nullable;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.head.CssHeaderItem;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.request.resource.CssResourceReference;
+
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.model.Repository;
+import com.pmease.gitplex.web.component.repopicker.RepositoryPicker;
+import com.pmease.gitplex.web.model.AffinalRepositoriesModel;
+
+@SuppressWarnings("serial")
+public abstract class AffinalBranchPicker extends Panel {
+
+ private Long repoId;
+
+ private String branch;
+
+ public AffinalBranchPicker(String id, Long repoId, String branch) {
+ super(id);
+
+ this.repoId = repoId;
+ this.branch = branch;
+ }
+
+ private void newBranchPicker(@Nullable AjaxRequestTarget target) {
+ BranchPicker branchPicker = new BranchPicker("branchPicker", new LoadableDetachableModel<Repository>() {
+
+ @Override
+ protected Repository load() {
+ return getRepository();
+ }
+
+ }, branch) {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, String branch) {
+ AffinalBranchPicker.this.onSelect(target, getRepository(), branch);
+ }
+
+ };
+ if (target != null) {
+ replace(branchPicker);
+ target.add(branchPicker);
+ } else {
+ add(branchPicker);
+ }
+ }
+
+ private Repository getRepository() {
+ return GitPlex.getInstance(Dao.class).load(Repository.class, repoId);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new RepositoryPicker("repositoryPicker", new AffinalRepositoriesModel(repoId), repoId) {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Repository repository) {
+ repoId = repository.getId();
+ branch = repository.getDefaultBranch();
+ newBranchPicker(target);
+ AffinalBranchPicker.this.onSelect(target, repository, branch);
+ }
+
+ });
+ newBranchPicker(null);
+
+ setOutputMarkupId(true);
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(CssHeaderItem.forReference(new CssResourceReference(
+ AffinalBranchPicker.class, "branch-picker.css")));
+ }
+
+ protected abstract void onSelect(AjaxRequestTarget target, Repository repository, String branch);
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchPicker.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchPicker.java
new file mode 100644
index 0000000000..8e7f6a2333
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchPicker.java
@@ -0,0 +1,62 @@
+package com.pmease.gitplex.web.component.branchpicker;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.unbescape.html.HtmlEscape;
+
+import com.pmease.commons.wicket.component.DropdownLink;
+import com.pmease.gitplex.core.model.Repository;
+
+@SuppressWarnings("serial")
+public abstract class BranchPicker extends DropdownLink {
+
+ private final IModel<Repository> repoModel;
+
+ private String branch;
+
+ public BranchPicker(String id, IModel<Repository> repoModel, String branch) {
+ super(id);
+
+ this.repoModel = repoModel;
+ this.branch = branch;
+ }
+
+ @Override
+ protected Component newContent(String id) {
+ return new BranchSelector(id, repoModel, branch) {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, String branch) {
+ close(target);
+ BranchPicker.this.branch = branch;
+ target.add(BranchPicker.this);
+
+ BranchPicker.this.onSelect(target, branch);
+ }
+
+ };
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ setEscapeModelStrings(false);
+ }
+
+ @Override
+ public IModel<?> getBody() {
+ return Model.of(String.format("<i class='fa fa-ext fa-branch'></i> <span>%s</span> <i class='fa fa-caret-down'></i>",
+ HtmlEscape.escapeHtml5(branch)));
+ }
+
+ @Override
+ protected void onDetach() {
+ repoModel.detach();
+ super.onDetach();
+ }
+
+ protected abstract void onSelect(AjaxRequestTarget target, String branch);
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchSelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchSelector.html
new file mode 100644
index 0000000000..c0afbed842
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchSelector.html
@@ -0,0 +1,10 @@
+<wicket:panel>
+ <div class="branch-selector">
+ <input wicket:id="branch" class="form-control input-sm branch" placeholder="Search branch"></input>
+ <ul wicket:id="branches" class="branches autosize list-unstyled">
+ <li wicket:id="branches" class="selectable">
+ <a wicket:id="link"><span wicket:id="label"></span></a>
+ </li>
+ </ul>
+ </div>
+</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchSelector.java
new file mode 100644
index 0000000000..7bee2b65a2
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/BranchSelector.java
@@ -0,0 +1,192 @@
+package com.pmease.gitplex.web.component.branchpicker;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.apache.wicket.ajax.attributes.CallbackParameter;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+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.form.TextField;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.IRequestParameters;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.resource.CssResourceReference;
+import org.apache.wicket.request.resource.JavaScriptResourceReference;
+import org.eclipse.jgit.lib.Ref;
+
+import com.pmease.commons.git.GitUtils;
+import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;
+import com.pmease.commons.wicket.assets.hotkeys.HotkeysResourceReference;
+import com.pmease.commons.wicket.behavior.FormComponentInputBehavior;
+import com.pmease.gitplex.core.model.Repository;
+
+@SuppressWarnings("serial")
+public abstract class BranchSelector extends Panel {
+
+ private final IModel<Repository> repoModel;
+
+ private final String branch;
+
+ private int activeBranchIndex;
+
+ private String branchInput;
+
+ private AbstractDefaultAjaxBehavior keyBehavior;
+
+ private TextField<String> branchField;
+
+ private final List<String> branches = new ArrayList<>();
+
+ private final List<String> filteredBranches = new ArrayList<>();
+
+ public BranchSelector(String id, IModel<Repository> repoModel, String branch) {
+ super(id);
+
+ this.repoModel = repoModel;
+ this.branch = branch;
+
+ List<Ref> refs = new ArrayList<>();
+
+ Repository repo = repoModel.getObject();
+ refs.addAll(repo.getBranchRefs());
+ Collections.sort(refs, repo.newBranchDateComparator());
+ for (Ref ref: refs)
+ branches.add(GitUtils.ref2branch(ref.getName()));
+
+ filteredBranches.addAll(branches);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ branchField = new TextField<String>("branch", Model.of(""));
+ branchField.setOutputMarkupId(true);
+ add(branchField);
+
+ keyBehavior = new AbstractDefaultAjaxBehavior() {
+
+ @Override
+ protected void respond(AjaxRequestTarget target) {
+ IRequestParameters params = RequestCycle.get().getRequest().getQueryParameters();
+ String key = params.getParameterValue("key").toString();
+
+ if (key.equals("return")) {
+ if (!filteredBranches.isEmpty())
+ onSelect(target, filteredBranches.get(activeBranchIndex));
+ } else if (key.equals("up")) {
+ activeBranchIndex--;
+ } else if (key.equals("down")) {
+ activeBranchIndex++;
+ } else {
+ throw new IllegalStateException("Unrecognized key: " + key);
+ }
+ }
+
+ @Override
+ public void renderHead(Component component, IHeaderResponse response) {
+ super.renderHead(component, response);
+ String script = String.format("gitplex.branchSelector.init('%s', %s);",
+ getMarkupId(true), getCallbackFunction(CallbackParameter.explicit("key")));
+ response.render(OnDomReadyHeaderItem.forScript(script));
+ }
+
+ };
+ add(keyBehavior);
+
+ branchField.add(new FormComponentInputBehavior() {
+
+ @Override
+ protected void onInput(AjaxRequestTarget target) {
+ branchInput = branchField.getInput();
+ filteredBranches.clear();
+ if (StringUtils.isNotBlank(branchInput)) {
+ branchInput = branchInput.trim();
+ for (String branch: branches) {
+ if (branch.contains(branchInput))
+ filteredBranches.add(branch);
+ }
+ } else {
+ branchInput = null;
+ filteredBranches.addAll(branches);
+ }
+
+ if (activeBranchIndex >= filteredBranches.size())
+ activeBranchIndex = 0;
+ target.add(get("branches"));
+ }
+
+ });
+
+ WebMarkupContainer branchesContainer = new WebMarkupContainer("branches");
+ branchesContainer.add(new ListView<String>("branches", filteredBranches) {
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ AjaxLink<Void> link = new AjaxLink<Void>("link") {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ onSelect(target, item.getModelObject());
+ }
+
+ };
+ link.add(new Label("label", item.getModelObject()));
+ if (item.getModelObject().equals(branch))
+ link.add(AttributeAppender.append("class", " current"));
+ item.add(link);
+
+ if (activeBranchIndex == item.getIndex())
+ item.add(AttributeAppender.append("class", " active"));
+ }
+
+ });
+ branchesContainer.setOutputMarkupId(true);
+ add(branchesContainer);
+
+ setOutputMarkupId(true);
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(JavaScriptHeaderItem.forReference(HotkeysResourceReference.INSTANCE));
+
+ response.render(JavaScriptHeaderItem.forReference(
+ new JavaScriptResourceReference(BranchSelector.class, "branch-selector.js")));
+ response.render(CssHeaderItem.forReference(
+ new CssResourceReference(BranchSelector.class, "branch-selector.css")));
+ }
+
+ protected abstract void onSelect(AjaxRequestTarget target, String branch);
+
+ @Override
+ protected void onDetach() {
+ repoModel.detach();
+
+ super.onDetach();
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-picker.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-picker.css
new file mode 100644
index 0000000000..676b5e1e70
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-picker.css
@@ -0,0 +1,11 @@
+.repository-and-branch {
+ white-space: nowrap;
+}
+.repository-and-branch>a {
+ color: #444;
+ text-decoration: none;
+ font-size: 16px;
+}
+.repository-and-branch>a.repository {
+ margin-right: 12px;
+}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-selector.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-selector.css
new file mode 100644
index 0000000000..dc4a7920a7
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-selector.css
@@ -0,0 +1,45 @@
+div.branch-selector input.branch {
+ margin-bottom: 12px;
+ background: url(search.gif) no-repeat right 6px center;
+ padding-right: 26px;
+}
+div.branch-selector .nav-tabs {
+ margin-bottom: 8px;
+}
+div.branch-selector .nav-tabs>li>a {
+ padding: 2px 4px;
+ color: #666;
+ font-size: 12px;
+}
+div.branch-selector .nav-tabs>li.active>a {
+ color: #333;
+ font-weight: bold;
+}
+div.branch-selector {
+ padding: 12px;
+}
+div.branch-selector ul.branches {
+ margin-bottom: 0;
+}
+div.branch-selector ul.branches>li {
+ position: relative;
+}
+div.branch-selector ul.branches>li>a {
+ padding-left: 20px;
+}
+div.branch-selector .feedback {
+ color: #F94949;
+ margin-bottom: 12px;
+}
+div.branch-selector .feedback:before {
+ font-family: "FontAwesome";
+ content: "\f071";
+ margin-right: 4px;
+}
+div.branch-selector a.current:before {
+ font-family: "FontAwesome";
+ content: "\f00c";
+ margin-right: 4px;
+ position: absolute;
+ left: 4px;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-selector.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-selector.js
new file mode 100644
index 0000000000..f14736ca49
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/branch-selector.js
@@ -0,0 +1,39 @@
+gitplex.branchSelector = {
+ init: function(containerId, callback) {
+ var $container = $("#" + containerId);
+ var $floating = $container.closest(".floating");
+ $floating.on("open click", function() {
+ $container.find("input").focus();
+ });
+ gitplex.branchSelector.bindInputKeys(containerId, callback);
+ },
+ bindInputKeys: function(containerId, callback) {
+ var $container = $("#" + containerId);
+ var $input = $container.find("input");
+ $input.bind("keydown", "return", function() {
+ callback("return");
+ });
+ $input.bind("keydown", "up", function(e) {
+ e.preventDefault();
+ var $active = $container.find("ul.branches li.active");
+ var $prev = $active.prev("li");
+ if ($prev.length != 0) {
+ $active.removeClass("active");
+ $prev.addClass("active");
+ callback("up");
+ }
+ $container.find("ul.branches").scrollIntoView("li.active", 8, 8);
+ });
+ $input.bind("keydown", "down", function(e) {
+ e.preventDefault();
+ var $active = $container.find("ul.branches li.active");
+ var $next = $active.next("li");
+ if ($next.length != 0) {
+ $active.removeClass("active");
+ $next.addClass("active");
+ callback("down");
+ }
+ $container.find("ul.branches").scrollIntoView("li.active", 8, 8);
+ });
+ }
+};
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/search.gif b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/search.gif
new file mode 100644
index 0000000000..e79f54dbe9
Binary files /dev/null and b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/search.gif differ
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.css
index 477eedf42d..77f6f21295 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
@@ -42,5 +42,5 @@
margin-top: 0;
}
.commit-list .alert {
- margin-bottom: 0;
+ margin-bottom: 12px;
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionPicker.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionPicker.java
index e654c2cbcb..f9299a7f8e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionPicker.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionPicker.java
@@ -1,5 +1,7 @@
package com.pmease.gitplex.web.component.revisionpicker;
+import javax.annotation.Nullable;
+
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
@@ -37,6 +39,11 @@ public abstract class RevisionPicker extends DropdownLink {
RevisionPicker.this.onSelect(target, revision);
}
+
+ @Override
+ protected String getRevisionUrl(String revision) {
+ return RevisionPicker.this.getRevisionUrl(revision);
+ }
};
}
@@ -73,4 +80,10 @@ public abstract class RevisionPicker extends DropdownLink {
}
protected abstract void onSelect(AjaxRequestTarget target, String revision);
+
+ @Nullable
+ protected String getRevisionUrl(String revision) {
+ return null;
+ }
+
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.html
index 09165891ae..8b43504fb4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.html
@@ -3,7 +3,7 @@
<input wicket:id="revision" class="form-control input-sm revision" placeholder="Input revision"></input>
<div wicket:id="feedback" class="feedback"></div>
<ul wicket:id="tabs" class="nav nav-tabs"></ul>
- <ul wicket:id="refs" class="refs list-unstyled">
+ <ul wicket:id="refs" class="refs autosize list-unstyled">
<li wicket:id="refs" class="selectable">
<a wicket:id="link"><span wicket:id="label"></span></a>
</li>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.java
index 177ed74d09..a58fad5948 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/RevisionSelector.java
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import javax.annotation.Nullable;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
@@ -30,7 +32,6 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.IRequestParameters;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
import org.eclipse.jgit.lib.Constants;
@@ -45,8 +46,6 @@ import com.pmease.commons.wicket.component.tabbable.AjaxActionTab;
import com.pmease.commons.wicket.component.tabbable.Tab;
import com.pmease.commons.wicket.component.tabbable.Tabbable;
import com.pmease.gitplex.core.model.Repository;
-import com.pmease.gitplex.web.page.repository.file.RepoFilePage;
-import com.pmease.gitplex.web.page.repository.file.RepoFileState;
@SuppressWarnings("serial")
public abstract class RevisionSelector extends Panel {
@@ -244,6 +243,11 @@ public abstract class RevisionSelector extends Panel {
setOutputMarkupId(true);
}
+ @Nullable
+ protected String getRevisionUrl(String revision) {
+ return null;
+ }
+
private Component newRefList(List<String> refs) {
WebMarkupContainer refsContainer = new WebMarkupContainer("refs");
refsContainer.add(new ListView<String>("refs", refs) {
@@ -267,10 +271,9 @@ public abstract class RevisionSelector extends Panel {
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
- RepoFileState state = new RepoFileState();
- state.blobIdent.revision = item.getModelObject();
- PageParameters params = RepoFilePage.paramsOf(repoModel.getObject(), state);
- tag.put("href", urlFor(RepoFilePage.class, params));
+ String url = getRevisionUrl(item.getModelObject());
+ if (url != null)
+ tag.put("href", url);
}
};
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/revision-selector.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/revision-selector.css
index 1f83a3f569..45ff7fc33c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/revision-selector.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/revision-selector.css
@@ -1,8 +1,3 @@
-div.revision-selector ul.refs {
- width: 400px;
- max-height: 300px;
- overflow: auto;
-}
div.revision-selector input.revision {
margin-bottom: 12px;
background: url(search.gif) no-repeat right 6px center;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/RevisionComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/RevisionComparePage.java
index b89159f41d..2dea096d33 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/RevisionComparePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/RevisionComparePage.java
@@ -152,8 +152,7 @@ public class RevisionComparePage extends RepositoryPage {
@Override
protected void onSelect(AjaxRequestTarget target, Repository repository, String revision) {
- RevisionComparePage.this.target = new RepoAndRevision(repository, revision);
- PageParameters params = paramsOf(getRepository(), RevisionComparePage.this.target, source);
+ PageParameters params = paramsOf(getRepository(), new RepoAndRevision(repository, revision), source);
setResponsePage(RevisionComparePage.class, params);
}
@@ -163,8 +162,8 @@ public class RevisionComparePage extends RepositoryPage {
@Override
protected void onSelect(AjaxRequestTarget target, Repository repository, String revision) {
- source = new RepoAndRevision(repository, revision);
- PageParameters params = paramsOf(getRepository(), RevisionComparePage.this.target, source);
+ PageParameters params = paramsOf(getRepository(), RevisionComparePage.this.target,
+ new RepoAndRevision(repository, revision));
setResponsePage(RevisionComparePage.class, params);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
index e04addc861..a0a1c33ba4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
@@ -650,6 +650,14 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {
private void newRevisionPicker(@Nullable AjaxRequestTarget target) {
Component revisionPicker = new RevisionPicker(REVISION_PICKER_ID, repoModel, blobIdent.revision) {
+ @Override
+ protected String getRevisionUrl(String revision) {
+ RepoFileState state = new RepoFileState();
+ state.blobIdent.revision = revision;
+ PageParameters params = RepoFilePage.paramsOf(repoModel.getObject(), state);
+ return urlFor(RepoFilePage.class, params).toString();
+ }
+
@Override
protected void onSelect(AjaxRequestTarget target, String revision) {
RepoFileState state = getState();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.html
index b562470e02..8e1b61f255 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.html
@@ -1,115 +1,113 @@
-<wicket:extend>
- <div id="new-request">
- <div class="head">Open Pull Request</div>
- <div class="body">
- <table class="branches">
- <tr>
- <td class="target">
- <div class="title">To</div>
- <div wicket:id="target" class="branch"></div>
- </td>
- <td class="actions">
- <a wicket:id="swap" class="swap btn btn-sm btn-default"><i class="fa fa-arrows-h"></i> swap</a>
- </td>
- <td class="source">
- <div class="title">From</div>
- <div wicket:id="source" class="branch"></div>
- </td>
- </tr>
- </table>
- <div wicket:id="status" class="status"></div>
- <ul wicket:id="tabs" class="nav nav-tabs"></ul>
- <div wicket:id="tabPanel" class="tab-panel"></div>
- <div wicket:id="backToTop"></div>
- </div>
- </div>
- <wicket:fragment wicket:id="openedFrag">
- <div class="alert alert-info">
- <div class="summary">
- <a wicket:id="view">Pull request #<span wicket:id="no"></span></a> is already open for this comparison:
- </div>
- <div wicket:id="title" class="detail"></div>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="sameBranchFrag">
- <div class="alert alert-warning">
- <div class="summary">
- <span class="fa fa-lg fa-warning"></span>
- <span>Please select different branches to integrate.</span>
- </div>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="integratedFrag">
- <div class="alert alert-success">
- <div class="summary">
- <span class="fa fa-lg fa-check-circle"></span>
- <a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.
- Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.
- </div>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="rejectedFrag">
- <div class="alert alert-danger">
- <div class="summary">
- <span class="fa fa-lg fa-ban"></span>
- <span class="message">Gate keeper of target repository rejects the integration request for below reasons:</span>
- </div>
- <ul class="detail">
- <li wicket:id="reasons"><span wicket:id="reason"></span></li>
- </ul>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="canSendFrag">
- <div class="can-send">
- <form wicket:id="form">
- <table>
- <tr class="title">
- <td class="name">Title <span class="required"></span></td>
- <td wicket:id="title" class="value">
- <input wicket:id="title" type="text" class="form-control focusable" placeholder="Input title here">
- <div wicket:id="feedback"></div>
- </td>
- </tr>
- <tr class="description">
- <td class="name">Description</td>
- <td class="value"><textarea wicket:id="comment" rows="5" class="form-control focusable"></textarea></td>
- </tr>
- <tr class="assignee">
- <td class="name">Assignee <span class="required"></span></td>
- <td wicket:id="assignee" class="value">
- <input wicket:id="assignee" type="hidden"></input>
- <div wicket:id="feedback"></div>
- <div class="help-block">
- <i class="fa fa-info-circle"></i> Assignee is responsible for integration of the
- pull request after it passes gate keeper check.
- </div>
- </td>
- </tr>
- <tr class="reviewers">
- <td class="name">Reviewers</td>
- <td wicket:id="reviewers" class="value">
- <ul class="clearfix list-unstyled">
- <li wicket:id="reviewers" class="pull-left">
- <span wicket:id="avatar"></span>
- </li>
- <wicket:enclosure child="addReviewer">
- <li class="pull-left"><input wicket:id="addReviewer" type="hidden"></input></li>
- </wicket:enclosure>
- </ul>
- <div wicket:id="prePopulateHint" class="help-block">
- <i class="fa fa-info-circle"></i> GitPlex pre-populated some reviewers above as suggested
- by gate keeper of the repository. You may adjust the list by removing existing (hovering mouse
- over reviewer avatar) or adding more.
- </div>
- </td>
- </tr>
- </table>
- <input wicket:id="send" type="submit" class="btn btn-primary" value="Send Pull Request"></input>
- </form>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="compareFrag">
- <div wicket:id="diffOption" class="diff-option"></div>
- <div wicket:id="revisionDiff"></div>
- </wicket:fragment>
+<wicket:extend>
+ <div id="new-request">
+ <div class="head">Open Pull Request</div>
+ <div class="body">
+ <div class="branches clearfix">
+ <div class="branch pull-left">
+ <label>Target</label>
+ <div wicket:id="target"></div>
+ </div>
+ <div class="action pull-left">
+ <a wicket:id="swap" class="swap btn btn-default"><i class="fa fa-arrows-h"></i> swap</a>
+ </div>
+ <div class="branch pull-left">
+ <label>Source</label>
+ <div wicket:id="source"></div>
+ </div>
+ </div>
+ <div wicket:id="status" class="status"></div>
+ <ul wicket:id="tabs" class="nav nav-tabs"></ul>
+ <div wicket:id="tabPanel" class="tab-panel"></div>
+ <div wicket:id="backToTop"></div>
+ </div>
+ </div>
+ <wicket:fragment wicket:id="openedFrag">
+ <div class="alert alert-info">
+ <div class="summary">
+ <a wicket:id="view">Pull request #<span wicket:id="no"></span></a> is already open for this comparison:
+ </div>
+ <div wicket:id="title" class="detail"></div>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="sameBranchFrag">
+ <div class="alert alert-warning">
+ <div class="summary">
+ <span class="fa fa-lg fa-warning"></span>
+ <span>Please select different branches to integrate.</span>
+ </div>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="integratedFrag">
+ <div class="alert alert-success">
+ <div class="summary">
+ <span class="fa fa-lg fa-check-circle"></span>
+ <a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.
+ Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.
+ </div>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="rejectedFrag">
+ <div class="alert alert-danger">
+ <div class="summary">
+ <span class="fa fa-lg fa-ban"></span>
+ <span class="message">Gate keeper of target repository rejects the integration request for below reasons:</span>
+ </div>
+ <ul class="detail">
+ <li wicket:id="reasons"><span wicket:id="reason"></span></li>
+ </ul>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="canSendFrag">
+ <div class="can-send">
+ <form wicket:id="form">
+ <table>
+ <tr class="title">
+ <td class="name">Title <span class="required"></span></td>
+ <td wicket:id="title" class="value">
+ <input wicket:id="title" type="text" class="form-control focusable" placeholder="Input title here">
+ <div wicket:id="feedback"></div>
+ </td>
+ </tr>
+ <tr class="description">
+ <td class="name">Description</td>
+ <td class="value"><textarea wicket:id="comment" rows="5" class="form-control focusable"></textarea></td>
+ </tr>
+ <tr class="assignee">
+ <td class="name">Assignee <span class="required"></span></td>
+ <td wicket:id="assignee" class="value">
+ <input wicket:id="assignee" type="hidden"></input>
+ <div wicket:id="feedback"></div>
+ <div class="help-block">
+ <i class="fa fa-info-circle"></i> Assignee is responsible for integration of the
+ pull request after it passes gate keeper check.
+ </div>
+ </td>
+ </tr>
+ <tr class="reviewers">
+ <td class="name">Reviewers</td>
+ <td wicket:id="reviewers" class="value">
+ <ul class="clearfix list-unstyled">
+ <li wicket:id="reviewers" class="pull-left">
+ <span wicket:id="avatar"></span>
+ </li>
+ <wicket:enclosure child="addReviewer">
+ <li class="pull-left"><input wicket:id="addReviewer" type="hidden"></input></li>
+ </wicket:enclosure>
+ </ul>
+ <div wicket:id="prePopulateHint" class="help-block">
+ <i class="fa fa-info-circle"></i> GitPlex pre-populated some reviewers above as suggested
+ by gate keeper of the repository. You may adjust the list by removing existing (hovering mouse
+ over reviewer avatar) or adding more.
+ </div>
+ </td>
+ </tr>
+ </table>
+ <input wicket:id="send" type="submit" class="btn btn-primary" value="Send Pull Request"></input>
+ </form>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="compareFrag">
+ <div wicket:id="diffOption" class="diff-option"></div>
+ <div wicket:id="revisionDiff"></div>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java
index 36cce050b0..e5ea92858a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/NewRequestPage.java
@@ -31,12 +31,10 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
-import org.eclipse.jgit.lib.Ref;
import com.google.common.base.Preconditions;
import com.pmease.commons.git.Commit;
import com.pmease.commons.git.Git;
-import com.pmease.commons.git.GitUtils;
import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.util.FileUtils;
import com.pmease.commons.wicket.behavior.StickyBehavior;
@@ -59,7 +57,7 @@ import com.pmease.gitplex.core.model.ReviewInvitation;
import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.core.permission.ObjectPermission;
import com.pmease.gitplex.web.component.BranchLink;
-import com.pmease.gitplex.web.component.branchchoice.AffinalBranchSingleChoice;
+import com.pmease.gitplex.web.component.branchpicker.AffinalBranchPicker;
import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.commitlist.CommitListPanel;
import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;
@@ -82,7 +80,9 @@ public class NewRequestPage extends PullRequestPage {
private static final String TAB_PANEL_ID = "tabPanel";
- private AffinalBranchSingleChoice targetChoice, sourceChoice;
+ private RepoAndBranch target;
+
+ private RepoAndBranch source;
private IModel<List<Commit>> commitsModel;
@@ -105,7 +105,6 @@ public class NewRequestPage extends PullRequestPage {
if (!getRepository().git().hasCommits())
throw new RestartResponseException(NoCommitsPage.class, paramsOf(getRepository()));
- RepoAndBranch target, source = null;
if (params.get("target").toString() != null) {
target = new RepoAndBranch(params.get("target").toString());
} else {
@@ -116,21 +115,14 @@ public class NewRequestPage extends PullRequestPage {
target = new RepoAndBranch(getRepository(), getRepository().getDefaultBranch());
}
}
+
if (params.get("source").toString() != null) {
source = new RepoAndBranch(params.get("source").toString());
} else {
if (getRepository().getForkedFrom() != null) {
source = new RepoAndBranch(getRepository(), getRepository().getDefaultBranch());
} else {
- for (Ref ref: getRepository().getBranchRefs()) {
- String branch = GitUtils.ref2branch(ref.getName());
- if (!branch.equals(target.getBranch())) {
- source = new RepoAndBranch(getRepository(), branch);
- break;
- }
- }
- if (source == null)
- source = target;
+ source = new RepoAndBranch(getRepository(), getRepository().getDefaultBranch());
}
}
@@ -228,39 +220,27 @@ public class NewRequestPage extends PullRequestPage {
setOutputMarkupId(true);
- targetChoice = new AffinalBranchSingleChoice("target", getRepository().getId(),
- Model.of(getPullRequest().getTarget().toString()), false) {
+ add(new AffinalBranchPicker("target", getRepository().getId(), target.getBranch()) {
@Override
- protected void onChange(AjaxRequestTarget target) {
- super.onChange(target);
-
+ protected void onSelect(AjaxRequestTarget target, Repository repository, String branch) {
PageParameters params = paramsOf(getRepository(),
- new RepoAndBranch(targetChoice.getModelObject()),
- new RepoAndBranch(sourceChoice.getModelObject()));
+ new RepoAndBranch(repository, branch), source);
setResponsePage(NewRequestPage.class, params);
}
- };
- targetChoice.setRequired(true);
- add(targetChoice);
+ });
- sourceChoice = new AffinalBranchSingleChoice("source", getRepository().getId(),
- Model.of(getPullRequest().getSource().toString()), false) {
+ add(new AffinalBranchPicker("source", getRepository().getId(), source.getBranch()) {
@Override
- protected void onChange(AjaxRequestTarget target) {
- super.onChange(target);
-
- PageParameters params = paramsOf(getRepository(),
- new RepoAndBranch(targetChoice.getModelObject()),
- new RepoAndBranch(sourceChoice.getModelObject()));
+ protected void onSelect(AjaxRequestTarget target, Repository repository, String branch) {
+ PageParameters params = paramsOf(getRepository(), NewRequestPage.this.target,
+ new RepoAndBranch(repository, branch));
setResponsePage(NewRequestPage.class, params);
}
- };
- sourceChoice.setRequired(true);
- add(sourceChoice);
+ });
add(new Link<Void>("swap") {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/new-request.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/new-request.css
index 6dabbddbcc..c64250f5ce 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/new-request.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/newrequest/new-request.css
@@ -1,85 +1,85 @@
-#new-request {
- padding: 20px 20px 0 20px;
-}
-#new-request>.head {
- font-size: 18px;
- margin-bottom: 20px;
-}
-#new-request>.body>div {
- margin-bottom: 20px;
-}
-#new-request>.body>.branches {
- margin-bottom: 20px;
-}
-#new-request>.body>.branches td>div.title {
- font-size: 18px;
- margin-bottom: 8px;
-}
-#new-request>.body>.branches td>div.branch {
- background: #F2F2F2;
- border-radius: 4px;
- vertical-align: top;
-}
-#new-request>.body>.branches .actions {
- width: 1%;
- background: none;
- padding: 77px 10px 0 10px;
-}
-
-#new-request>.body>.status .summary {
- font-size: 16px;
- padding: 0;
- margin-bottom: 8px;
-}
-
-#new-request>.body>.status>.can-send form>table td {
- padding: 16px 0;
- border-top: 1px dashed #BBB;
- border-bottom: 1px dashed #BBB;
-}
-#new-request>.body>.status>.can-send form>table tr.description td {
- padding-bottom: 8px;
-}
-#new-request>.body>.status>.can-send form>table td.name {
- width: 120px;
- font-size: 18px;
- padding-right: 8px;
-}
-#new-request>.body>.status>.can-send form>table td.value {
- padding-left: 8px;
-}
-#new-request>.body>.status>.can-send form>table {
- margin-bottom: 16px;
-}
-#new-request>.body>.status>.can-send form>table .select2-container {
- min-width: 250px;
-}
-#new-request>.body>.status>.can-send form>table td.name .required:BEFORE {
- content: "*";
- color: red;
-}
-#new-request>.body>.status>.can-send form>table .reviewers li {
- margin-right: 10px;
-}
-#new-request>.body>.status>.can-send form>table .reviewers li a:hover {
- text-decoration: none;
-}
-#new-request>.body>.status>.can-send form .feedbackPanelERROR>.alert {
- margin-bottom: 0; margin-top: 16px;
-}
-#new-request>.body>.status>.can-send form .assignee .help-block {
- margin-top: 12px;
-}
-#new-request>.body>.status>.can-send form .help-block {
- margin-bottom: 0;
-}
-#new-request>.body>.nav-tabs {
- margin-bottom: 20px;
-}
-#new-request>.body>.tab-panel>.diff-option {
- padding: 8px;
- background: #F2F2F2;
- border: 1px solid #DDD;
- z-index: 200;
- margin-bottom: 16px;
-}
+#new-request {
+ padding: 20px 20px 0 20px;
+}
+#new-request>.head {
+ font-size: 18px;
+ margin-bottom: 20px;
+}
+#new-request>.body>div {
+ margin-bottom: 20px;
+}
+#new-request>.body>.branches {
+ margin-bottom: 20px;
+}
+#new-request>.body>.branches>.branch {
+ background: #F2F2F2;
+ border: 1px solid #DDD;
+ border-radius: 4px;
+ padding: 12px;
+}
+#new-request>.body>.branches>.action {
+ margin-right: 0;
+ padding: 18px;
+}
+#new-request>.body>.branches>.branch>label {
+ font-size: 16px;
+ color: #333;
+ font-weight: normal;
+}
+#new-request>.body>.status .summary {
+ font-size: 16px;
+ padding: 0;
+ margin-bottom: 8px;
+}
+
+#new-request>.body>.status>.can-send form>table td {
+ padding: 16px 0;
+ border-top: 1px dashed #BBB;
+ border-bottom: 1px dashed #BBB;
+}
+#new-request>.body>.status>.can-send form>table tr.description td {
+ padding-bottom: 8px;
+}
+#new-request>.body>.status>.can-send form>table td.name {
+ width: 120px;
+ font-size: 18px;
+ padding-right: 8px;
+}
+#new-request>.body>.status>.can-send form>table td.value {
+ padding-left: 8px;
+}
+#new-request>.body>.status>.can-send form>table {
+ margin-bottom: 16px;
+}
+#new-request>.body>.status>.can-send form>table .select2-container {
+ min-width: 250px;
+}
+#new-request>.body>.status>.can-send form>table td.name .required:BEFORE {
+ content: "*";
+ color: red;
+}
+#new-request>.body>.status>.can-send form>table .reviewers li {
+ margin-right: 10px;
+}
+#new-request>.body>.status>.can-send form>table .reviewers li a:hover {
+ text-decoration: none;
+}
+#new-request>.body>.status>.can-send form .feedbackPanelERROR>.alert {
+ margin-bottom: 0; margin-top: 16px;
+}
+#new-request>.body>.status>.can-send form .assignee .help-block {
+ margin-top: 12px;
+}
+#new-request>.body>.status>.can-send form .help-block {
+ margin-bottom: 0;
+}
+#new-request>.body>.nav-tabs {
+ margin-bottom: 20px;
+}
+#new-request>.body>.tab-panel>.diff-option {
+ padding: 8px;
+ background: #F2F2F2;
+ border: 1px solid #DDD;
+ z-index: 200;
+ margin-bottom: 16px;
+}
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.html
index 795b443f3a..5602a5aeec 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,3 @@
<wicket:extend>
- <a wicket:id="test">test</a>
+ <a wicket:id="test"></a>
</wicket:extend>
\ No newline at end of file
diff --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.java
index 3992ec671f..f0c305836c 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,10 +1,5 @@
package com.pmease.gitplex.web.page.test;
-import org.apache.wicket.markup.html.link.Link;
-
-import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.web.page.base.BasePage;
@SuppressWarnings("serial")
@@ -13,16 +8,7 @@ public class TestPage extends BasePage {
@Override
protected void onInitialize() {
super.onInitialize();
-
- add(new Link<Void>("test") {
- @Override
- public void onClick() {
- Repository repo = GitPlex.getInstance(Dao.class).load(Repository.class, 1L);
- System.out.println(repo.getMergeBase("master", "formfeed"));
- }
-
- });
}
}