diff options
Diffstat (limited to 'src/com/gitblit/wicket/pages')
-rw-r--r-- | src/com/gitblit/wicket/pages/EditRepositoryPage.html | 2 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/EditRepositoryPage.java | 26 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/RepositoryPage.java | 10 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/RootSubPage.java | 2 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/SummaryPage.html | 2 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/SummaryPage.java | 19 |
6 files changed, 37 insertions, 24 deletions
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html index 60893f44..be9616c0 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -50,7 +50,7 @@ <div class="tab-pane" id="permissions">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.owner"></wicket:message></th><td class="edit"><select class="span2" wicket:id="owner" tabindex="15" /> <span class="help-inline"><wicket:message key="gb.ownerDescription"></wicket:message></span></td></tr>
+ <tr><th><wicket:message key="gb.repoAdministrators"></wicket:message></th><td class="edit"><span wicket:id="repoAdministrators" tabindex="15" /> <span class="help-inline"><wicket:message key="gb.repoAdministratorsDescription"></wicket:message></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="16" /></td></tr>
<tr><th colspan="2"><hr/></th></tr>
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index a071b69e..9a81bde4 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -61,6 +61,7 @@ import com.gitblit.models.RegistrantAccessPermission; import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.ArrayUtils;
+import com.gitblit.utils.MultiConfigUtil;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.StringChoiceRenderer;
@@ -70,6 +71,8 @@ import com.gitblit.wicket.panels.RegistrantPermissionsPanel; public class EditRepositoryPage extends RootSubPage {
+ private MultiConfigUtil multiConfigUtil = new MultiConfigUtil();
+
private final boolean isCreate;
private boolean isAdmin;
@@ -94,7 +97,7 @@ public class EditRepositoryPage extends RootSubPage { // personal create permissions, inject personal repository path
model.name = user.getPersonalPath() + "/";
model.projectPath = user.getPersonalPath();
- model.owner = user.username;
+ model.addRepoAdministrator(user.username);
// personal repositories are private by default
model.accessRestriction = AccessRestrictionType.VIEW;
model.authorizationControl = AuthorizationControl.NAMED;
@@ -164,6 +167,12 @@ public class EditRepositoryPage extends RootSubPage { final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams",
RegistrantType.TEAM, GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions());
+ // repo administrators palette
+ List admins = multiConfigUtil.convertCollectionToList(repositoryModel.getRepoAdministrators());
+ List persons = GitBlit.self().getAllUsernames();
+ final Palette repoAdministratorsPalette = new Palette("repoAdministrators", new ListModel<String>(admins), new CollectionModel<String>(
+ persons), new StringChoiceRenderer(), 10, true);
+
// indexed local branches palette
List<String> allLocalBranches = new ArrayList<String>();
allLocalBranches.add(Constants.DEFAULT_BRANCH);
@@ -326,6 +335,12 @@ public class EditRepositoryPage extends RootSubPage { }
repositoryModel.indexedBranches = indexedBranches;
+ repositoryModel.removeAllRepoAdministrators();
+ Iterator<String> repoAdmins = repoAdministratorsPalette.getSelectedChoices();
+ while (repoAdmins.hasNext()) {
+ repositoryModel.addRepoAdministrator(repoAdmins.next());
+ }
+
// pre-receive scripts
List<String> preReceiveScripts = new ArrayList<String>();
Iterator<String> pres = preReceivePalette.getSelectedChoices();
@@ -377,8 +392,7 @@ public class EditRepositoryPage extends RootSubPage { // field names reflective match RepositoryModel fields
form.add(new TextField<String>("name").setEnabled(allowEditName));
form.add(new TextField<String>("description"));
- form.add(new DropDownChoice<String>("owner", GitBlit.self().getAllUsernames())
- .setEnabled(GitBlitWebSession.get().canAdmin() && !repositoryModel.isPersonalRepository()));
+ form.add(repoAdministratorsPalette);
form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction", Arrays
.asList(AccessRestrictionType.values()), new AccessRestrictionRenderer());
@@ -559,9 +573,9 @@ public class EditRepositoryPage extends RootSubPage { isAdmin = true;
return;
} else {
- if (!model.owner.equalsIgnoreCase(user.username)) {
- // User is not an Admin nor Owner
- error(getString("gb.errorOnlyAdminOrOwnerMayEditRepository"), true);
+ if (!model.isRepoAdministrator(user.username)) {
+ // User is not an Admin nor RepoAdministrator
+ error(getString("gb.errorOnlyAdminOrRepoAdminMayEditRepository"), true);
}
}
}
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index aac527d7..b67aaa6d 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -79,7 +79,7 @@ public abstract class RepositoryPage extends BasePage { private final Map<String, PageRegistration> registeredPages;
private boolean showAdmin;
- private boolean isOwner;
+ private boolean isRepoAdministrator;
public RepositoryPage(PageParameters params) {
super(params);
@@ -183,10 +183,10 @@ public abstract class RepositoryPage extends BasePage { } else {
showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
}
- isOwner = GitBlitWebSession.get().isLoggedIn()
- && (model.owner != null && model.owner.equalsIgnoreCase(GitBlitWebSession.get()
+ isRepoAdministrator = GitBlitWebSession.get().isLoggedIn()
+ && (model.isRepoAdministrator(GitBlitWebSession.get()
.getUsername()));
- if (showAdmin || isOwner) {
+ if (showAdmin || isRepoAdministrator) {
pages.put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class, params));
}
return pages;
@@ -540,7 +540,7 @@ public abstract class RepositoryPage extends BasePage { }
public boolean isOwner() {
- return isOwner;
+ return isRepoAdministrator;
}
private class SearchForm extends SessionlessForm<Void> implements Serializable {
diff --git a/src/com/gitblit/wicket/pages/RootSubPage.java b/src/com/gitblit/wicket/pages/RootSubPage.java index e7e12ccc..ed1bdfbf 100644 --- a/src/com/gitblit/wicket/pages/RootSubPage.java +++ b/src/com/gitblit/wicket/pages/RootSubPage.java @@ -88,7 +88,7 @@ public abstract class RootSubPage extends RootPage { if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)
&& repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED)) {
if (user != null &&
- (repositoryModel.isOwner(user.username) || repositoryModel.isUsersPersonalRepository(user.username))) {
+ (repositoryModel.isRepoAdministrator(user.username) || repositoryModel.isUsersPersonalRepository(user.username))) {
// exclude Owner or personal repositories
continue;
}
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html index 45ffddfb..788dbb57 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.html +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -16,7 +16,7 @@ <div class="hidden-phone" style="padding-bottom: 10px;">
<table class="plain">
<tr><th><wicket:message key="gb.description">[description]</wicket:message></th><td><span wicket:id="repositoryDescription">[repository description]</span></td></tr>
- <tr><th><wicket:message key="gb.owner">[owner]</wicket:message></th><td><span wicket:id="repositoryOwner">[repository owner]</span></td></tr>
+ <tr><th><wicket:message key="gb.repoAdministrators">[owner]</wicket:message></th><td><span wicket:id="repositoryAdministrators">[repository owner]</span></td></tr>
<tr><th><wicket:message key="gb.lastChange">[last change]</wicket:message></th><td><span wicket:id="repositoryLastChange">[repository last change]</span></td></tr>
<tr><th><wicket:message key="gb.stats">[stats]</wicket:message></th><td><span wicket:id="branchStats">[branch stats]</span> <span class="link"><a wicket:id="metrics"><wicket:message key="gb.metrics">[metrics]</wicket:message></a></span></td></tr>
<tr><th style="vertical-align:top;"><wicket:message key="gb.repositoryUrl">[URL]</wicket:message> <img style="vertical-align: top;padding-left:3px;" wicket:id="accessRestrictionIcon" /></th><td><span wicket:id="repositoryCloneUrl">[repository clone url]</span><div wicket:id="otherUrls"></div></td></tr>
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 8df2cebc..3b2c92a1 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -49,6 +49,7 @@ import com.gitblit.models.UserModel; import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
+import com.gitblit.utils.MultiConfigUtil;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.BranchesPanel;
@@ -59,6 +60,8 @@ import com.gitblit.wicket.panels.TagsPanel; public class SummaryPage extends RepositoryPage {
+ private MultiConfigUtil multiConfigUtil = new MultiConfigUtil();
+
public SummaryPage(PageParameters params) {
super(params);
@@ -82,16 +85,12 @@ public class SummaryPage extends RepositoryPage { // repository description
add(new Label("repositoryDescription", getRepositoryModel().description));
- String owner = getRepositoryModel().owner;
- if (StringUtils.isEmpty(owner)) {
- add(new Label("repositoryOwner").setVisible(false));
- } else {
- UserModel ownerModel = GitBlit.self().getUserModel(owner);
- if (ownerModel != null) {
- add(new LinkPanel("repositoryOwner", null, ownerModel.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(owner)));
- } else {
- add(new Label("repositoryOwner", owner));
- }
+ String repoAdministrators = multiConfigUtil.convertCollectionToSingleLineString(getRepositoryModel().getRepoAdministrators());
+ if (StringUtils.isEmpty(repoAdministrators)) {
+ add(new Label("repositoryAdministrators").setVisible(false));
+ } else {
+ //TODO reimplement link panel for each username
+ add(new Label("repositoryAdministrators", repoAdministrators));
}
add(WicketUtils.createTimestampLabel("repositoryLastChange",
|