Disable send button when commit message is unchanged
dd2bd5c adds a check in the commit message edit service to
prevent a new patch set from being added when the given commit
message is the same as the existing one. However it is still
possible for the user to send a commit edit request from the Web
UI with an unchanged commit message, which results in an error
dialog.
Add a new helper class that watches for changes on a text box
and notifies changes. Use this in the commit message editor
dialog to enable the send button only when the text differs from
the existing commit message text.
Change-Id: I249beaa24e8a30bddd6f6a471053396a3fd2dafa
This commit is contained in:
@@ -19,6 +19,7 @@ import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.ui.ChangeLink;
|
||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||
import com.google.gerrit.client.ui.CommentedActionDialog;
|
||||
import com.google.gerrit.client.ui.TextBoxChangeListener;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.common.data.ChangeDetail;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -72,13 +73,24 @@ public class CommitMessageBlock extends Composite {
|
||||
}
|
||||
|
||||
private abstract class CommitMessageEditDialog extends CommentedActionDialog<ChangeDetail> {
|
||||
private final String originalMessage;
|
||||
public CommitMessageEditDialog(final String title, final String heading,
|
||||
final String commitMessage, AsyncCallback<ChangeDetail> callback) {
|
||||
super(title, heading, callback);
|
||||
originalMessage = commitMessage.trim();
|
||||
message.setCharacterWidth(72);
|
||||
message.setVisibleLines(20);
|
||||
message.setText(commitMessage);
|
||||
message.setText(originalMessage);
|
||||
message.addStyleName(Gerrit.RESOURCES.css().changeScreenDescription());
|
||||
sendButton.setEnabled(false);
|
||||
|
||||
new TextBoxChangeListener(message) {
|
||||
public void onTextChanged(String newText) {
|
||||
// Trim the new text so we don't consider trailing
|
||||
// newlines as changes
|
||||
sendButton.setEnabled(!newText.trim().equals(originalMessage));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getMessageText() {
|
||||
|
||||
Reference in New Issue
Block a user