Merge "Show in ApprovalTable if a reviewer can't vote in a category"

This commit is contained in:
Shawn Pearce
2012-09-16 12:12:21 -07:00
committed by gerrit code review
8 changed files with 54 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ public class ApprovalDetail {
protected Account.Id account; protected Account.Id account;
protected List<PatchSetApproval> approvals; protected List<PatchSetApproval> approvals;
protected boolean canRemove; protected boolean canRemove;
private Set<String> votable;
private transient Set<String> approved; private transient Set<String> approved;
private transient Set<String> rejected; private transient Set<String> rejected;
@@ -112,6 +113,13 @@ public class ApprovalDetail {
rejected.add(label); rejected.add(label);
} }
public void votable(String label) {
if (votable == null) {
votable = new HashSet<String>();
}
votable.add(label);
}
public boolean isApproved(String label) { public boolean isApproved(String label) {
return approved != null && approved.contains(label); return approved != null && approved.contains(label);
} }
@@ -119,4 +127,8 @@ public class ApprovalDetail {
public boolean isRejected(String label) { public boolean isRejected(String label) {
return rejected != null && rejected.contains(label); return rejected != null && rejected.contains(label);
} }
public boolean canVote(String label) {
return votable != null && votable.contains(label);
}
} }

View File

@@ -106,4 +106,6 @@ public interface GerritConstants extends Constants {
String projectAccessError(); String projectAccessError();
String projectAccessProposeForReviewHint(); String projectAccessProposeForReviewHint();
String userCannotVoteToolTip();
} }

View File

@@ -89,3 +89,5 @@ jumpMineDraftComments = Go to draft comments
projectAccessError = You don't have permissions to modify the access rights for the following refs: projectAccessError = You don't have permissions to modify the access rights for the following refs:
projectAccessProposeForReviewHint = You may propose these modifications to the project owners by clicking on 'Save for Review'. projectAccessProposeForReviewHint = You may propose these modifications to the project owners by clicking on 'Save for Review'.
userCannotVoteToolTip = User cannot vote in this category

View File

@@ -37,6 +37,7 @@ public interface GerritCss extends CssResource {
String approvalhint(); String approvalhint();
String approvalrole(); String approvalrole();
String approvalscore(); String approvalscore();
String notVotable();
String blockHeader(); String blockHeader();
String bottomheader(); String bottomheader();
String cAPPROVAL(); String cAPPROVAL();

View File

@@ -397,8 +397,11 @@ public class ApprovalTable extends Composite {
for (String labelName : columns) { for (String labelName : columns) {
fmt.setStyleName(row, col, Gerrit.RESOURCES.css().approvalscore()); fmt.setStyleName(row, col, Gerrit.RESOURCES.css().approvalscore());
if (!ad.canVote(labelName)) {
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().notVotable());
fmt.getElement(row, col).setTitle(Gerrit.C.userCannotVoteToolTip());
if (ad.isRejected(labelName)) { } else if (ad.isRejected(labelName)) {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot())); table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot()));
} else if (ad.isApproved(labelName)) { } else if (ad.isApproved(labelName)) {

View File

@@ -871,6 +871,9 @@
.infoTable td.approvalscore { .infoTable td.approvalscore {
text-align: center; text-align: center;
} }
.infoTable td.notVotable {
background: #F5F5F5;
}
.infoTable td.negscore { .infoTable td.negscore {
color: red; color: red;
} }

View File

@@ -19,6 +19,7 @@ import com.google.gerrit.common.data.ApprovalType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.ApprovalTypes;
import com.google.gerrit.common.data.ChangeDetail; import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.ChangeInfo; import com.google.gerrit.common.data.ChangeInfo;
import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.common.errors.NoSuchEntityException; import com.google.gerrit.common.errors.NoSuchEntityException;
import com.google.gerrit.httpd.rpc.Handler; import com.google.gerrit.httpd.rpc.Handler;
@@ -71,6 +72,8 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
private final ApprovalTypes approvalTypes; private final ApprovalTypes approvalTypes;
private final ChangeControl.Factory changeControlFactory; private final ChangeControl.Factory changeControlFactory;
private final ChangeControl.GenericFactory changeControlGenericFactory;
private final IdentifiedUser.GenericFactory identifiedUserFactory;
private final FunctionState.Factory functionState; private final FunctionState.Factory functionState;
private final PatchSetDetailFactory.Factory patchSetDetail; private final PatchSetDetailFactory.Factory patchSetDetail;
private final AccountInfoCacheFactory aic; private final AccountInfoCacheFactory aic;
@@ -93,6 +96,8 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
final PatchSetDetailFactory.Factory patchSetDetail, final ReviewDb db, final PatchSetDetailFactory.Factory patchSetDetail, final ReviewDb db,
final GitRepositoryManager repoManager, final GitRepositoryManager repoManager,
final ChangeControl.Factory changeControlFactory, final ChangeControl.Factory changeControlFactory,
final ChangeControl.GenericFactory changeControlGenericFactory,
final IdentifiedUser.GenericFactory identifiedUserFactory,
final AccountInfoCacheFactory.Factory accountInfoCacheFactory, final AccountInfoCacheFactory.Factory accountInfoCacheFactory,
final AnonymousUser anonymousUser, final AnonymousUser anonymousUser,
final MergeOp.Factory opFactory, final MergeOp.Factory opFactory,
@@ -104,6 +109,8 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
this.db = db; this.db = db;
this.repoManager = repoManager; this.repoManager = repoManager;
this.changeControlFactory = changeControlFactory; this.changeControlFactory = changeControlFactory;
this.changeControlGenericFactory = changeControlGenericFactory;
this.identifiedUserFactory = identifiedUserFactory;
this.anonymousUser = anonymousUser; this.anonymousUser = anonymousUser;
this.aic = accountInfoCacheFactory.create(); this.aic = accountInfoCacheFactory.create();
@@ -241,6 +248,14 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
if (ca.getPatchSetId().equals(psId)) { if (ca.getPatchSetId().equals(psId)) {
d.add(ca); d.add(ca);
} }
final ChangeControl chgCtrl =
changeControlGenericFactory.controlFor(detail.getChange(),
identifiedUserFactory.create(ca.getAccountId()));
for (PermissionRange pr : chgCtrl.getLabelRanges()) {
if (pr.getMin() != 0 || pr.getMax() != 0) {
d.votable(pr.getLabel());
}
}
} }
final Account.Id owner = detail.getChange().getOwner(); final Account.Id owner = detail.getChange().getOwner();

View File

@@ -55,6 +55,8 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
private final ReviewDb db; private final ReviewDb db;
private final FunctionState.Factory functionState; private final FunctionState.Factory functionState;
private final ChangeControl.Factory changeControlFactory; private final ChangeControl.Factory changeControlFactory;
private final ChangeControl.GenericFactory changeControlGenericFactory;
private final IdentifiedUser.GenericFactory identifiedUserFactory;
private final ApprovalTypes approvalTypes; private final ApprovalTypes approvalTypes;
private final AccountInfoCacheFactory aic; private final AccountInfoCacheFactory aic;
private final IdentifiedUser user; private final IdentifiedUser user;
@@ -71,12 +73,16 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
final AccountInfoCacheFactory.Factory accountInfoCacheFactory, final AccountInfoCacheFactory.Factory accountInfoCacheFactory,
final FunctionState.Factory functionState, final FunctionState.Factory functionState,
final ChangeControl.Factory changeControlFactory, final ChangeControl.Factory changeControlFactory,
final ChangeControl.GenericFactory changeControlGenericFactory,
final IdentifiedUser.GenericFactory identifiedUserFactory,
final ApprovalTypes approvalTypes, final ApprovalTypes approvalTypes,
final IdentifiedUser user, @Assisted final PatchSet.Id patchSetId) { final IdentifiedUser user, @Assisted final PatchSet.Id patchSetId) {
this.infoFactory = infoFactory; this.infoFactory = infoFactory;
this.db = db; this.db = db;
this.functionState = functionState; this.functionState = functionState;
this.changeControlFactory = changeControlFactory; this.changeControlFactory = changeControlFactory;
this.changeControlGenericFactory = changeControlGenericFactory;
this.identifiedUserFactory = identifiedUserFactory;
this.approvalTypes = approvalTypes; this.approvalTypes = approvalTypes;
this.aic = accountInfoCacheFactory.create(); this.aic = accountInfoCacheFactory.create();
this.user = user; this.user = user;
@@ -190,7 +196,7 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
} }
private void loadApprovals(final PatchSetPublishDetail detail, private void loadApprovals(final PatchSetPublishDetail detail,
final ChangeControl control) throws OrmException { final ChangeControl control) throws OrmException, NoSuchChangeException {
final PatchSet.Id psId = detail.getChange().currentPatchSetId(); final PatchSet.Id psId = detail.getChange().currentPatchSetId();
final Change.Id changeId = patchSetId.getParentKey(); final Change.Id changeId = patchSetId.getParentKey();
final List<PatchSetApproval> allApprovals = final List<PatchSetApproval> allApprovals =
@@ -221,6 +227,14 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
if (ca.getPatchSetId().equals(psId)) { if (ca.getPatchSetId().equals(psId)) {
d.add(ca); d.add(ca);
} }
final ChangeControl chgCtrl =
changeControlGenericFactory.controlFor(detail.getChange(),
identifiedUserFactory.create(ca.getAccountId()));
for (PermissionRange pr : chgCtrl.getLabelRanges()) {
if (pr.getMin() != 0 || pr.getMax() != 0) {
d.votable(pr.getLabel());
}
}
} }
final Account.Id owner = detail.getChange().getOwner(); final Account.Id owner = detail.getChange().getOwner();