Add 'a' as shortcut to go to change and open reply box

This saves one keystroke when going from a file back to the
change screen to send a reply comment.

CodeMirror seems to be eating the 'a' and refuses to let us
bind to the character there.

Change-Id: I2cfac04cad9a9cebe94913ae9f464894df4c2a7d
This commit is contained in:
Shawn Pearce
2013-08-14 13:08:24 -07:00
parent 7f605c1584
commit b7cf9b6271
5 changed files with 44 additions and 10 deletions

View File

@@ -470,7 +470,9 @@ public class Dispatcher {
if (rest.isEmpty()) {
Gerrit.display(token, panel== null
? (useChangeScreen2 ? new ChangeScreen2(id, null) : new ChangeScreen(id))
? (useChangeScreen2
? new ChangeScreen2(id, null, false)
: new ChangeScreen(id))
: new NotFoundScreen());
return;
}
@@ -502,7 +504,7 @@ public class Dispatcher {
} else {
if (panel == null) {
Gerrit.display(token, useChangeScreen2
? new ChangeScreen2(id, String.valueOf(ps.get()))
? new ChangeScreen2(id, String.valueOf(ps.get()), false)
: new ChangeScreen(id));
} else if ("publish".equals(panel)) {
publish(ps);
@@ -524,7 +526,7 @@ public class Dispatcher {
rest = "";
}
useChangeScreen2 = true;
Gerrit.display(token, new ChangeScreen2(id, rest));
Gerrit.display(token, new ChangeScreen2(id, rest, false));
}
private static void publish(final PatchSet.Id ps) {

View File

@@ -115,6 +115,7 @@ public class ChangeScreen2 extends Screen {
private UpdateCheckTimer updateCheck;
private Timestamp lastDisplayedUpdate;
private UpdateAvailableBar updateAvailable;
private boolean openReplyBox;
@UiField Style style;
@UiField ToggleButton star;
@@ -150,9 +151,10 @@ public class ChangeScreen2 extends Screen {
@UiField QuickApprove quickApprove;
private ReplyAction replyAction;
public ChangeScreen2(Change.Id changeId, String revision) {
public ChangeScreen2(Change.Id changeId, String revision, boolean openReplyBox) {
this.changeId = changeId;
this.revision = revision != null && !revision.isEmpty() ? revision : null;
this.openReplyBox = openReplyBox;
add(uiBinder.createAndBindUi(this));
}
@@ -256,10 +258,15 @@ public class ChangeScreen2 extends Screen {
.getParentElement()
.getOffsetHeight());
String prior = Gerrit.getPriorView();
if (prior != null && prior.startsWith("/c/")) {
scrollToPath(prior.substring(3));
if (openReplyBox) {
onReply();
} else {
String prior = Gerrit.getPriorView();
if (prior != null && prior.startsWith("/c/")) {
scrollToPath(prior.substring(3));
}
}
startPoller();
}
@@ -301,14 +308,16 @@ public class ChangeScreen2 extends Screen {
if (0 <= idx) {
String n = revisionList.getValue(idx);
revisionList.setEnabled(false);
Gerrit.display(
PageLinks.toChange2(changeId, n),
new ChangeScreen2(changeId, n));
Gerrit.display(PageLinks.toChange2(changeId, n));
}
}
@UiHandler("reply")
void onReply(ClickEvent e) {
onReply();
}
private void onReply() {
if (Gerrit.isSignedIn()) {
replyAction.onReply();
} else {

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.client.diff;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.change.ChangeScreen2;
import com.google.gerrit.client.changes.CommentApi;
import com.google.gerrit.client.changes.CommentInfo;
import com.google.gerrit.client.diff.DiffInfo.Region;
@@ -34,6 +35,7 @@ import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.changes.Side;
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
@@ -264,6 +266,7 @@ public class SideBySide2 extends Screen {
cm.addKeyMap(KeyMap.create()
.on("'j'", moveCursorDown(cm, 1))
.on("'k'", moveCursorDown(cm, -1))
.on("'a'", openReplyBox())
.on("'u'", upToChange())
.on("'r'", toggleReviewed())
.on("'o'", toggleOpenBox(cm))
@@ -287,6 +290,12 @@ public class SideBySide2 extends Screen {
toggleReviewed().run();
}
});
keysAction.add(new KeyCommand(0, 'a', PatchUtil.C.openReply()) {
@Override
public void onKeyPress(KeyPressEvent event) {
openReplyBox().run();
}
});
keysOpenByEnter = new KeyCommandSet(Gerrit.C.sectionNavigation());
keysOpenByEnter.add(new NoOpKeyCommand(0, KeyCodes.KEY_ENTER,
@@ -956,6 +965,18 @@ public class SideBySide2 extends Screen {
};
}
private Runnable openReplyBox() {
return new Runnable() {
public void run() {
Change.Id id = revision.getParentKey();
String rev = String.valueOf(revision.get());
Gerrit.display(
PageLinks.toChange2(id, rev),
new ChangeScreen2(id, rev, true));
}
};
}
private Runnable upToChange() {
return new Runnable() {
public void run() {

View File

@@ -40,6 +40,7 @@ public interface PatchConstants extends Constants {
String illegalNumberOfColumns();
String upToChange();
String openReply();
String linePrev();
String lineNext();
String chunkPrev();

View File

@@ -22,6 +22,7 @@ intralineTimeout = Intraline difference not available due to timeout.
illegalNumberOfColumns = The number of columns cannot be zero or negative
upToChange = Up to change
openReply = Reply and score
linePrev = Previous line
lineNext = Next line
chunkPrev = Previous diff chunk or comment