Make the ability to remove reviewers a grantable permission

Change-Id: I4ee3c3b6a42916bc3bb6d4283c937552033f309c
This commit is contained in:
Chad Horohoe
2012-09-13 11:04:20 -07:00
parent d768c7754d
commit c626f3c42b
5 changed files with 27 additions and 3 deletions

View File

@@ -728,6 +728,20 @@ Users without this access right who are able to upload new patch sets
can still do the rebase locally and upload the rebased commit as a new
patch set.
[[category_remove_reviewer]]
Remove Reviewer
~~~~~~~~~~~~~~~
This category permits users to remove other users from the list of
reviewers on a change.
The change owner, project owner and site administrator can always
remove reviewers (even without having the `Remove Reviewer` access
right assigned).
Users without this access right can only remove themselves from the
reviewer list on a change.
[[category_submit]]
Submit

View File

@@ -33,6 +33,7 @@ public class Permission implements Comparable<Permission> {
public static final String PUSH_TAG = "pushTag";
public static final String READ = "read";
public static final String REBASE = "rebase";
public static final String REMOVE_REVIEWER = "removeReviewer";
public static final String SUBMIT = "submit";
private static final List<String> NAMES_LC;
@@ -52,6 +53,7 @@ public class Permission implements Comparable<Permission> {
NAMES_LC.add(PUSH_TAG.toLowerCase());
NAMES_LC.add(LABEL.toLowerCase());
NAMES_LC.add(REBASE.toLowerCase());
NAMES_LC.add(REMOVE_REVIEWER.toLowerCase());
NAMES_LC.add(SUBMIT.toLowerCase());
labelIndex = NAMES_LC.indexOf(Permission.LABEL);

View File

@@ -114,6 +114,7 @@ permissionNames = \
pushTag, \
read, \
rebase, \
removeReviewer, \
submit
abandon = Abandon
create = Create Reference
@@ -126,6 +127,7 @@ pushMerge = Push Merge Commit
pushTag = Push Annotated Tag
read = Read
rebase = Rebase
removeReviewer = Remove Reviewer
submit = Submit
refErrorEmpty = Reference must be supplied

View File

@@ -282,9 +282,10 @@ public class ChangeControl {
return true;
}
// The branch owner, project owner, site admin can remove anyone.
//
if (getRefControl().isOwner() // branch owner
// Users with the remove reviewer permission, the branch owner, project
// owner and site admin can remove anyone
if (getRefControl().canRemoveReviewer() // has removal permissions
|| getRefControl().isOwner() // branch owner
|| getProjectControl().isOwner() // project owner
|| getCurrentUser().getCapabilities().canAdministrateServer()) {
return true;

View File

@@ -322,6 +322,11 @@ public class RefControl {
return canPerform(Permission.ABANDON);
}
/** @return true if this user can remove a reviewer for a change. */
public boolean canRemoveReviewer() {
return canPerform(Permission.REMOVE_REVIEWER);
}
/** All value ranges of any allowed label permission. */
public List<PermissionRange> getLabelRanges() {
List<PermissionRange> r = new ArrayList<PermissionRange>();