Add action to edit the project configuration in the browser
Add an 'Edit Config' button to the ProjectInfoScreen that creates a new change for the 'refs/meta/config' branch and opens the 'project.config' file in the EditScreen. This allows project owners to easily edit the 'project.config' file from the browser. This is useful since not all configuration options might be available from the UI. Change-Id: I4ada81090149b6058a206e0df745b42f33a29b85 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -143,4 +143,7 @@ public interface AdminConstants extends Constants {
|
||||
String buttonCreateDescription();
|
||||
String buttonCreateChange();
|
||||
String buttonCreateChangeDescription();
|
||||
String buttonEditConfig();
|
||||
String buttonEditConfigDescription();
|
||||
String editConfigMessage();
|
||||
}
|
||||
|
||||
@@ -167,3 +167,6 @@ buttonCreate = Create
|
||||
buttonCreateDescription = Insert the description of the change.
|
||||
buttonCreateChange = Create Change
|
||||
buttonCreateChangeDescription = Create change directly in the browser.
|
||||
buttonEditConfig = Edit Config
|
||||
buttonEditConfigDescription = Creates a change to edit the project configuration in the browser.
|
||||
editConfigMessage = Edit Project Config
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2015 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.Dispatcher;
|
||||
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.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
|
||||
public class EditConfigAction {
|
||||
static void call(final Button b, final String project) {
|
||||
b.setEnabled(false);
|
||||
|
||||
ChangeApi.createChange(project, RefNames.REFS_CONFIG,
|
||||
Util.C.editConfigMessage(), null, new GerritCallback<ChangeInfo>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeInfo result) {
|
||||
Gerrit.display(Dispatcher.toEditScreen(
|
||||
new PatchSet.Id(result.legacy_id(), 1), "project.config"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
b.setEnabled(true);
|
||||
super.onFailure(caught);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -581,6 +581,10 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
if (showCreateChange) {
|
||||
actionsPanel.add(createChangeAction());
|
||||
}
|
||||
|
||||
if (isOwner) {
|
||||
actionsPanel.add(createEditConfigAction());
|
||||
}
|
||||
}
|
||||
|
||||
private Button createChangeAction() {
|
||||
@@ -596,6 +600,19 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
return createChange;
|
||||
}
|
||||
|
||||
private Button createEditConfigAction() {
|
||||
final Button editConfig = new Button(Util.C.buttonEditConfig());
|
||||
editConfig.setStyleName("");
|
||||
editConfig.setTitle(Util.C.buttonEditConfigDescription());
|
||||
editConfig.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
EditConfigAction.call(editConfig, getProjectKey().get());
|
||||
}
|
||||
});
|
||||
return editConfig;
|
||||
}
|
||||
|
||||
private void doSave() {
|
||||
enableForm(false);
|
||||
saveProject.setEnabled(false);
|
||||
|
||||
Reference in New Issue
Block a user