Add a screen to allow changing project owner, description
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import com.google.gerrit.client.account.AccountSettings;
|
||||
import com.google.gerrit.client.account.NewAgreementScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupScreen;
|
||||
import com.google.gerrit.client.admin.GroupListScreen;
|
||||
import com.google.gerrit.client.admin.ProjectAdminScreen;
|
||||
import com.google.gerrit.client.admin.ProjectListScreen;
|
||||
import com.google.gerrit.client.changes.AccountDashboardScreen;
|
||||
import com.google.gerrit.client.changes.ChangeScreen;
|
||||
@@ -153,6 +154,10 @@ public class Link implements HistoryListener {
|
||||
if (token.startsWith(p))
|
||||
return new AccountGroupScreen(AccountGroup.Id.parse(skip(p, token)));
|
||||
|
||||
p = "admin,project,";
|
||||
if (token.startsWith(p))
|
||||
return new ProjectAdminScreen(Project.Id.parse(skip(p, token)));
|
||||
|
||||
if (ADMIN_GROUPS.equals(token)) {
|
||||
return new GroupListScreen();
|
||||
}
|
||||
|
@@ -17,5 +17,6 @@ package com.google.gerrit.client.admin;
|
||||
import com.google.gwt.i18n.client.Messages;
|
||||
|
||||
public interface AdminMessages extends Messages {
|
||||
public String group(String name);
|
||||
String group(String name);
|
||||
String project(String name);
|
||||
}
|
||||
|
@@ -1 +1,2 @@
|
||||
group = Group {0}
|
||||
project = Project {0}
|
||||
|
@@ -0,0 +1,144 @@
|
||||
// Copyright 2008 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.admin;
|
||||
|
||||
import com.google.gerrit.client.reviewdb.Project;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
|
||||
import com.google.gerrit.client.ui.AccountScreen;
|
||||
import com.google.gerrit.client.ui.TextSaveButtonListener;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.ClickListener;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.TextArea;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
|
||||
public class ProjectAdminScreen extends AccountScreen {
|
||||
private Project.Id projectId;
|
||||
|
||||
private TextBox ownerTxtBox;
|
||||
private SuggestBox ownerTxt;
|
||||
private Button saveOwner;
|
||||
|
||||
private TextArea descTxt;
|
||||
private Button saveDesc;
|
||||
|
||||
public ProjectAdminScreen(final Project.Id toShow) {
|
||||
projectId = toShow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (descTxt == null) {
|
||||
initUI();
|
||||
}
|
||||
|
||||
enableForm(false);
|
||||
saveOwner.setEnabled(false);
|
||||
saveDesc.setEnabled(false);
|
||||
super.onLoad();
|
||||
|
||||
Util.PROJECT_SVC.projectDetail(projectId,
|
||||
new GerritCallback<ProjectDetail>() {
|
||||
public void onSuccess(final ProjectDetail result) {
|
||||
enableForm(true);
|
||||
saveOwner.setEnabled(false);
|
||||
saveDesc.setEnabled(false);
|
||||
display(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enableForm(final boolean on) {
|
||||
ownerTxtBox.setEnabled(on);
|
||||
descTxt.setEnabled(on);
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
initOwner();
|
||||
initDescription();
|
||||
}
|
||||
|
||||
|
||||
private void initOwner() {
|
||||
final VerticalPanel ownerPanel = new VerticalPanel();
|
||||
final Label ownerHdr = new Label(Util.C.headingOwner());
|
||||
ownerHdr.setStyleName("gerrit-SmallHeading");
|
||||
ownerPanel.add(ownerHdr);
|
||||
|
||||
ownerTxtBox = new TextBox();
|
||||
ownerTxtBox.setVisibleLength(60);
|
||||
ownerTxt = new SuggestBox(new AccountGroupSuggestOracle(), ownerTxtBox);
|
||||
ownerPanel.add(ownerTxt);
|
||||
|
||||
saveOwner = new Button(Util.C.buttonChangeGroupOwner());
|
||||
saveOwner.addClickListener(new ClickListener() {
|
||||
public void onClick(Widget sender) {
|
||||
final String newOwner = ownerTxt.getText().trim();
|
||||
if (newOwner.length() > 0) {
|
||||
Util.PROJECT_SVC.changeProjectOwner(projectId, newOwner,
|
||||
new GerritCallback<VoidResult>() {
|
||||
public void onSuccess(final VoidResult result) {
|
||||
saveOwner.setEnabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
ownerPanel.add(saveOwner);
|
||||
add(ownerPanel);
|
||||
|
||||
new TextSaveButtonListener(ownerTxtBox, saveOwner);
|
||||
}
|
||||
|
||||
private void initDescription() {
|
||||
final VerticalPanel vp = new VerticalPanel();
|
||||
final Label descHdr = new Label(Util.C.headingDescription());
|
||||
descHdr.setStyleName("gerrit-SmallHeading");
|
||||
vp.add(descHdr);
|
||||
|
||||
descTxt = new TextArea();
|
||||
descTxt.setVisibleLines(6);
|
||||
descTxt.setCharacterWidth(60);
|
||||
vp.add(descTxt);
|
||||
|
||||
saveDesc = new Button(Util.C.buttonSaveDescription());
|
||||
saveDesc.addClickListener(new ClickListener() {
|
||||
public void onClick(Widget sender) {
|
||||
final String txt = descTxt.getText().trim();
|
||||
Util.PROJECT_SVC.changeProjectDescription(projectId, txt,
|
||||
new GerritCallback<VoidResult>() {
|
||||
public void onSuccess(final VoidResult result) {
|
||||
saveDesc.setEnabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
vp.add(saveDesc);
|
||||
add(vp);
|
||||
|
||||
new TextSaveButtonListener(descTxt, saveDesc);
|
||||
}
|
||||
|
||||
private void display(final ProjectDetail result) {
|
||||
setTitleText(Util.M.project(result.project.getName()));
|
||||
ownerTxt.setText(result.ownerGroup.getName());
|
||||
descTxt.setText(result.project.getDescription());
|
||||
}
|
||||
}
|
@@ -65,6 +65,13 @@ public final class Project {
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
|
||||
/** Parse a Project.Id out of a string representation. */
|
||||
public static Id parse(final String str) {
|
||||
final Id r = new Id();
|
||||
r.fromString(str);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
@Column
|
||||
|
Reference in New Issue
Block a user