Skip to content

The Unified and Autonomous Development Platform

Add repository creation shortcuts at page head.

robin shine3cbaf204abe5
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java
index 99ec064635..7dab90e929 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java
@@ -115,10 +115,13 @@ public abstract class InputAssistBehavior extends AbstractDefaultAjaxBehavior {
Preconditions.checkArgument(inputContent.indexOf('\r') == -1);
- List<Range> errors = normalizeErrors(inputContent, getErrors(inputContent));
+ List<Range> errors = getErrors(inputContent);
+ if (errors == null)
+ errors = new ArrayList<>();
+ List<Range> normalizedErrors = normalizeErrors(inputContent, errors);
String json;
try {
- json = AppLoader.getInstance(ObjectMapper.class).writeValueAsString(errors);
+ json = AppLoader.getInstance(ObjectMapper.class).writeValueAsString(normalizedErrors);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
@@ -211,6 +214,14 @@ public abstract class InputAssistBehavior extends AbstractDefaultAjaxBehavior {
protected abstract List<Range> getErrors(String inputContent);
- protected abstract int getAnchor(String content);
+ /**
+ * Given an input content, anchor is index of the char at which place to display left side
+ * of the suggestion window. This makes it possible to make the suggestion window moves
+ * as one types, instead of always staying at a fixed place
+ *
+ * @param inputContent
+ * @return
+ */
+ protected abstract int getAnchor(String inputContent);
}
\ No newline at end of file
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/GitPlex.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/GitPlex.java
index 6ced430128..150a0bda79 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/GitPlex.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/GitPlex.java
@@ -31,6 +31,7 @@ import com.pmease.commons.util.init.InitStage;
import com.pmease.commons.util.init.ManualConfig;
import com.pmease.gitplex.core.listener.LifecycleListener;
import com.pmease.gitplex.core.manager.AccountManager;
+import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.DataManager;
import com.pmease.gitplex.core.setting.ServerConfig;
@@ -38,6 +39,8 @@ public class GitPlex extends AbstractPlugin implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(GitPlex.class);
+ private final ConfigManager configManager;
+
private final DataManager dataManager;
private final AccountManager userManager;
@@ -59,10 +62,11 @@ public class GitPlex extends AbstractPlugin implements Serializable {
private String gitCheckTaskId;
@Inject
- public GitPlex(ServerConfig serverConfig, DataManager dataManager,
+ public GitPlex(ServerConfig serverConfig, DataManager dataManager, ConfigManager configManager,
TaskScheduler taskScheduler, Provider<GitConfig> gitConfigProvider,
AccountManager userManager, Provider<Set<LifecycleListener>> listenersProvider,
@AppName String appName) {
+ this.configManager = configManager;
this.dataManager = dataManager;
this.serverConfig = serverConfig;
this.taskScheduler = taskScheduler;
@@ -81,7 +85,7 @@ public class GitPlex extends AbstractPlugin implements Serializable {
List<ManualConfig> manualConfigs = dataManager.init();
if (!manualConfigs.isEmpty()) {
- logger.warn("Please set up the server at " + GitPlex.getInstance().guessServerUrl());
+ logger.warn("Please set up the server at " + guessServerUrl());
initStage = new InitStage("Server Setup", manualConfigs);
initStage.waitFor();
@@ -122,7 +126,7 @@ public class GitPlex extends AbstractPlugin implements Serializable {
ThreadContext.unbindSubject();
- logger.info("Server is ready at " + guessServerUrl() + ".");
+ logger.info("Server is ready at " + configManager.getSystemSetting().getServerUrl() + ".");
}
public String guessServerUrl() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java
index 67de4b0ac3..9d0401b517 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java
@@ -137,10 +137,6 @@ public class Account extends AbstractUser implements ProtectedObject {
@OnDelete(action=OnDeleteAction.CASCADE)
private Collection<ReviewInvitation> reviewInvitations = new ArrayList<>();
- @OneToMany(mappedBy="user")
- @OnDelete(action=OnDeleteAction.CASCADE)
- private Collection<CodeComment> requestComments = new ArrayList<>();
-
@OneToMany(mappedBy="user")
@OnDelete(action=OnDeleteAction.CASCADE)
private Collection<BranchWatch> branchWatches = new ArrayList<>();
@@ -330,14 +326,6 @@ public class Account extends AbstractUser implements ProtectedObject {
this.closedRequests = closedRequests;
}
- public Collection<CodeComment> getRequestComments() {
- return requestComments;
- }
-
- public void setRequestComments(Collection<CodeComment> requestComments) {
- this.requestComments = requestComments;
- }
-
public Collection<BranchWatch> getBranchWatches() {
return branchWatches;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java
index 8162feab04..2712f2f5cb 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java
@@ -3,7 +3,6 @@ package com.pmease.gitplex.core.entity;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -86,6 +85,7 @@ import com.pmease.gitplex.core.entity.component.IntegrationPolicy;
import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;
import com.pmease.gitplex.core.gatekeeper.GateKeeper;
import com.pmease.gitplex.core.listener.RefListener;
+import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.DepotManager;
import com.pmease.gitplex.core.manager.StorageManager;
import com.pmease.gitplex.core.security.protectedobject.AccountBelonging;
@@ -165,8 +165,6 @@ public class Depot extends AbstractEntity implements AccountBelonging {
private transient Map<BlobIdent, Blob> blobCache;
- private transient Map<DiffKey, List<DiffEntry>> diffCache;
-
private transient Map<String, Commit> commitCache;
private transient Map<String, Optional<ObjectId>> objectIdCache;
@@ -211,7 +209,7 @@ public class Depot extends AbstractEntity implements AccountBelonging {
this.description = description;
}
- @Editable(order=300, name="Public", description="Whether or this repository can be read by everyone")
+ @Editable(order=300, name="Public", description="Whether or not this repository can be read by everyone")
public boolean isPublicRead() {
return publicRead;
}
@@ -513,7 +511,7 @@ public class Depot extends AbstractEntity implements AccountBelonging {
}
public String getUrl() {
- return GitPlex.getInstance().guessServerUrl() + "/" + getFQN();
+ return GitPlex.getInstance(ConfigManager.class).getSystemSetting().getServerUrl() + "/" + getFQN();
}
public String getDefaultBranch() {
@@ -688,34 +686,26 @@ public class Depot extends AbstractEntity implements AccountBelonging {
}
public List<DiffEntry> getDiffs(String oldRev, String newRev) {
- if (diffCache == null)
- diffCache = new HashMap<>();
-
- DiffKey key = new DiffKey(oldRev, newRev);
- List<DiffEntry> diffs = diffCache.get(key);
- if (diffs == null) {
- try (DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE);) {
- diffFormatter.setRepository(getRepository());
- diffFormatter.setDetectRenames(true);
- diffFormatter.setDiffAlgorithm(MyersDiff.INSTANCE);
- diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
- AnyObjectId oldCommitId = getObjectId(oldRev);
- AnyObjectId newCommitId = getObjectId(newRev);
- diffs = new ArrayList<>();
- for (DiffEntry entry: diffFormatter.scan(oldCommitId, newCommitId)) {
- if (!Objects.equal(entry.getOldPath(), entry.getNewPath())
- || !Objects.equal(entry.getOldMode(), entry.getNewMode())
- || entry.getOldId()==null || !entry.getOldId().isComplete()
- || entry.getNewId()== null || !entry.getNewId().isComplete()
- || !entry.getOldId().equals(entry.getNewId())) {
- diffs.add(entry);
- }
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- diffCache.put(key, diffs);
- }
+ List<DiffEntry> diffs = new ArrayList<>();
+ try (DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE);) {
+ diffFormatter.setRepository(getRepository());
+ diffFormatter.setDetectRenames(true);
+ diffFormatter.setDiffAlgorithm(MyersDiff.INSTANCE);
+ diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
+ AnyObjectId oldCommitId = getObjectId(oldRev);
+ AnyObjectId newCommitId = getObjectId(newRev);
+ for (DiffEntry entry: diffFormatter.scan(oldCommitId, newCommitId)) {
+ if (!Objects.equal(entry.getOldPath(), entry.getNewPath())
+ || !Objects.equal(entry.getOldMode(), entry.getNewMode())
+ || entry.getOldId()==null || !entry.getOldId().isComplete()
+ || entry.getNewId()== null || !entry.getNewId().isComplete()
+ || !entry.getOldId().equals(entry.getNewId())) {
+ diffs.add(entry);
+ }
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
return diffs;
}
@@ -992,35 +982,6 @@ public class Depot extends AbstractEntity implements AccountBelonging {
listener.onRefUpdate(this, refName, commitId, ObjectId.zeroId());
}
- private static class DiffKey implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- String oldRev;
-
- String newRev;
-
- DiffKey(String oldRev, String newRev) {
- this.oldRev = oldRev;
- this.newRev = newRev;
- }
-
- public boolean equals(Object other) {
- if (!(other instanceof DiffKey))
- return false;
- if (this == other)
- return true;
- DiffKey otherKey = (DiffKey) other;
- return Objects.equal(oldRev, otherKey.oldRev)
- && Objects.equal(newRev, otherKey.newRev);
- }
-
- public int hashCode() {
- return Objects.hashCode(oldRev, newRev);
- }
-
- }
-
public Collection<TeamAuthorization> getAuthorizedTeams() {
return authorizedTeams;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
index 826e6e7319..6fcaae3402 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
@@ -51,6 +51,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Blocking;
import com.pmease.gitplex.core.gatekeeper.checkresult.CheckResult;
import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;
+import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.manager.ReviewManager;
import com.pmease.gitplex.core.security.ObjectPermission;
@@ -930,8 +931,8 @@ public class PullRequest extends AbstractEntity {
}
public String getUrl() {
- return GitPlex.getInstance().guessServerUrl() + "/" + getTargetDepot().getFQN()
- + "/pull_requests/" + getId() + "/overview";
+ return GitPlex.getInstance(ConfigManager.class).getSystemSetting().getServerUrl()
+ + "/" + getTargetDepot().getFQN() + "/pull_requests/" + getId() + "/overview";
}
@PrePersist
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java
index 93157a4244..48076af2de 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java
@@ -109,15 +109,11 @@ public class DefaultAccountManager extends AbstractEntityDao<Account> implements
query.setParameter("user", account);
query.executeUpdate();
- query = getSession().createQuery("update PullRequestActivity set user=null where user=:user");
- query.setParameter("user", account);
- query.executeUpdate();
-
- query = getSession().createQuery("update Comment set user=null where user=:user");
+ query = getSession().createQuery("update PullRequestComment set user=null where user=:user");
query.setParameter("user", account);
query.executeUpdate();
- query = getSession().createQuery("update CommentReply set user=null where user=:user");
+ query = getSession().createQuery("update CodeComment set user=null where user=:user");
query.setParameter("user", account);
query.executeUpdate();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/UrlMapper.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/UrlMapper.java
index 7d6e93e7f6..9abf9e3c23 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/UrlMapper.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/UrlMapper.java
@@ -60,6 +60,7 @@ import com.pmease.gitplex.web.page.depot.setting.integrationpolicy.IntegrationPo
import com.pmease.gitplex.web.page.depot.tags.DepotTagsPage;
import com.pmease.gitplex.web.page.init.ServerInitPage;
import com.pmease.gitplex.web.page.init.WelcomePage;
+import com.pmease.gitplex.web.page.layout.CreateDepotPage;
import com.pmease.gitplex.web.page.security.ForgetPage;
import com.pmease.gitplex.web.page.security.LoginPage;
import com.pmease.gitplex.web.page.security.LogoutPage;
@@ -82,6 +83,7 @@ public class UrlMapper extends CompoundRequestMapper {
add(new NoVersionMountedMapper("test", TestPage.class));
add(new NoVersionMountedMapper("runmode", RunModePage.class));
+ add(new NoVersionMountedMapper("new-depot", CreateDepotPage.class));
addResources();
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.html
index 205cf27bae..dd71b42f80 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.html
@@ -1,6 +1,5 @@
<wicket:panel>
<div class="organization-selector">
- <a wicket:id="addNew" class="btn btn-primary btn-block"><i class="fa fa-plus"></i> Add New</a>
<ul wicket:id="organizations" class="list-unstyled organizations autosize">
<li wicket:id="organizations" class="organization">
<a wicket:id="link">
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.java
index 5d25da981c..89587b8c06 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/OrganizationSelector.java
@@ -12,7 +12,6 @@ import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.GenericPanel;
@@ -25,7 +24,6 @@ import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.gitplex.core.entity.Account;
import com.pmease.gitplex.web.component.avatar.Avatar;
import com.pmease.gitplex.web.page.account.overview.AccountOverviewPage;
-import com.pmease.gitplex.web.page.account.overview.NewOrganizationPage;
@SuppressWarnings("serial")
public abstract class OrganizationSelector extends GenericPanel<Account> {
@@ -43,9 +41,6 @@ public abstract class OrganizationSelector extends GenericPanel<Account> {
protected void onInitialize() {
super.onInitialize();
- add(new BookmarkablePageLink<Void>("addNew", NewOrganizationPage.class,
- NewOrganizationPage.paramsOf(getAccount())));
-
WebMarkupContainer organizationsContainer = new WebMarkupContainer("organizations") {
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/organization-selector.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/organization-selector.css
index 989b186404..c1847fa10e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/organization-selector.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/accountselector/organization-selector.css
@@ -2,7 +2,7 @@
padding: 10px;
}
.organization-selector ul, .organization-selector .alert {
- margin: 12px 0 0 0;
+ margin: 0;
}
.organization-selector ul a {
padding: 5px 20px;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.html
index 856789752f..7dd71b0b94 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.html
@@ -1,9 +1,8 @@
<wicket:panel>
<div class="depot-selector">
- <a wicket:id="addNew"></a>
<wicket:enclosure child="search">
<div class="search">
- <input wicket:id="search" class="form-control" placeholder="Search..."></input>
+ <input wicket:id="search" class="form-control" placeholder="Search repositories..."></input>
</div>
</wicket:enclosure>
<ul wicket:id="depots" class="list-unstyled depots autosize">
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.java
index 9394376b76..e473870ac0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotselector/DepotSelector.java
@@ -4,8 +4,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import javax.annotation.Nullable;
-
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -20,7 +18,6 @@ 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.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
@@ -87,12 +84,6 @@ public abstract class DepotSelector extends Panel {
noDepotsContainer.setOutputMarkupPlaceholderTag(true);
add(noDepotsContainer);
- Link<Void> addLink = newAddLink("addNew");
- if (addLink != null)
- add(addLink);
- else
- add(new WebMarkupContainer("addNew").setVisible(false));
-
TextField<String> searchField = new TextField<String>("search", Model.of(""));
add(searchField);
searchField.add(new InputChangeBehavior() {
@@ -181,11 +172,6 @@ public abstract class DepotSelector extends Panel {
super.onDetach();
}
- @Nullable
- protected Link<Void> newAddLink(String componentId) {
- return null;
- }
-
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
index 2d92ba2d45..90481c976f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
@@ -1,45 +1,49 @@
<wicket:panel>
<div class="revision-diff">
- <div class="option clearfix">
- <div class="pull-left">
- <form wicket:id="pathFilter" class="form-inline path-filter">
- <div class="input-group">
- <input wicket:id="input" class="form-control" placeholder="Filter by path pattern" type="text"></input>
- <span class="input-group-btn">
- <button wicket:id="submit" title="Filter" class="btn btn-default" type="submit"><i class="fa fa-filter"></i></button>
- </span>
- </div>
- </form>
+ <table class="head">
+ <tr>
+ <td class="view-mode">
+ <span class="btn-group">
+ <a wicket:id="unified" class="btn btn-default">Unified</a>
+ <a wicket:id="split" class="btn btn-default">Split</a>
+ </span>
+ </td>
+ <td class="whitespace-option">
+ <span wicket:id="whitespaceOption" class="btn btn-default" title="White space options">White space <i class="caret"></i></span>
+ </td>
+ <td class="path-filter">
+ <form wicket:id="pathFilter">
+ <div class="input-group">
+ <input wicket:id="input" class="form-control" spellcheck="false" placeholder="Filter by path pattern" type="text"></input>
+ <span class="input-group-btn">
+ <button wicket:id="submit" title="Filter" class="btn btn-default" type="submit"><i class="fa fa-filter"></i></button>
+ </span>
+ </div>
+ </form>
+ </td>
+ </tr>
+ </table>
+ <div wicket:id="body" class="body">
+ <div class="title">
+ Total <a wicket:id="totalChanged" class="total-changed"></a>
</div>
- <div class="pull-right view-mode">
- <span class="btn-group">
- <a wicket:id="unified" class="btn btn-default">Unified</a>
- <a wicket:id="split" class="btn btn-default">Split</a>
- </span>
- </div>
- <div class="pull-right">
- <select wicket:id="whitespaceOption" class="form-control"></select>
- </div>
- </div>
- <div class="title">
- Total <a wicket:id="totalChanged" class="total-changed"></a>
+ <div wicket:id="tooManyChanges" class="alert alert-warning">Sorry we are unable to display the full diff as there are too many changes</div>
+ <ul wicket:id="diffStats" class="diff-stats list-unstyled">
+ <li wicket:id="diffStats" class="diff-stat clearfix">
+ <i wicket:id="icon" class="icon pull-left"></i>
+ <a wicket:id="file" class="file pull-left"><span wicket:id="name"></span></a>
+ <wicket:enclosure child="bar">
+ <span wicket:id="bar" class="bar pull-right"></span>
+ <span wicket:id="deletions" class="deletions pull-right"></span>
+ <span wicket:id="additions" class="additions pull-right"></span>
+ </wicket:enclosure>
+ </li>
+ </ul>
+ <ul class="changes list-unstyled">
+ <li wicket:id="changes" class="change">
+ <div wicket:id="change"></div>
+ </li>
+ </ul>
</div>
- <div wicket:id="tooManyChanges" class="alert alert-warning">Sorry we are unable to display the full diff as there are too many changes</div>
- <ul wicket:id="diffStats" class="diff-stats list-unstyled">
- <li wicket:id="diffStats" class="diff-stat clearfix">
- <i wicket:id="icon" class="icon pull-left"></i>
- <a wicket:id="file" class="file pull-left"><span wicket:id="name"></span></a>
- <wicket:enclosure child="bar">
- <span wicket:id="bar" class="bar pull-right"></span>
- <span wicket:id="deletions" class="deletions pull-right"></span>
- <span wicket:id="additions" class="additions pull-right"></span>
- </wicket:enclosure>
- </li>
- </ul>
- <ul class="changes list-unstyled">
- <li wicket:id="changes" class="change">
- <div wicket:id="change"></div>
- </li>
- </ul>
</div>
</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
index 2b96711bc0..8f1003374f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
@@ -16,7 +16,6 @@ import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
-import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.behavior.AttributeAppender;
@@ -26,10 +25,9 @@ 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.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
@@ -46,24 +44,32 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.pmease.commons.antlr.codeassist.InputCompletion;
+import com.pmease.commons.antlr.codeassist.InputStatus;
+import com.pmease.commons.antlr.codeassist.InputSuggestion;
import com.pmease.commons.git.Blob;
import com.pmease.commons.git.BlobChange;
import com.pmease.commons.git.BlobIdent;
import com.pmease.commons.git.WhitespaceOption;
import com.pmease.commons.lang.diff.DiffUtils;
+import com.pmease.commons.util.Range;
import com.pmease.commons.util.StringUtils;
import com.pmease.commons.util.match.WildcardUtils;
import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;
-import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;
import com.pmease.commons.wicket.assets.clearable.ClearableResourceReference;
import com.pmease.commons.wicket.assets.cookies.CookiesResourceReference;
import com.pmease.commons.wicket.assets.uri.URIResourceReference;
+import com.pmease.commons.wicket.behavior.inputassist.InputAssistBehavior;
+import com.pmease.commons.wicket.component.menu.MenuItem;
+import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.web.Constants;
import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;
import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;
+import com.pmease.gitplex.web.util.SuggestionUtils;
@SuppressWarnings("serial")
public abstract class RevisionDiffPanel extends Panel {
@@ -84,14 +90,22 @@ public abstract class RevisionDiffPanel extends Panel {
private DiffViewMode diffMode;
- private IModel<ChangesAndCount> changesAndCountModel = new LoadableDetachableModel<ChangesAndCount>() {
+ private IModel<List<DiffEntry>> diffEntriesModel = new LoadableDetachableModel<List<DiffEntry>>() {
@Override
- protected ChangesAndCount load() {
+ protected List<DiffEntry> load() {
String oldCommitHash = depotModel.getObject().getObjectId(oldRev).name();
String newCommitHash = depotModel.getObject().getObjectId(newRev).name();
- List<DiffEntry> diffEntries = depotModel.getObject()
- .getDiffs(oldCommitHash, newCommitHash);
+ return depotModel.getObject().getDiffs(oldCommitHash, newCommitHash);
+ }
+
+ };
+
+ private IModel<ChangesAndCount> changesAndCountModel = new LoadableDetachableModel<ChangesAndCount>() {
+
+ @Override
+ protected ChangesAndCount load() {
+ List<DiffEntry> diffEntries = diffEntriesModel.getObject();
List<BlobChange> filterChanges = new ArrayList<>();
for (DiffEntry entry: diffEntries) {
@@ -103,10 +117,18 @@ public abstract class RevisionDiffPanel extends Panel {
}
};
- String pattern = pathFilter;
- if (StringUtils.isNotBlank(pattern)) {
- if (WildcardUtils.matchString(pattern, change.getPath()))
+ if (StringUtils.isNotBlank(pathFilter)) {
+ String matchWith = pathFilter.toLowerCase().trim();
+ matchWith = StringUtils.stripStart(matchWith, "/");
+ matchWith = StringUtils.stripEnd(matchWith, "/");
+ String path = change.getPath().toLowerCase();
+ if (matchWith.equals(path)) {
+ filterChanges.add(change);
+ } else if (path.startsWith(matchWith + "/")) {
filterChanges.add(change);
+ } else if (WildcardUtils.matchString(matchWith, path)){
+ filterChanges.add(change);
+ }
} else {
filterChanges.add(change);
}
@@ -212,123 +234,189 @@ public abstract class RevisionDiffPanel extends Panel {
protected void onInitialize() {
super.onInitialize();
- List<WhitespaceOption> choices = new ArrayList<>();
- for (WhitespaceOption each: WhitespaceOption.values())
- choices.add(each);
+ WebMarkupContainer body = new WebMarkupContainer("body");
+ body.setOutputMarkupId(true);
+ add(body);
- IModel<WhitespaceOption> choiceModel = new IModel<WhitespaceOption>() {
+ for (DiffViewMode each: DiffViewMode.values()) {
+ add(new AjaxLink<Void>(each.name().toLowerCase()) {
- @Override
- public void detach() {
- }
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(body));
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ diffMode = each;
+ WebResponse response = (WebResponse) RequestCycle.get().getResponse();
+ Cookie cookie = new Cookie(COOKIE_VIEW_MODE, diffMode.name());
+ cookie.setMaxAge(Integer.MAX_VALUE);
+ response.addCookie(cookie);
+ target.add(RevisionDiffPanel.this);
+ }
+
+ }.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {
- @Override
- public WhitespaceOption getObject() {
- return whitespaceOption;
- }
+ @Override
+ protected String load() {
+ return each==diffMode?" active":"";
+ }
+
+ })));
+ }
+
+ add(new MenuLink("whitespaceOption") {
@Override
- public void setObject(WhitespaceOption object) {
- whitespaceOption = object;
+ protected List<MenuItem> getMenuItems() {
+ List<MenuItem> menuItems = new ArrayList<>();
+
+ for (WhitespaceOption each: WhitespaceOption.values()) {
+ menuItems.add(new MenuItem() {
+
+ @Override
+ public String getLabel() {
+ return each.getDescription();
+ }
+
+ @Override
+ public String getIconClass() {
+ if (whitespaceOption == each)
+ return "fa fa-check";
+ else
+ return null;
+ }
+
+ @Override
+ public AbstractLink newLink(String id) {
+ return new AjaxLink<Void>(id) {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ close();
+ whitespaceOption = each;
+ target.add(body);
+ onWhitespaceOptionChange(target, whitespaceOption);
+ }
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(body));
+ }
+
+ };
+ }
+
+ });
+ }
+
+ return menuItems;
}
- };
- IChoiceRenderer<WhitespaceOption> choiceRenderer = new IChoiceRenderer<WhitespaceOption>() {
+ });
+
+ Form<?> form = new Form<Void>("pathFilter");
+ TextField<String> filterInput;
+ form.add(filterInput = new TextField<String>("input", new IModel<String>() {
@Override
- public Object getDisplayValue(WhitespaceOption object) {
- return object.getDescription();
+ public void detach() {
}
@Override
- public String getIdValue(WhitespaceOption object, int index) {
- return object.name();
+ public String getObject() {
+ return pathFilter;
}
@Override
- public WhitespaceOption getObject(String id, IModel<? extends List<? extends WhitespaceOption>> choices) {
- return WhitespaceOption.valueOf(id);
+ public void setObject(String object) {
+ pathFilter = object;
}
- };
+
+ }));
- DropDownChoice<WhitespaceOption> whitespaceChoice =
- new DropDownChoice<WhitespaceOption>("whitespaceOption", choiceModel, choices, choiceRenderer);
- whitespaceChoice.add(new OnChangeAjaxBehavior() {
+ List<String> diffPaths = new ArrayList<>();
+ for (DiffEntry diffEntry: diffEntriesModel.getObject()) {
+ if (diffEntry.getChangeType() == DiffEntry.ChangeType.ADD) {
+ diffPaths.add(diffEntry.getNewPath());
+ } else if (diffEntry.getChangeType() == DiffEntry.ChangeType.COPY) {
+ diffPaths.add(diffEntry.getNewPath());
+ diffPaths.add(diffEntry.getOldPath());
+ } else if (diffEntry.getChangeType() == DiffEntry.ChangeType.DELETE) {
+ diffPaths.add(diffEntry.getOldPath());
+ } else if (diffEntry.getChangeType() == DiffEntry.ChangeType.MODIFY) {
+ diffPaths.add(diffEntry.getNewPath());
+ } else if (diffEntry.getChangeType() == DiffEntry.ChangeType.RENAME) {
+ diffPaths.add(diffEntry.getNewPath());
+ diffPaths.add(diffEntry.getOldPath());
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ filterInput.add(new InputAssistBehavior() {
@Override
- protected void onUpdate(AjaxRequestTarget target) {
- target.add(RevisionDiffPanel.this);
- onWhitespaceOptionChange(target, whitespaceOption);
+ protected List<InputCompletion> getSuggestions(InputStatus inputStatus, int count) {
+ List<InputCompletion> completions = new ArrayList<>();
+ for (InputSuggestion suggestion: SuggestionUtils.suggestPath(diffPaths,
+ inputStatus.getContentBeforeCaret().trim(), count)) {
+ int caret = suggestion.getCaret();
+ if (caret == -1)
+ caret = suggestion.getContent().length();
+ InputCompletion completion = new InputCompletion(0, inputStatus.getContent().length(),
+ suggestion.getContent(), caret, suggestion.getLabel(),
+ null, suggestion.getMatchRange());
+ completions.add(completion);
+ }
+ return completions;
}
- });
- add(whitespaceChoice);
-
- Form<?> form = new Form<Void>("pathFilter") {
+ @Override
+ protected List<String> getHints(InputStatus inputStatus) {
+ return Lists.newArrayList("Use * to match any string in the path");
+ }
@Override
- protected void onSubmit() {
- super.onSubmit();
- AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
- Preconditions.checkNotNull(target);
- target.add(RevisionDiffPanel.this);
- onPathFilterChange(target, pathFilter);
+ protected List<Range> getErrors(String inputContent) {
+ return null;
}
- };
- form.add(new TextField<String>("input", new IModel<String>() {
-
@Override
- public void detach() {
+ protected int getAnchor(String content) {
+ for (int i=0; i<content.length(); i++) {
+ if (!Character.isWhitespace(content.charAt(i)))
+ return i;
+ }
+ return content.length();
}
+
+ });
+
+ form.add(new AjaxButton("submit") {
@Override
- public String getObject() {
- return pathFilter;
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(body));
}
-
+
@Override
- public void setObject(String object) {
- pathFilter = object;
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ super.onSubmit(target, form);
+ Preconditions.checkNotNull(target);
+ target.add(body);
+ onPathFilterChange(target, pathFilter);
}
- }));
- form.add(new AjaxButton("submit") {});
+ });
add(form);
- for (DiffViewMode each: DiffViewMode.values()) {
- add(new AjaxLink<Void>(each.name().toLowerCase()) {
-
- @Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- attributes.getAjaxCallListeners().add(new IndicateLoadingListener());
- if (getDirtyContainer() != null)
- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(getDirtyContainer()));
- }
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- diffMode = each;
- WebResponse response = (WebResponse) RequestCycle.get().getResponse();
- Cookie cookie = new Cookie(COOKIE_VIEW_MODE, diffMode.name());
- cookie.setMaxAge(Integer.MAX_VALUE);
- response.addCookie(cookie);
- target.add(RevisionDiffPanel.this);
- }
-
- }.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {
-
- @Override
- protected String load() {
- return each==diffMode?" active":"";
- }
-
- })));
- }
-
Component totalChangedLink;
- add(totalChangedLink = new Label("totalChanged", new AbstractReadOnlyModel<String>() {
+ body.add(totalChangedLink = new Label("totalChanged", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
@@ -337,7 +425,7 @@ public abstract class RevisionDiffPanel extends Panel {
}));
- add(new WebMarkupContainer("tooManyChanges") {
+ body.add(new WebMarkupContainer("tooManyChanges") {
@Override
protected void onConfigure() {
@@ -356,7 +444,7 @@ public abstract class RevisionDiffPanel extends Panel {
} else {
totalChangedLink.add(AttributeAppender.append("class", "expanded"));
}
- add(diffStats);
+ body.add(diffStats);
diffStats.add(new ListView<BlobChange>("diffStats", new AbstractReadOnlyModel<List<BlobChange>>() {
@Override
@@ -408,7 +496,7 @@ public abstract class RevisionDiffPanel extends Panel {
});
- add(new ListView<BlobChange>("changes", new AbstractReadOnlyModel<List<BlobChange>>() {
+ body.add(new ListView<BlobChange>("changes", new AbstractReadOnlyModel<List<BlobChange>>() {
@Override
public List<BlobChange> getObject() {
@@ -429,12 +517,9 @@ public abstract class RevisionDiffPanel extends Panel {
setOutputMarkupId(true);
}
- protected Component getDirtyContainer() {
- return null;
- };
-
@Override
protected void onDetach() {
+ diffEntriesModel.detach();
changesAndCountModel.detach();
depotModel.detach();
requestModel.detach();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
index 0f96b5b61a..165c4c14a3 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
@@ -1,17 +1,17 @@
-.revision-diff>.option {
+.revision-diff>.head {
margin-bottom: 16px;
}
-.revision-diff>.option>.view-mode {
- margin-left: 16px;
+.revision-diff>.head td.view-mode {
+ width: 140px;
}
-.revision-diff>.option .path-filter input {
- width: 300px;
+.revision-diff>.head td.whitespace-option {
+ width: 140px;
}
-.revision-diff>.title {
+.revision-diff>.body>.title {
font-size: 16px;
margin-bottom: 16px;
}
-.revision-diff>.alert {
+.revision-diff>.body>.alert {
margin-bottom: 16px;
}
.revision-diff .total-changed:after {
@@ -22,47 +22,47 @@
.revision-diff .total-changed.expanded:after {
content: "\f106";
}
-.revision-diff>ul>li.diff-stat {
+.revision-diff>.body>ul>li.diff-stat {
font-size: 13px;
}
-.revision-diff>ul>li.diff-stat>.icon {
+.revision-diff>.body>ul>li.diff-stat>.icon {
margin-top: 2px;
}
-.revision-diff>ul>li.diff-stat .fa-diff-modified, .revision-diff>ul>li.diff-stat .fa-diff-renamed {
+.revision-diff>.body>ul>li.diff-stat .fa-diff-modified, .revision-diff>ul>li.diff-stat .fa-diff-renamed {
color: #D0B44C;
}
-.revision-diff>ul>li.diff-stat .fa-diff-added {
+.revision-diff>.body>ul>li.diff-stat .fa-diff-added {
color: #35C335;
}
-.revision-diff>ul>li.diff-stat .fa-diff-removed {
+.revision-diff>.body>ul>li.diff-stat .fa-diff-removed {
color: #C33535;
}
-.revision-diff>.diff-stats {
+.revision-diff>.body>.diff-stats {
margin-top: -10px;
}
-.revision-diff>.diff-stats li {
+.revision-diff>.body>.diff-stats li {
padding: 6px 0;
border-bottom: 1px solid #F2F2F2;
}
-.revision-diff>.diff-stats li:last-child {
+.revision-diff>.body>.diff-stats li:last-child {
border-bottom: none;
}
-.revision-diff>.diff-stats li a.file {
+.revision-diff>.body>.diff-stats li a.file {
padding: 0 6px;
}
-.revision-diff>.diff-stats li>.additions {
+.revision-diff>.body>.diff-stats li>.additions {
color: #35C335;
}
-.revision-diff>.diff-stats li>.deletions {
+.revision-diff>.body>.diff-stats li>.deletions {
color: #C33535;
}
-.revision-diff>.diff-stats li>.additions, .revision-diff .diff-stats li>.deletions {
+.revision-diff>.body>.diff-stats li>.additions, .revision-diff .diff-stats li>.deletions {
font-size: 12px;
font-weight: bold;
margin-right: 4px;
margin-top: 2px;
}
-.revision-diff>.changes>.change {
+.revision-diff>.body>.changes>.change {
margin-bottom: 20px;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/CreateDepotPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/CreateDepotPage.html
new file mode 100644
index 0000000000..04e16ca965
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/CreateDepotPage.html
@@ -0,0 +1,17 @@
+<wicket:extend>
+ <section class="depot create">
+ <div class="head">Create New Repository</div>
+ <div class="body">
+ <form wicket:id="form" class="leave-confirm">
+ <div class="form-group">
+ <label class="control-label">Owner <span class="required">*</span></label>
+ <input wicket:id="owner" type="hidden" class="form-control"></input>
+ </div>
+ <div wicket:id="editor"></div>
+ <div class="actions">
+ <input class="btn btn-primary dirty-aware" value="Create" type="submit"></input>
+ </div>
+ </form>
+ </div>
+ </section>
+</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/CreateDepotPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/CreateDepotPage.java
new file mode 100644
index 0000000000..1f593e534f
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/CreateDepotPage.java
@@ -0,0 +1,136 @@
+package com.pmease.gitplex.web.page.layout;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.MatchMode;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+
+import com.pmease.commons.wicket.component.select2.ResponseFiller;
+import com.pmease.commons.wicket.editable.BeanContext;
+import com.pmease.commons.wicket.editable.BeanEditor;
+import com.pmease.commons.wicket.editable.PathSegment;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.OrganizationMembership;
+import com.pmease.gitplex.core.manager.AccountManager;
+import com.pmease.gitplex.core.manager.DepotManager;
+import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.accountchoice.AbstractAccountChoiceProvider;
+import com.pmease.gitplex.web.component.accountchoice.AccountSingleChoice;
+import com.pmease.gitplex.web.page.depot.overview.DepotOverviewPage;
+import com.vaynberg.wicket.select2.Response;
+
+@SuppressWarnings("serial")
+public class CreateDepotPage extends LayoutPage {
+
+ private Long ownerId;
+
+ public CreateDepotPage(PageParameters params) {
+ super(params);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ Depot depot = new Depot();
+
+ BeanEditor<?> editor = BeanContext.editBean("editor", depot);
+
+ Form<?> form = new Form<Void>("form") {
+
+ @Override
+ protected void onSubmit() {
+ super.onSubmit();
+
+ Account owner = getOwner();
+ depot.setAccount(owner);
+ DepotManager depotManager = GitPlex.getInstance(DepotManager.class);
+ Depot depotWithSameName = depotManager.findBy(owner, depot.getName());
+ if (depotWithSameName != null) {
+ editor.getErrorContext(new PathSegment.Property("name"))
+ .addError("This name has already been used by another repository in account '" + owner.getDisplayName() + "'");
+ } else {
+ depotManager.save(depot, null, null);
+ Session.get().success("New repository created");
+ setResponsePage(DepotOverviewPage.class, DepotOverviewPage.paramsOf(depot));
+ }
+ }
+
+ };
+ form.add(editor);
+
+ IModel<Account> choiceModel = new IModel<Account>() {
+
+ @Override
+ public void detach() {
+ }
+
+ @Override
+ public Account getObject() {
+ return getOwner();
+ }
+
+ @Override
+ public void setObject(Account object) {
+ ownerId = object.getId();
+ }
+
+ };
+ form.add(new AccountSingleChoice("owner", choiceModel, new AbstractAccountChoiceProvider() {
+
+ @Override
+ public void query(String term, int page, Response<Account> response) {
+ Account loginUser = getLoginUser();
+ if (loginUser.isAdministrator()) {
+ AccountManager accountManager = GitPlex.getInstance(AccountManager.class);
+ int first = page * Constants.DEFAULT_PAGE_SIZE;
+ Criterion criterion = Restrictions.and(Restrictions.or(
+ Restrictions.ilike("name", term, MatchMode.ANYWHERE),
+ Restrictions.ilike("fullName", term, MatchMode.ANYWHERE)));
+ List<Account> accounts = accountManager.query(accountManager.newCriteria()
+ .add(criterion).addOrder(Order.asc("name")), first, Constants.DEFAULT_PAGE_SIZE + 1);
+
+ if (accounts.size() <= Constants.DEFAULT_PAGE_SIZE) {
+ response.addAll(accounts);
+ } else {
+ response.addAll(accounts.subList(0, Constants.DEFAULT_PAGE_SIZE));
+ response.setHasMore(true);
+ }
+ } else {
+ List<Account> accounts = new ArrayList<>();
+ if (loginUser.matches(term))
+ accounts.add(loginUser);
+ for (OrganizationMembership membership: loginUser.getOrganizations()) {
+ if (membership.isAdmin() && membership.getOrganization().matches(term))
+ accounts.add(membership.getOrganization());
+ }
+
+ Collections.sort(accounts);
+
+ new ResponseFiller<Account>(response).fill(accounts, page, Constants.DEFAULT_PAGE_SIZE);
+ }
+ }
+
+ }).setRequired(true));
+
+ add(form);
+ }
+
+ private Account getOwner() {
+ if (ownerId == null)
+ return getLoginUser();
+ else
+ return GitPlex.getInstance(AccountManager.class).load(ownerId);
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html
index f0ed049622..8b743f95dd 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.html
@@ -22,6 +22,7 @@
</wicket:enclosure>
</div>
<div class="actions pull-right">
+ <a wicket:id="createNewDropdown" title="Create new repository or organization"><i class="fa fa-plus"></i> <i class="fa fa-caret-down"></i></a>
<a wicket:id="organizations" title="Joined organizations"><i class="fa fa-group"></i> <i class="fa fa-caret-down"></i></a>
<a wicket:id="repositories" title="Accessible repositories"><i class="fa fa-ext fa-repo"></i> <i class="fa fa-caret-down"></i></a>
<a wicket:id="administration" title="System administration"><i class="fa fa-gear"></i></a>
@@ -42,4 +43,10 @@
</div>
</div>
</div>
+ <wicket:fragment wicket:id="createNewFrag">
+ <div class="create-new">
+ <a wicket:id="createNewDepot">Create new repository</a>
+ <a wicket:id="createNewOrganization">Create new organization</a>
+ </div>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.java
index 56ac7b907e..8d1a209a8c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/LayoutPage.java
@@ -8,17 +8,15 @@ import javax.annotation.Nullable;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
-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.html.WebMarkupContainer;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.AbstractReadOnlyModel;
-import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
@@ -36,7 +34,7 @@ import com.pmease.gitplex.web.component.avatar.AvatarLink;
import com.pmease.gitplex.web.component.depotselector.DepotSelector;
import com.pmease.gitplex.web.page.account.notifications.NotificationListPage;
import com.pmease.gitplex.web.page.account.overview.AccountOverviewPage;
-import com.pmease.gitplex.web.page.account.overview.NewDepotPage;
+import com.pmease.gitplex.web.page.account.overview.NewOrganizationPage;
import com.pmease.gitplex.web.page.account.setting.ProfileEditPage;
import com.pmease.gitplex.web.page.admin.account.AccountListPage;
import com.pmease.gitplex.web.page.base.BasePage;
@@ -111,35 +109,28 @@ public abstract class LayoutPage extends BasePage {
LayoutPage.this.onSelect(target, depot);
}
- @Override
- protected Link<Void> newAddLink(String componentId) {
- Account loginUser = getLoginUser();
- if (loginUser != null) {
- return new BookmarkablePageLink<Void>(componentId,
- NewDepotPage.class, NewDepotPage.paramsOf(loginUser)) {
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
- setEscapeModelStrings(false);
- add(AttributeAppender.append("class", "btn btn-primary btn-block"));
- }
-
- @Override
- public IModel<?> getBody() {
- return Model.of("<i class='fa fa-plus'></i> Add New");
- }
-
- };
- } else {
- return null;
- }
- }
-
};
}
});
+
+ if (isLoggedIn()) {
+ head.add(new DropdownLink("createNewDropdown") {
+
+ @Override
+ protected Component newContent(String id) {
+ Fragment fragment = new Fragment(id, "createNewFrag", LayoutPage.this);
+ fragment.add(new BookmarkablePageLink<Void>("createNewDepot", CreateDepotPage.class));
+ fragment.add(new BookmarkablePageLink<Void>("createNewOrganization",
+ NewOrganizationPage.class, NewOrganizationPage.paramsOf(getLoginUser())));
+ return fragment;
+ }
+
+ });
+ } else {
+ head.add(new WebMarkupContainer("createNewDropdown").setVisible(false));
+ }
+
head.add(new BookmarkablePageLink<Void>("administration", AccountListPage.class)
.setVisible(SecurityUtils.canManageSystem()));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/layout.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/layout.css
index 91cf5009f9..fd4d8ea307 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/layout.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/layout/layout.css
@@ -124,3 +124,20 @@ section>.head {
font-size: 18px;
margin-bottom: 20px;
}
+
+.floating>.content>.create-new {
+ padding: 12px;
+}
+.floating>.content>.create-new>a {
+ display: block;
+ text-decoration: none;
+ color: #444;
+ padding: 4px 8px;
+}
+.floating>.content>.create-new>a:hover {
+ background: #F0F0F0;
+}
+
+.create.depot {
+ padding: 20px;
+}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java
index cac8989252..0c4c0d6454 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java
@@ -58,7 +58,7 @@ public class SuggestionUtils {
suggestions.add(new InputSuggestion(wildcard, wildcardDescription, matchRange));
}
}
- for (Depot affinal: /*depot.findAffinals()*/GitPlex.getInstance(Dao.class).allOf(Depot.class)) {
+ for (Depot affinal: GitPlex.getInstance(Dao.class).allOf(Depot.class)) {
String FQN = affinal.getFQN();
int index = FQN.toLowerCase().indexOf(lowerCaseMatchWith);
if (index != -1 && numSuggestions++<count) {
@@ -85,13 +85,17 @@ public class SuggestionUtils {
}
public static List<InputSuggestion> suggestPath(Depot depot, String matchWith, int count) {
+ AuxiliaryManager auxiliaryManager = GitPlex.getInstance(AuxiliaryManager.class);
+ return suggestPath(auxiliaryManager.getFiles(depot), matchWith, count);
+ }
+
+ public static List<InputSuggestion> suggestPath(List<String> paths, String matchWith, int count) {
String lowerCaseMatchWith = matchWith.toLowerCase();
List<InputSuggestion> suggestions = new ArrayList<>();
List<PatternApplied> allApplied = new ArrayList<>();
Map<String, Range> suggestedInputs = new LinkedHashMap<>();
- AuxiliaryManager auxiliaryManager = GitPlex.getInstance(AuxiliaryManager.class);
- for (String path: auxiliaryManager.getFiles(depot)) {
+ for (String path: paths) {
PatternApplied applied = WildcardUtils.applyPattern(lowerCaseMatchWith, path, false);
if (applied != null)
allApplied.add(applied);
@@ -125,4 +129,5 @@ public class SuggestionUtils {
return suggestions;
}
+
}