Make the ability to view draft changes a grantable permission
Currently only the change owner and explicitly added reviewers are able to see draft changes. This change makes the ability to view draft changes a grantable permission. Users having this permission will be able to view draft changes even if they are not the owner or already added as a reviewer. A use case for this would be a non-interactive user such as an automated verification bot that needs to react to all changes, including drafts. Bug: issue 1585 Change-Id: Ia57f000d1ac075e61edb604682e85d2d135c50f2
This commit is contained in:
committed by
Edwin Kempin
parent
d19be975e2
commit
5ae7300a07
@@ -759,6 +759,18 @@ In order to submit, all approval categories (such as `Verified` and
|
||||
See above for details on each category.
|
||||
|
||||
|
||||
[[category_view_drafts]]
|
||||
View Drafts
|
||||
~~~~~~~~~~~
|
||||
|
||||
This category permits users to view draft changes uploaded by other
|
||||
users.
|
||||
|
||||
The change owner and any explicitly added reviewers can always see
|
||||
draft changes (even without having the `View Drafts` access right
|
||||
assigned).
|
||||
|
||||
|
||||
[[category_makeoneup]]
|
||||
Your Category Here
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -35,6 +35,7 @@ public class Permission implements Comparable<Permission> {
|
||||
public static final String REBASE = "rebase";
|
||||
public static final String REMOVE_REVIEWER = "removeReviewer";
|
||||
public static final String SUBMIT = "submit";
|
||||
public static final String VIEW_DRAFTS = "viewDrafts";
|
||||
|
||||
private static final List<String> NAMES_LC;
|
||||
private static final int labelIndex;
|
||||
@@ -55,6 +56,7 @@ public class Permission implements Comparable<Permission> {
|
||||
NAMES_LC.add(REBASE.toLowerCase());
|
||||
NAMES_LC.add(REMOVE_REVIEWER.toLowerCase());
|
||||
NAMES_LC.add(SUBMIT.toLowerCase());
|
||||
NAMES_LC.add(VIEW_DRAFTS.toLowerCase());
|
||||
|
||||
labelIndex = NAMES_LC.indexOf(Permission.LABEL);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@ permissionNames = \
|
||||
read, \
|
||||
rebase, \
|
||||
removeReviewer, \
|
||||
submit
|
||||
submit, \
|
||||
viewDrafts
|
||||
abandon = Abandon
|
||||
create = Create Reference
|
||||
forgeAuthor = Forge Author Identity
|
||||
@@ -130,6 +131,7 @@ read = Read
|
||||
rebase = Rebase
|
||||
removeReviewer = Remove Reviewer
|
||||
submit = Submit
|
||||
viewDrafts = View Drafts
|
||||
|
||||
refErrorEmpty = Reference must be supplied
|
||||
refErrorBeginSlash = Reference must not start with '/'
|
||||
|
||||
@@ -554,7 +554,7 @@ public class ChangeControl {
|
||||
|
||||
private boolean isDraftVisible(ReviewDb db, ChangeData cd)
|
||||
throws OrmException {
|
||||
return isOwner() || isReviewer(db, cd);
|
||||
return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts();
|
||||
}
|
||||
|
||||
private static boolean isUser(Term who) {
|
||||
|
||||
@@ -327,6 +327,11 @@ public class RefControl {
|
||||
return canPerform(Permission.REMOVE_REVIEWER);
|
||||
}
|
||||
|
||||
/** @return true if this user can view draft changes. */
|
||||
public boolean canViewDrafts() {
|
||||
return canPerform(Permission.VIEW_DRAFTS);
|
||||
}
|
||||
|
||||
/** All value ranges of any allowed label permission. */
|
||||
public List<PermissionRange> getLabelRanges() {
|
||||
List<PermissionRange> r = new ArrayList<PermissionRange>();
|
||||
|
||||
Reference in New Issue
Block a user