diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java index 20ff9930b3..86f543a8cc 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java @@ -143,4 +143,7 @@ public interface AdminConstants extends Constants { String buttonCreateDescription(); String buttonCreateChange(); String buttonCreateChangeDescription(); + String buttonEditConfig(); + String buttonEditConfigDescription(); + String editConfigMessage(); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties index 26b8123b69..4446354662 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties @@ -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 diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/EditConfigAction.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/EditConfigAction.java new file mode 100644 index 0000000000..86a31ee593 --- /dev/null +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/EditConfigAction.java @@ -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() { + @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); + } + }); + } +} diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java index e1fb925868..6cb92951a2 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java @@ -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);