Merge branch 'stable-2.10'

* stable-2.10:
  Don't show 'Add Me' button for change owner or existing reviewers
  Clarify behaviour of the 'Remove Reviewer' permission for change owners
  Include all command arguments in SSH log entry
  Honor expireAfterWrite in the H2CacheImpl
  ACL: Fix transitions check & a '1' in RefName
  Fix exception when clicking on binary file without being signed in
  Use current time for cherry picked commits
  Enable scrollbars for "Edit Commit Message" TextArea
  Only create All-Projects ACL once
  Fix inconsistent behaviour when adding reviewers

Conflicts:
	gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheFactory.java
	gerrit-gwtui/src/main/java/com/google/gerrit/client/change/Reviewers.java
	gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java

Change-Id: I120ce5cc0ac117673c36d96cad301c4ac0982915
This commit is contained in:
David Pursehouse 2014-12-05 11:19:22 +09:00
commit d3d7e26235
5 changed files with 34 additions and 17 deletions

View File

@ -741,9 +741,11 @@ patch set.
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).
Change owners can always remove reviewers who have given a zero or positive
score (even without having the `Remove Reviewer` access right assigned).
Project owners and site administrators can always remove any reviewer (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.

View File

@ -65,6 +65,7 @@ public class Reviewers extends Composite {
@UiField Element reviewersText;
@UiField Button openForm;
@UiField Button addMe;
@UiField Element form;
@UiField Element error;
@UiField(provided = true)
@ -146,7 +147,7 @@ public class Reviewers extends Composite {
}
}
@UiHandler("addme")
@UiHandler("addMe")
void onAddMe(@SuppressWarnings("unused") ClickEvent e) {
String accountId = String.valueOf(Gerrit.getUserAccountInfo()._account_id());
addReviewer(accountId, false);
@ -248,6 +249,13 @@ public class Reviewers extends Composite {
reviewersText.setInnerSafeHtml(rHtml);
ccText.setInnerSafeHtml(ccHtml);
if (Gerrit.isSignedIn()) {
int currentUser = Gerrit.getUserAccountInfo()._account_id();
boolean showAddMeButton = info.owner()._account_id() != currentUser
&& !cc.containsKey(currentUser)
&& !r.containsKey(currentUser);
addMe.setVisible(showAddMeButton);
}
}
private static Map<Integer, VotableInfo> votable(ChangeInfo change) {

View File

@ -72,7 +72,8 @@ limitations under the License.
<g:Button ui:field='add' styleName='{res.style.button}'>
<div>Add</div>
</g:Button>
<g:Button ui:field='addme' styleName='{res.style.button}'>
<g:Button ui:field='addMe'
styleName='{res.style.button}' visible='false'>
<div>Add Me</div>
</g:Button>
<g:Button ui:field='cancel'

View File

@ -151,11 +151,12 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
private PostResult putAccount(ReviewerResource rsrc) throws OrmException,
IOException {
Account.Id id = rsrc.getUser().getAccountId();
ChangeControl control = rsrc.getControl().forUser(
identifiedUserFactory.create(id));
Account member = rsrc.getUser().getAccount();
ChangeControl control = rsrc.getControl();
PostResult result = new PostResult();
addReviewers(rsrc, result, ImmutableMap.of(id, control));
if (isValidReviewer(member, control)) {
addReviewers(rsrc, result, ImmutableMap.of(member.getId(), control));
}
return result;
}
@ -206,13 +207,8 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
}
for (Account member : members) {
if (member.isActive()) {
IdentifiedUser user = identifiedUserFactory.create(member.getId());
// Does not account for draft status as a user might want to let a
// reviewer see a draft.
if (control.forUser(user).isRefVisible()) {
reviewers.put(user.getAccountId(), control);
}
if (isValidReviewer(member, control)) {
reviewers.put(member.getId(), control);
}
}
@ -220,6 +216,16 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
return result;
}
private boolean isValidReviewer(Account member, ChangeControl control) {
if (member.isActive()) {
IdentifiedUser user = identifiedUserFactory.create(member.getId());
// Does not account for draft status as a user might want to let a
// reviewer see a draft.
return control.forUser(user).isRefVisible();
}
return false;
}
private void addReviewers(ChangeResource rsrc, PostResult result,
Map<Account.Id, ChangeControl> reviewers)
throws OrmException, IOException {