Add UiAction to create change from project info page
Change-Id: I2c9f23e644a020bcd30a478fbd3156e94a0c00d5
This commit is contained in:
committed by
Dave Borowitz
parent
74b27c6ac4
commit
0ec2763bc3
@@ -138,4 +138,9 @@ public interface AdminConstants extends Constants {
|
||||
|
||||
String pagedListPrev();
|
||||
String pagedListNext();
|
||||
|
||||
String buttonCreate();
|
||||
String buttonCreateDescription();
|
||||
String buttonCreateChange();
|
||||
String buttonCreateChangeDescription();
|
||||
}
|
||||
|
||||
@@ -162,3 +162,8 @@ sectionTypeSection = Section:
|
||||
sectionNames = \
|
||||
GLOBAL_CAPABILITIES
|
||||
GLOBAL_CAPABILITIES = Global Capabilities
|
||||
|
||||
buttonCreate = Create
|
||||
buttonCreateDescription = Insert the description of the change.
|
||||
buttonCreateChange = Create Change
|
||||
buttonCreateChangeDescription = Create change directly in the browser.
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// 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.Gerrit;
|
||||
import com.google.gerrit.client.changes.ChangeApi;
|
||||
import com.google.gerrit.client.changes.ChangeInfo;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.ui.CreateChangeDialog;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
|
||||
class CreateChangeAction {
|
||||
static void call(Button b, final String project) {
|
||||
// TODO Replace CreateChangeDialog with a nicer looking display.
|
||||
b.setEnabled(false);
|
||||
new CreateChangeDialog(b, new Project.NameKey(project)) {
|
||||
{
|
||||
sendButton.setText(Util.C.buttonCreate());
|
||||
message.setText(Util.C.buttonCreateDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend() {
|
||||
ChangeApi.createChange(project, getDestinationBranch(),
|
||||
message.getText(),
|
||||
new GerritCallback<ChangeInfo>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeInfo result) {
|
||||
sent = true;
|
||||
hide();
|
||||
Gerrit.display(PageLinks.toChange(result.legacy_id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
enableButtons(true);
|
||||
super.onFailure(caught);
|
||||
}
|
||||
});
|
||||
}
|
||||
}.center();
|
||||
}
|
||||
}
|
||||
@@ -565,10 +565,27 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
actionsPanel.setStyleName(Gerrit.RESOURCES.css().projectActions());
|
||||
actionsPanel.setVisible(true);
|
||||
actionsGrid.add(Util.C.headingCommands(), actionsPanel);
|
||||
|
||||
for (String id : actions.keySet()) {
|
||||
actionsPanel.add(new ActionButton(getProjectKey(),
|
||||
actions.get(id)));
|
||||
}
|
||||
|
||||
if (Gerrit.isSignedIn()) {
|
||||
actionsPanel.add(createChangeAction());
|
||||
}
|
||||
}
|
||||
|
||||
private Button createChangeAction() {
|
||||
final Button createChange = new Button(Util.C.buttonCreateChange());
|
||||
createChange.setTitle(Util.C.buttonCreateChangeDescription());
|
||||
createChange.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
CreateChangeAction.call(createChange, getProjectKey().get());
|
||||
}
|
||||
});
|
||||
return createChange;
|
||||
}
|
||||
|
||||
private void doSave() {
|
||||
|
||||
Reference in New Issue
Block a user