Removed the AccountGroup emailOnlyAuthors flag.

The functionality has been replaced with a global capability in
All-Projects project.config with the name emailReviewers. The
emailyOnlyAuthors groups will be listed with the deny permission in the
next change.

Change-Id: I67506956e2689c0840d4a37235c733d23fe1e7ad
This commit is contained in:
Colby Ranger
2012-04-10 14:27:06 -07:00
parent d9488f0c37
commit 74d093d93d
10 changed files with 19 additions and 82 deletions

View File

@@ -22,22 +22,15 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
public class GroupOptions { public class GroupOptions {
private boolean visibleToAll; private boolean visibleToAll;
private boolean emailOnlyAuthors;
protected GroupOptions() { protected GroupOptions() {
} }
public GroupOptions(final boolean visibleToAll, public GroupOptions(final boolean visibleToAll) {
final boolean emailOnlyAuthors) {
this.visibleToAll = visibleToAll; this.visibleToAll = visibleToAll;
this.emailOnlyAuthors = emailOnlyAuthors;
} }
public boolean isVisibleToAll() { public boolean isVisibleToAll() {
return visibleToAll; return visibleToAll;
} }
public boolean isEmailOnlyAuthors() {
return emailOnlyAuthors;
}
} }

View File

@@ -122,7 +122,6 @@ public interface GerritCss extends CssResource {
String groupNamePanel(); String groupNamePanel();
String groupNameTextBox(); String groupNameTextBox();
String groupOptionsPanel(); String groupOptionsPanel();
String groupOptionsNotificationsDescriptionPanel();
String groupOwnerPanel(); String groupOwnerPanel();
String groupOwnerTextBox(); String groupOwnerTextBox();
String groupTypePanel(); String groupTypePanel();

View File

@@ -70,9 +70,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
private Button externalNameSearch; private Button externalNameSearch;
private Grid externalMatches; private Grid externalMatches;
private Panel groupOptionsPanel;
private CheckBox visibleToAllCheckBox; private CheckBox visibleToAllCheckBox;
private CheckBox emailOnlyAuthors;
private Button saveGroupOptions; private Button saveGroupOptions;
public AccountGroupInfoScreen(final GroupDetail toShow, final String token) { public AccountGroupInfoScreen(final GroupDetail toShow, final String token) {
@@ -100,7 +98,6 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
externalNameFilter.setEnabled(canModify); externalNameFilter.setEnabled(canModify);
externalNameSearch.setEnabled(canModify); externalNameSearch.setEnabled(canModify);
visibleToAllCheckBox.setEnabled(canModify); visibleToAllCheckBox.setEnabled(canModify);
emailOnlyAuthors.setEnabled(canModify);
} }
private void initUUID() { private void initUUID() {
@@ -207,20 +204,14 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
} }
private void initGroupOptions() { private void initGroupOptions() {
groupOptionsPanel = new VerticalPanel(); final VerticalPanel groupOptionsPanel = new VerticalPanel();
groupOptionsPanel.setStyleName(Gerrit.RESOURCES.css().groupOptionsPanel());
groupOptionsPanel.add(new SmallHeading(Util.C.headingGroupOptions()));
visibleToAllCheckBox = new CheckBox(Util.C.isVisibleToAll());
groupOptionsPanel.add(visibleToAllCheckBox);
emailOnlyAuthors = new CheckBox(Util.C.emailOnlyAuthors());
final VerticalPanel vp = new VerticalPanel(); final VerticalPanel vp = new VerticalPanel();
vp.setStyleName(Gerrit.RESOURCES.css() vp.setStyleName(Gerrit.RESOURCES.css().groupOptionsPanel());
.groupOptionsNotificationsDescriptionPanel()); vp.add(new SmallHeading(Util.C.headingGroupOptions()));
vp.add(new Label(Util.C.descriptionNotifications()));
vp.add(emailOnlyAuthors); visibleToAllCheckBox = new CheckBox(Util.C.isVisibleToAll());
vp.add(visibleToAllCheckBox);
groupOptionsPanel.add(vp); groupOptionsPanel.add(vp);
saveGroupOptions = new Button(Util.C.buttonSaveGroupOptions()); saveGroupOptions = new Button(Util.C.buttonSaveGroupOptions());
@@ -229,8 +220,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
@Override @Override
public void onClick(final ClickEvent event) { public void onClick(final ClickEvent event) {
final GroupOptions groupOptions = final GroupOptions groupOptions =
new GroupOptions(visibleToAllCheckBox.getValue(), new GroupOptions(visibleToAllCheckBox.getValue());
emailOnlyAuthors.getValue());
Util.GROUP_SVC.changeGroupOptions(getGroupId(), groupOptions, Util.GROUP_SVC.changeGroupOptions(getGroupId(), groupOptions,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
@@ -245,7 +235,6 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
final OnEditEnabler enabler = new OnEditEnabler(saveGroupOptions); final OnEditEnabler enabler = new OnEditEnabler(saveGroupOptions);
enabler.listenTo(visibleToAllCheckBox); enabler.listenTo(visibleToAllCheckBox);
enabler.listenTo(emailOnlyAuthors);
} }
private void initGroupType() { private void initGroupType() {
@@ -460,7 +449,6 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
descTxt.setText(group.getDescription()); descTxt.setText(group.getDescription());
visibleToAllCheckBox.setValue(group.isVisibleToAll()); visibleToAllCheckBox.setValue(group.isVisibleToAll());
emailOnlyAuthors.setValue(group.isEmailOnlyAuthors());
switch (group.getType()) { switch (group.getType()) {
case LDAP: case LDAP:

View File

@@ -44,8 +44,6 @@ public interface AdminConstants extends Constants {
String requireChangeID(); String requireChangeID();
String headingGroupOptions(); String headingGroupOptions();
String isVisibleToAll(); String isVisibleToAll();
String emailOnlyAuthors();
String descriptionNotifications();
String buttonSaveGroupOptions(); String buttonSaveGroupOptions();
String suggestedGroupLabel(); String suggestedGroupLabel();
String parentSuggestions(); String parentSuggestions();

View File

@@ -29,9 +29,6 @@ headingParentProjectName = Rights Inherit From
parentSuggestions = Parent Suggestion parentSuggestions = Parent Suggestion
columnProjectName = Project Name columnProjectName = Project Name
emailOnlyAuthors = Authors
descriptionNotifications = Send email notifications about comments and actions by users in this group only to:
headingGroupUUID = Group UUID headingGroupUUID = Group UUID
headingOwner = Owners headingOwner = Owners
headingDescription = Description headingDescription = Description

View File

@@ -32,6 +32,8 @@ import java.util.List;
public class GroupTable extends NavigationTable<AccountGroup> { public class GroupTable extends NavigationTable<AccountGroup> {
private static final int NUM_COLS = 5;
private final boolean enableLink; private final boolean enableLink;
public GroupTable(final boolean enableLink) { public GroupTable(final boolean enableLink) {
@@ -52,8 +54,7 @@ public class GroupTable extends NavigationTable<AccountGroup> {
table.setText(0, 2, Util.C.columnGroupDescription()); table.setText(0, 2, Util.C.columnGroupDescription());
table.setText(0, 3, Util.C.headingOwner()); table.setText(0, 3, Util.C.headingOwner());
table.setText(0, 4, Util.C.columnGroupType()); table.setText(0, 4, Util.C.columnGroupType());
table.setText(0, 5, Util.C.columnGroupNotifications()); table.setText(0, 5, Util.C.columnGroupVisibleToAll());
table.setText(0, 6, Util.C.columnGroupVisibleToAll());
table.addClickHandler(new ClickHandler() { table.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
@@ -66,12 +67,9 @@ public class GroupTable extends NavigationTable<AccountGroup> {
}); });
final FlexCellFormatter fmt = table.getFlexCellFormatter(); final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().dataHeader()); for (int i = 1; i <= NUM_COLS; i++) {
fmt.addStyleName(0, 2, Gerrit.RESOURCES.css().dataHeader()); fmt.addStyleName(0, i, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(0, 3, Gerrit.RESOURCES.css().dataHeader()); }
fmt.addStyleName(0, 4, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(0, 5, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(0, 6, Gerrit.RESOURCES.css().dataHeader());
} }
@Override @Override
@@ -107,21 +105,15 @@ public class GroupTable extends NavigationTable<AccountGroup> {
table.setText(row, 2, k.getDescription()); table.setText(row, 2, k.getDescription());
table.setText(row, 3, detail.ownerGroup.getName()); table.setText(row, 3, detail.ownerGroup.getName());
table.setText(row, 4, k.getType().toString()); table.setText(row, 4, k.getType().toString());
if (k.isEmailOnlyAuthors()) {
table.setWidget(row, 5, new Image(Gerrit.RESOURCES.greenCheck()));
}
if (k.isVisibleToAll()) { if (k.isVisibleToAll()) {
table.setWidget(row, 6, new Image(Gerrit.RESOURCES.greenCheck())); table.setWidget(row, 5, new Image(Gerrit.RESOURCES.greenCheck()));
} }
final FlexCellFormatter fmt = table.getFlexCellFormatter(); final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().groupName()); fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().groupName());
fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell()); for (int i = 1; i <= NUM_COLS; i++) {
fmt.addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell()); fmt.addStyleName(row, i, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 4, Gerrit.RESOURCES.css().dataCell()); }
fmt.addStyleName(row, 5, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 6, Gerrit.RESOURCES.css().dataCell());
setRowItem(row, k); setRowItem(row, k);
} }

View File

@@ -1310,10 +1310,6 @@ a:hover.downloadLink {
margin-bottom: 2px; margin-bottom: 2px;
} }
.groupOptionsPanel { .groupOptionsPanel {
margin-bottom: 3px;
}
.groupOptionsNotificationsDescriptionPanel {
margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;
} }
.groupOwnerPanel { .groupOwnerPanel {

View File

@@ -131,7 +131,6 @@ class GroupAdminServiceImpl extends BaseServiceImplementation implements
final AccountGroup group = db.accountGroups().get(groupId); final AccountGroup group = db.accountGroups().get(groupId);
assertAmGroupOwner(db, group); assertAmGroupOwner(db, group);
group.setVisibleToAll(groupOptions.isVisibleToAll()); group.setVisibleToAll(groupOptions.isVisibleToAll());
group.setEmailOnlyAuthors(groupOptions.isEmailOnlyAuthors());
db.accountGroups().update(Collections.singleton(group)); db.accountGroups().update(Collections.singleton(group));
groupCache.evict(group); groupCache.evict(group);
return VoidResult.INSTANCE; return VoidResult.INSTANCE;

View File

@@ -216,11 +216,6 @@ public final class AccountGroup {
@Column(id = 7) @Column(id = 7)
protected boolean visibleToAll; protected boolean visibleToAll;
/** Comment and action email notifications by users in this group are only
* sent to change authors. */
@Column(id = 8)
protected boolean emailOnlyAuthors;
/** Globally unique identifier name for this group. */ /** Globally unique identifier name for this group. */
@Column(id = 9) @Column(id = 9)
protected UUID groupUUID; protected UUID groupUUID;
@@ -294,14 +289,6 @@ public final class AccountGroup {
return visibleToAll; return visibleToAll;
} }
public boolean isEmailOnlyAuthors() {
return emailOnlyAuthors;
}
public void setEmailOnlyAuthors(boolean emailOnlyAuthors) {
this.emailOnlyAuthors = emailOnlyAuthors;
}
public AccountGroup.UUID getGroupUUID() { public AccountGroup.UUID getGroupUUID() {
return groupUUID; return groupUUID;
} }

View File

@@ -70,19 +70,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
/** Is the from user in an email squelching group? */ /** Is the from user in an email squelching group? */
final IdentifiedUser user = args.identifiedUserFactory.create(id); final IdentifiedUser user = args.identifiedUserFactory.create(id);
if (!user.getCapabilities().canEmailReviewers()) { emailOnlyAuthors = !user.getCapabilities().canEmailReviewers();
emailOnlyAuthors = true;
} else {
// TODO(cranger): remove once the schema is migrated in the next patch.
final Set<AccountGroup.UUID> gids = user.getEffectiveGroups().getKnownGroups();
for (final AccountGroup.UUID gid : gids) {
AccountGroup group = args.groupCache.get(gid);
if (group != null && group.isEmailOnlyAuthors()) {
emailOnlyAuthors = true;
break;
}
}
}
} }
public void setPatchSet(final PatchSet ps) { public void setPatchSet(final PatchSet ps) {