Merge "Add group option that makes the group visible to all registered users"

This commit is contained in:
Shawn Pearce
2011-04-08 14:01:20 -07:00
committed by Android Code Review
17 changed files with 204 additions and 31 deletions

View File

@@ -27,6 +27,7 @@ import com.google.gerrit.client.ui.RPCSuggestOracle;
import com.google.gerrit.client.ui.SmallHeading;
import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.common.data.GroupDetail;
import com.google.gerrit.common.data.GroupOptions;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.AccountGroupMember;
@@ -84,6 +85,10 @@ public class AccountGroupScreen extends AccountScreen {
private Button externalNameSearch;
private Grid externalMatches;
private Panel groupOptionsPanel;
private CheckBox visibleToAllCheckBox;
private Button saveGroupOptions;
public AccountGroupScreen(final AccountGroup.Id toShow) {
groupId = toShow;
}
@@ -95,6 +100,14 @@ public class AccountGroupScreen extends AccountScreen {
this) {
@Override
protected void preDisplay(final GroupDetail result) {
enableForm(result.canModify);
saveName.setVisible(result.canModify);
saveOwner.setVisible(result.canModify);
saveDesc.setVisible(result.canModify);
saveGroupOptions.setVisible(result.canModify);
delMember.setVisible(result.canModify);
members.setEnabled(result.canModify);
saveType.setVisible(result.canModify);
display(result);
}
});
@@ -106,11 +119,23 @@ public class AccountGroupScreen extends AccountScreen {
initName();
initOwner();
initDescription();
initGroupOptions();
initGroupType();
initMemberList();
initExternal();
}
private void enableForm(final boolean canModify) {
groupNameTxt.setEnabled(canModify);
ownerTxtBox.setEnabled(canModify);
descTxt.setEnabled(canModify);
typeSelect.setEnabled(canModify);
addMemberBox.setEnabled(canModify);
externalNameFilter.setEnabled(canModify);
externalNameSearch.setEnabled(canModify);
visibleToAllCheckBox.setEnabled(canModify);
}
private void initName() {
final VerticalPanel groupNamePanel = new VerticalPanel();
groupNameTxt = new NpTextBox();
@@ -199,6 +224,35 @@ public class AccountGroupScreen extends AccountScreen {
new OnEditEnabler(saveDesc, descTxt);
}
private void initGroupOptions() {
groupOptionsPanel = new VerticalPanel();
groupOptionsPanel.add(new SmallHeading(Util.C.headingGroupOptions()));
visibleToAllCheckBox = new CheckBox(Util.C.isVisibleToAll());
groupOptionsPanel.add(visibleToAllCheckBox);
saveGroupOptions = new Button(Util.C.buttonSaveGroupOptions());
saveGroupOptions.setEnabled(false);
saveGroupOptions.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
final GroupOptions groupOptions =
new GroupOptions(visibleToAllCheckBox.getValue());
Util.GROUP_SVC.changeGroupOptions(groupId, groupOptions,
new GerritCallback<VoidResult>() {
public void onSuccess(final VoidResult result) {
saveGroupOptions.setEnabled(false);
}
});
}
});
groupOptionsPanel.add(saveGroupOptions);
add(groupOptionsPanel);
new OnEditEnabler(saveGroupOptions, visibleToAllCheckBox);
}
private void initGroupType() {
typeSystem = new Label(Util.C.groupType_SYSTEM());
@@ -445,6 +499,8 @@ public class AccountGroupScreen extends AccountScreen {
}
setType(group.getType());
visibleToAllCheckBox.setValue(group.isVisibleToAll());
}
void doAddNew() {
@@ -474,6 +530,8 @@ public class AccountGroupScreen extends AccountScreen {
}
private class MemberTable extends FancyFlexTable<AccountGroupMember> {
private boolean enabled = true;
MemberTable() {
table.setText(0, 2, Util.C.columnMember());
table.setText(0, 3, Util.C.columnEmailAddress());
@@ -484,6 +542,16 @@ public class AccountGroupScreen extends AccountScreen {
fmt.addStyleName(0, 3, Gerrit.RESOURCES.css().dataHeader());
}
void setEnabled(final boolean enabled) {
this.enabled = enabled;
for (int row = 1; row < table.getRowCount(); row++) {
final AccountGroupMember k = getRowItem(row);
if (k != null) {
((CheckBox) table.getWidget(row, 1)).setEnabled(enabled);
}
}
}
void deleteChecked() {
final HashSet<AccountGroupMember.Key> ids =
new HashSet<AccountGroupMember.Key>();
@@ -531,7 +599,9 @@ public class AccountGroupScreen extends AccountScreen {
void populate(final int row, final AccountGroupMember k) {
final Account.Id accountId = k.getAccountId();
table.setWidget(row, 1, new CheckBox());
CheckBox checkBox = new CheckBox();
table.setWidget(row, 1, checkBox);
checkBox.setEnabled(enabled);
table.setWidget(row, 2, AccountDashboardLink.link(accounts, accountId));
table.setText(row, 3, accounts.get(accountId).getPreferredEmail());

View File

@@ -37,6 +37,9 @@ public interface AdminConstants extends Constants {
String useContributorAgreements();
String useSignedOffBy();
String requireChangeID();
String headingGroupOptions();
String isVisibleToAll();
String buttonSaveGroupOptions();
String headingOwner();
String headingParentProjectName();

View File

@@ -18,6 +18,9 @@ useContentMerge = Automatically resolve conflicts
useContributorAgreements = Require a valid contributor agreement to upload
useSignedOffBy = Require <a href="http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html#Signed-off-by" target="_blank"><code>Signed-off-by</code></a> in commit message
requireChangeID = Require <a href="http://gerrit.googlecode.com/svn/documentation/2.0/user-changeid.html" target="_blank"><code>Change-Id</code></a> in commit message
headingGroupOptions = Group Options
isVisibleToAll = Make group visible to all registered users.
buttonSaveGroupOptions = Save Group Options
headingOwner = Owners
headingParentProjectName = Rights Inherit From

View File

@@ -49,7 +49,7 @@ public class GroupListScreen extends AccountScreen {
protected void onLoad() {
super.onLoad();
Util.GROUP_SVC
.ownedGroups(new ScreenLoadCallback<List<AccountGroup>>(this) {
.visibleGroups(new ScreenLoadCallback<List<AccountGroup>>(this) {
@Override
protected void preDisplay(final List<AccountGroup> result) {
groups.display(result);