Update displayed owner group after group rename

In the AccountGroupScreen the group name and the
name of the owner group are displayed. A group
can own itself, in this case the group name and
the owner group name are the same. If now the
group got renamed by entering a new group name
and clicking on 'Rename Group' only the displayed
group name but not the displayed owner group name
was updated. With this change now also the
displayed owner group name gets updated on group
rename.

Signed-off-by: Edwin Kempin <edwin.kempin@gmail.com>
Bug: issue 751
This commit is contained in:
Edwin Kempin 2010-12-09 14:45:30 +01:00
parent 53ad356d96
commit fba6da8cb2
4 changed files with 13 additions and 12 deletions

View File

@ -47,7 +47,7 @@ public interface GroupAdminService extends RemoteJsonService {
@SignInRequired
void renameGroup(AccountGroup.Id groupId, String newName,
AsyncCallback<VoidResult> callback);
AsyncCallback<GroupDetail> callback);
@SignInRequired
void changeGroupType(AccountGroup.Id groupId, AccountGroup.Type newType,

View File

@ -124,10 +124,10 @@ public class AccountGroupScreen extends AccountScreen {
public void onClick(final ClickEvent event) {
final String newName = groupNameTxt.getText().trim();
Util.GROUP_SVC.renameGroup(groupId, newName,
new GerritCallback<VoidResult>() {
public void onSuccess(final VoidResult result) {
new GerritCallback<GroupDetail>() {
public void onSuccess(final GroupDetail groupDetail) {
saveName.setEnabled(false);
setPageTitle(Util.M.group(newName));
display(groupDetail);
}
});
}

View File

@ -163,7 +163,7 @@ class GroupAdminServiceImpl extends BaseServiceImplementation implements
}
public void renameGroup(final AccountGroup.Id groupId, final String newName,
final AsyncCallback<VoidResult> callback) {
final AsyncCallback<GroupDetail> callback) {
renameGroupFactory.create(groupId, newName).to(callback);
}

View File

@ -14,6 +14,7 @@
package com.google.gerrit.httpd.rpc.account;
import com.google.gerrit.common.data.GroupDetail;
import com.google.gerrit.common.errors.NameAlreadyUsedException;
import com.google.gerrit.httpd.rpc.Handler;
import com.google.gerrit.reviewdb.AccountGroup;
@ -22,7 +23,6 @@ import com.google.gerrit.reviewdb.ReviewDb;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.account.GroupControl;
import com.google.gerrit.server.account.NoSuchGroupException;
import com.google.gwtjsonrpc.client.VoidResult;
import com.google.gwtorm.client.OrmDuplicateKeyException;
import com.google.gwtorm.client.OrmException;
import com.google.inject.Inject;
@ -30,7 +30,7 @@ import com.google.inject.assistedinject.Assisted;
import java.util.Collections;
class RenameGroup extends Handler<VoidResult> {
class RenameGroup extends Handler<GroupDetail> {
interface Factory {
RenameGroup create(AccountGroup.Id id, String newName);
}
@ -38,6 +38,7 @@ class RenameGroup extends Handler<VoidResult> {
private final ReviewDb db;
private final GroupCache groupCache;
private final GroupControl.Factory groupControlFactory;
private final GroupDetailFactory.Factory groupDetailFactory;
private final AccountGroup.Id groupId;
private final String newName;
@ -45,18 +46,18 @@ class RenameGroup extends Handler<VoidResult> {
@Inject
RenameGroup(final ReviewDb db, final GroupCache groupCache,
final GroupControl.Factory groupControlFactory,
final GroupDetailFactory.Factory groupDetailFactory,
@Assisted final AccountGroup.Id groupId, @Assisted final String newName) {
this.db = db;
this.groupCache = groupCache;
this.groupControlFactory = groupControlFactory;
this.groupDetailFactory = groupDetailFactory;
this.groupId = groupId;
this.newName = newName;
}
@Override
public VoidResult call() throws OrmException, NameAlreadyUsedException,
public GroupDetail call() throws OrmException, NameAlreadyUsedException,
NoSuchGroupException {
final GroupControl ctl = groupControlFactory.validateFor(groupId);
final AccountGroup group = db.accountGroups().get(groupId);
@ -75,7 +76,7 @@ class RenameGroup extends Handler<VoidResult> {
//
AccountGroupName other = db.accountGroupNames().get(key);
if (other != null && other.getId().equals(groupId)) {
return VoidResult.INSTANCE;
return groupDetailFactory.create(groupId).call();
}
// Otherwise, someone else has this identity.
@ -94,6 +95,6 @@ class RenameGroup extends Handler<VoidResult> {
groupCache.evict(group);
groupCache.evictAfterRename(old);
return VoidResult.INSTANCE;
return groupDetailFactory.create(groupId).call();
}
}