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:
parent
53ad356d96
commit
fba6da8cb2
@ -47,7 +47,7 @@ public interface GroupAdminService extends RemoteJsonService {
|
|||||||
|
|
||||||
@SignInRequired
|
@SignInRequired
|
||||||
void renameGroup(AccountGroup.Id groupId, String newName,
|
void renameGroup(AccountGroup.Id groupId, String newName,
|
||||||
AsyncCallback<VoidResult> callback);
|
AsyncCallback<GroupDetail> callback);
|
||||||
|
|
||||||
@SignInRequired
|
@SignInRequired
|
||||||
void changeGroupType(AccountGroup.Id groupId, AccountGroup.Type newType,
|
void changeGroupType(AccountGroup.Id groupId, AccountGroup.Type newType,
|
||||||
|
@ -124,10 +124,10 @@ public class AccountGroupScreen extends AccountScreen {
|
|||||||
public void onClick(final ClickEvent event) {
|
public void onClick(final ClickEvent event) {
|
||||||
final String newName = groupNameTxt.getText().trim();
|
final String newName = groupNameTxt.getText().trim();
|
||||||
Util.GROUP_SVC.renameGroup(groupId, newName,
|
Util.GROUP_SVC.renameGroup(groupId, newName,
|
||||||
new GerritCallback<VoidResult>() {
|
new GerritCallback<GroupDetail>() {
|
||||||
public void onSuccess(final VoidResult result) {
|
public void onSuccess(final GroupDetail groupDetail) {
|
||||||
saveName.setEnabled(false);
|
saveName.setEnabled(false);
|
||||||
setPageTitle(Util.M.group(newName));
|
display(groupDetail);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ class GroupAdminServiceImpl extends BaseServiceImplementation implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void renameGroup(final AccountGroup.Id groupId, final String newName,
|
public void renameGroup(final AccountGroup.Id groupId, final String newName,
|
||||||
final AsyncCallback<VoidResult> callback) {
|
final AsyncCallback<GroupDetail> callback) {
|
||||||
renameGroupFactory.create(groupId, newName).to(callback);
|
renameGroupFactory.create(groupId, newName).to(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.rpc.account;
|
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.common.errors.NameAlreadyUsedException;
|
||||||
import com.google.gerrit.httpd.rpc.Handler;
|
import com.google.gerrit.httpd.rpc.Handler;
|
||||||
import com.google.gerrit.reviewdb.AccountGroup;
|
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.GroupCache;
|
||||||
import com.google.gerrit.server.account.GroupControl;
|
import com.google.gerrit.server.account.GroupControl;
|
||||||
import com.google.gerrit.server.account.NoSuchGroupException;
|
import com.google.gerrit.server.account.NoSuchGroupException;
|
||||||
import com.google.gwtjsonrpc.client.VoidResult;
|
|
||||||
import com.google.gwtorm.client.OrmDuplicateKeyException;
|
import com.google.gwtorm.client.OrmDuplicateKeyException;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@ -30,7 +30,7 @@ import com.google.inject.assistedinject.Assisted;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
class RenameGroup extends Handler<VoidResult> {
|
class RenameGroup extends Handler<GroupDetail> {
|
||||||
interface Factory {
|
interface Factory {
|
||||||
RenameGroup create(AccountGroup.Id id, String newName);
|
RenameGroup create(AccountGroup.Id id, String newName);
|
||||||
}
|
}
|
||||||
@ -38,6 +38,7 @@ class RenameGroup extends Handler<VoidResult> {
|
|||||||
private final ReviewDb db;
|
private final ReviewDb db;
|
||||||
private final GroupCache groupCache;
|
private final GroupCache groupCache;
|
||||||
private final GroupControl.Factory groupControlFactory;
|
private final GroupControl.Factory groupControlFactory;
|
||||||
|
private final GroupDetailFactory.Factory groupDetailFactory;
|
||||||
|
|
||||||
private final AccountGroup.Id groupId;
|
private final AccountGroup.Id groupId;
|
||||||
private final String newName;
|
private final String newName;
|
||||||
@ -45,18 +46,18 @@ class RenameGroup extends Handler<VoidResult> {
|
|||||||
@Inject
|
@Inject
|
||||||
RenameGroup(final ReviewDb db, final GroupCache groupCache,
|
RenameGroup(final ReviewDb db, final GroupCache groupCache,
|
||||||
final GroupControl.Factory groupControlFactory,
|
final GroupControl.Factory groupControlFactory,
|
||||||
|
final GroupDetailFactory.Factory groupDetailFactory,
|
||||||
@Assisted final AccountGroup.Id groupId, @Assisted final String newName) {
|
@Assisted final AccountGroup.Id groupId, @Assisted final String newName) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.groupCache = groupCache;
|
this.groupCache = groupCache;
|
||||||
this.groupControlFactory = groupControlFactory;
|
this.groupControlFactory = groupControlFactory;
|
||||||
|
this.groupDetailFactory = groupDetailFactory;
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this.newName = newName;
|
this.newName = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoidResult call() throws OrmException, NameAlreadyUsedException,
|
public GroupDetail call() throws OrmException, NameAlreadyUsedException,
|
||||||
NoSuchGroupException {
|
NoSuchGroupException {
|
||||||
final GroupControl ctl = groupControlFactory.validateFor(groupId);
|
final GroupControl ctl = groupControlFactory.validateFor(groupId);
|
||||||
final AccountGroup group = db.accountGroups().get(groupId);
|
final AccountGroup group = db.accountGroups().get(groupId);
|
||||||
@ -75,7 +76,7 @@ class RenameGroup extends Handler<VoidResult> {
|
|||||||
//
|
//
|
||||||
AccountGroupName other = db.accountGroupNames().get(key);
|
AccountGroupName other = db.accountGroupNames().get(key);
|
||||||
if (other != null && other.getId().equals(groupId)) {
|
if (other != null && other.getId().equals(groupId)) {
|
||||||
return VoidResult.INSTANCE;
|
return groupDetailFactory.create(groupId).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, someone else has this identity.
|
// Otherwise, someone else has this identity.
|
||||||
@ -94,6 +95,6 @@ class RenameGroup extends Handler<VoidResult> {
|
|||||||
groupCache.evict(group);
|
groupCache.evict(group);
|
||||||
groupCache.evictAfterRename(old);
|
groupCache.evictAfterRename(old);
|
||||||
|
|
||||||
return VoidResult.INSTANCE;
|
return groupDetailFactory.create(groupId).call();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user