Enable UI action to toggle WIP flag for admins

Change I4878f066b6 allowed administrators to toggle the WIP flag on any
change but the UI action was still disabled for admins.

Change-Id: I55dd6400dc07d57fe2aaaf3528ff429d5baf48ed
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2018-03-27 15:20:58 +02:00
parent 659ea71969
commit 9cae606cda
2 changed files with 20 additions and 6 deletions
java/com/google/gerrit/server/restapi/change

@ -14,6 +14,9 @@
package com.google.gerrit.server.restapi.change;
import static com.google.gerrit.extensions.conditions.BooleanCondition.and;
import static com.google.gerrit.extensions.conditions.BooleanCondition.or;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
@ -93,8 +96,12 @@ public class SetReadyForReview extends RetryingRestModifyView<ChangeResource, In
.setLabel("Start Review")
.setTitle("Set Ready For Review")
.setVisible(
rsrc.isUserOwner()
&& rsrc.getChange().getStatus() == Status.NEW
&& rsrc.getChange().isWorkInProgress());
and(
rsrc.getChange().getStatus() == Status.NEW && rsrc.getChange().isWorkInProgress(),
or(
rsrc.isUserOwner(),
permissionBackend
.currentUser()
.testCond(GlobalPermission.ADMINISTRATE_SERVER))));
}
}

@ -14,6 +14,9 @@
package com.google.gerrit.server.restapi.change;
import static com.google.gerrit.extensions.conditions.BooleanCondition.and;
import static com.google.gerrit.extensions.conditions.BooleanCondition.or;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
@ -94,8 +97,12 @@ public class SetWorkInProgress extends RetryingRestModifyView<ChangeResource, In
.setLabel("WIP")
.setTitle("Set Work In Progress")
.setVisible(
rsrc.isUserOwner()
&& rsrc.getChange().getStatus() == Status.NEW
&& !rsrc.getChange().isWorkInProgress());
and(
rsrc.getChange().getStatus() == Status.NEW && !rsrc.getChange().isWorkInProgress(),
or(
rsrc.isUserOwner(),
permissionBackend
.currentUser()
.testCond(GlobalPermission.ADMINISTRATE_SERVER))));
}
}