Remove old EditCommitMessage RPC
Change-Id: Ic25c5d68f3bb27423b7c6b829169e33c8361eba5
This commit is contained in:
@@ -25,11 +25,6 @@ import com.google.gwtjsonrpc.common.RpcImpl.Version;
|
|||||||
|
|
||||||
@RpcImpl(version = Version.V2_0)
|
@RpcImpl(version = Version.V2_0)
|
||||||
public interface ChangeManageService extends RemoteJsonService {
|
public interface ChangeManageService extends RemoteJsonService {
|
||||||
@Audit
|
|
||||||
@SignInRequired
|
|
||||||
void createNewPatchSet(final PatchSet.Id patchSetId, final String newCommitMessage,
|
|
||||||
final AsyncCallback<ChangeDetail> callback);
|
|
||||||
|
|
||||||
@Audit
|
@Audit
|
||||||
@SignInRequired
|
@SignInRequired
|
||||||
void publish(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback);
|
void publish(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class ChangeDescriptionBlock extends Composite {
|
|||||||
SubmitTypeRecord submitTypeRecord,
|
SubmitTypeRecord submitTypeRecord,
|
||||||
CommentLinkProcessor commentLinkProcessor) {
|
CommentLinkProcessor commentLinkProcessor) {
|
||||||
infoBlock.display(changeDetail, acc, submitTypeRecord);
|
infoBlock.display(changeDetail, acc, submitTypeRecord);
|
||||||
messageBlock.display(changeDetail.getChange().currentPatchSetId(), starred,
|
messageBlock.display(changeDetail.getChange().currentPatchSetId(), info.getRevId(), starred,
|
||||||
canEditCommitMessage, info.getMessage(), commentLinkProcessor);
|
canEditCommitMessage, info.getMessage(), commentLinkProcessor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,17 +14,17 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.changes;
|
package com.google.gerrit.client.changes;
|
||||||
|
|
||||||
import com.google.gerrit.client.ErrorDialog;
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.ui.ChangeLink;
|
import com.google.gerrit.client.ui.ChangeLink;
|
||||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||||
import com.google.gerrit.client.ui.CommentedActionDialog;
|
import com.google.gerrit.client.ui.CommentedActionDialog;
|
||||||
import com.google.gerrit.client.ui.TextBoxChangeListener;
|
import com.google.gerrit.client.ui.TextBoxChangeListener;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.dom.client.PreElement;
|
import com.google.gwt.dom.client.PreElement;
|
||||||
import com.google.gwt.dom.client.Style.Display;
|
import com.google.gwt.dom.client.Style.Display;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
@@ -70,13 +70,14 @@ public class CommitMessageBlock extends Composite {
|
|||||||
|
|
||||||
public void display(String commitMessage,
|
public void display(String commitMessage,
|
||||||
CommentLinkProcessor commentLinkProcessor) {
|
CommentLinkProcessor commentLinkProcessor) {
|
||||||
display(null, null, false, commitMessage, commentLinkProcessor);
|
display(null, null, null, false, commitMessage, commentLinkProcessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract class CommitMessageEditDialog extends CommentedActionDialog<ChangeDetail> {
|
private abstract class CommitMessageEditDialog
|
||||||
|
extends CommentedActionDialog<JavaScriptObject> {
|
||||||
private final String originalMessage;
|
private final String originalMessage;
|
||||||
public CommitMessageEditDialog(final String title, final String heading,
|
public CommitMessageEditDialog(final String title, final String heading,
|
||||||
final String commitMessage, AsyncCallback<ChangeDetail> callback) {
|
final String commitMessage, AsyncCallback<JavaScriptObject> callback) {
|
||||||
super(title, heading, callback);
|
super(title, heading, callback);
|
||||||
originalMessage = commitMessage.trim();
|
originalMessage = commitMessage.trim();
|
||||||
message.setCharacterWidth(72);
|
message.setCharacterWidth(72);
|
||||||
@@ -103,7 +104,7 @@ public class CommitMessageBlock extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(final PatchSet.Id patchSetId,
|
public void display(final PatchSet.Id patchSetId, final String revision,
|
||||||
Boolean starred, Boolean canEditCommitMessage, final String commitMessage,
|
Boolean starred, Boolean canEditCommitMessage, final String commitMessage,
|
||||||
CommentLinkProcessor commentLinkProcessor) {
|
CommentLinkProcessor commentLinkProcessor) {
|
||||||
starPanel.clear();
|
starPanel.clear();
|
||||||
@@ -119,7 +120,7 @@ public class CommitMessageBlock extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
permalinkPanel.clear();
|
permalinkPanel.clear();
|
||||||
if (patchSetId != null) {
|
if (patchSetId != null && revision != null) {
|
||||||
final Change.Id changeId = patchSetId.getParentKey();
|
final Change.Id changeId = patchSetId.getParentKey();
|
||||||
permalinkPanel.add(new ChangeLink(Util.C.changePermalink(), changeId));
|
permalinkPanel.add(new ChangeLink(Util.C.changePermalink(), changeId));
|
||||||
permalinkPanel.add(new CopyableLabel(ChangeLink.permalink(changeId),
|
permalinkPanel.add(new CopyableLabel(ChangeLink.permalink(changeId),
|
||||||
@@ -134,24 +135,20 @@ public class CommitMessageBlock extends Composite {
|
|||||||
new CommitMessageEditDialog(Util.C.titleEditCommitMessage(),
|
new CommitMessageEditDialog(Util.C.titleEditCommitMessage(),
|
||||||
Util.C.headingEditCommitMessage(),
|
Util.C.headingEditCommitMessage(),
|
||||||
commitMessage,
|
commitMessage,
|
||||||
new ChangeDetailCache.IgnoreErrorCallback() {}) {
|
new GerritCallback<JavaScriptObject>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(JavaScriptObject result) {}
|
||||||
|
}) {
|
||||||
@Override
|
@Override
|
||||||
public void onSend() {
|
public void onSend() {
|
||||||
Util.MANAGE_SVC.createNewPatchSet(patchSetId, getMessageText(),
|
ChangeApi.message(changeId.get(), revision, getMessageText(),
|
||||||
new AsyncCallback<ChangeDetail>() {
|
new GerritCallback<JavaScriptObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ChangeDetail result) {
|
public void onSuccess(JavaScriptObject msg) {
|
||||||
Gerrit.display(PageLinks.toChange(changeId));
|
Gerrit.display(PageLinks.toChange(changeId));
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
new ErrorDialog(caught.getMessage()).center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}.center();
|
}.center();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.httpd.rpc.changedetail;
|
|||||||
import com.google.gerrit.common.data.ChangeDetail;
|
import com.google.gerrit.common.data.ChangeDetail;
|
||||||
import com.google.gerrit.common.data.ChangeManageService;
|
import com.google.gerrit.common.data.ChangeManageService;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet.Id;
|
|
||||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||||
import com.google.gwtjsonrpc.common.VoidResult;
|
import com.google.gwtjsonrpc.common.VoidResult;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -26,18 +25,15 @@ class ChangeManageServiceImpl implements ChangeManageService {
|
|||||||
private final RebaseChangeHandler.Factory rebaseChangeFactory;
|
private final RebaseChangeHandler.Factory rebaseChangeFactory;
|
||||||
private final PublishAction.Factory publishAction;
|
private final PublishAction.Factory publishAction;
|
||||||
private final DeleteDraftChange.Factory deleteDraftChangeFactory;
|
private final DeleteDraftChange.Factory deleteDraftChangeFactory;
|
||||||
private final EditCommitMessageHandler.Factory editCommitMessageHandlerFactory;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChangeManageServiceImpl(
|
ChangeManageServiceImpl(
|
||||||
final RebaseChangeHandler.Factory rebaseChangeFactory,
|
final RebaseChangeHandler.Factory rebaseChangeFactory,
|
||||||
final PublishAction.Factory publishAction,
|
final PublishAction.Factory publishAction,
|
||||||
final DeleteDraftChange.Factory deleteDraftChangeFactory,
|
final DeleteDraftChange.Factory deleteDraftChangeFactory) {
|
||||||
final EditCommitMessageHandler.Factory editCommitMessageHandler) {
|
|
||||||
this.rebaseChangeFactory = rebaseChangeFactory;
|
this.rebaseChangeFactory = rebaseChangeFactory;
|
||||||
this.publishAction = publishAction;
|
this.publishAction = publishAction;
|
||||||
this.deleteDraftChangeFactory = deleteDraftChangeFactory;
|
this.deleteDraftChangeFactory = deleteDraftChangeFactory;
|
||||||
this.editCommitMessageHandlerFactory = editCommitMessageHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebaseChange(final PatchSet.Id patchSetId,
|
public void rebaseChange(final PatchSet.Id patchSetId,
|
||||||
@@ -54,9 +50,4 @@ class ChangeManageServiceImpl implements ChangeManageService {
|
|||||||
final AsyncCallback<VoidResult> callback) {
|
final AsyncCallback<VoidResult> callback) {
|
||||||
deleteDraftChangeFactory.create(patchSetId).to(callback);
|
deleteDraftChangeFactory.create(patchSetId).to(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createNewPatchSet(Id patchSetId, String message,
|
|
||||||
AsyncCallback<ChangeDetail> callback) {
|
|
||||||
editCommitMessageHandlerFactory.create(patchSetId, message).to(callback);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ public class ChangeModule extends RpcServletModule {
|
|||||||
install(new FactoryModule() {
|
install(new FactoryModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
factory(EditCommitMessageHandler.Factory.class);
|
|
||||||
factory(RebaseChangeHandler.Factory.class);
|
factory(RebaseChangeHandler.Factory.class);
|
||||||
factory(ChangeDetailFactory.Factory.class);
|
factory(ChangeDetailFactory.Factory.class);
|
||||||
factory(IncludedInDetailFactory.Factory.class);
|
factory(IncludedInDetailFactory.Factory.class);
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
// Copyright (C) 2012 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.httpd.rpc.changedetail;
|
|
||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.errors.EmailException;
|
|
||||||
import com.google.gerrit.common.errors.NoSuchEntityException;
|
|
||||||
import com.google.gerrit.httpd.rpc.Handler;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
|
||||||
import com.google.gerrit.server.change.PatchSetInserter;
|
|
||||||
import com.google.gerrit.server.mail.CommitMessageEditedSender;
|
|
||||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
|
||||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
|
||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
|
||||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
|
||||||
import com.google.gwtorm.server.OrmException;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.assistedinject.Assisted;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class EditCommitMessageHandler extends Handler<ChangeDetail> {
|
|
||||||
interface Factory {
|
|
||||||
EditCommitMessageHandler create(PatchSet.Id patchSetId, String message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final ChangeControl.Factory changeControlFactory;
|
|
||||||
private final ChangeDetailFactory.Factory changeDetailFactory;
|
|
||||||
private final ChangeUtil changeUtil;
|
|
||||||
private final PatchSet.Id patchSetId;
|
|
||||||
@Nullable
|
|
||||||
private final String message;
|
|
||||||
private final PersonIdent myIdent;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
EditCommitMessageHandler(ChangeControl.Factory changeControlFactory,
|
|
||||||
ChangeDetailFactory.Factory changeDetailFactory,
|
|
||||||
CommitMessageEditedSender.Factory commitMessageEditedSenderFactory,
|
|
||||||
@Assisted PatchSet.Id patchSetId,
|
|
||||||
@Assisted @Nullable String message,
|
|
||||||
ChangeUtil changeUtil,
|
|
||||||
@GerritPersonIdent PersonIdent myIdent,
|
|
||||||
PatchSetInserter.Factory patchSetInserterFactory) {
|
|
||||||
this.changeControlFactory = changeControlFactory;
|
|
||||||
this.changeDetailFactory = changeDetailFactory;
|
|
||||||
this.changeUtil = changeUtil;
|
|
||||||
this.patchSetId = patchSetId;
|
|
||||||
this.message = message;
|
|
||||||
this.myIdent = myIdent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChangeDetail call() throws NoSuchChangeException, OrmException,
|
|
||||||
EmailException, NoSuchEntityException, PatchSetInfoNotAvailableException,
|
|
||||||
MissingObjectException, IncorrectObjectTypeException, IOException,
|
|
||||||
InvalidChangeOperationException, NoSuchProjectException {
|
|
||||||
Change.Id changeId = patchSetId.getParentKey();
|
|
||||||
ChangeControl control = changeControlFactory.validateFor(changeId);
|
|
||||||
if (!control.canAddPatchSet()) {
|
|
||||||
throw new InvalidChangeOperationException(
|
|
||||||
"Not allowed to add new Patch Sets to: " + changeId.toString());
|
|
||||||
}
|
|
||||||
changeUtil.editCommitMessage(control, patchSetId, message, myIdent);
|
|
||||||
return changeDetailFactory.create(changeId).call();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user