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:
@@ -470,7 +470,9 @@ public class Dispatcher {
|
|||||||
|
|
||||||
if (rest.isEmpty()) {
|
if (rest.isEmpty()) {
|
||||||
Gerrit.display(token, panel== null
|
Gerrit.display(token, panel== null
|
||||||
? (useChangeScreen2 ? new ChangeScreen2(id, null) : new ChangeScreen(id))
|
? (useChangeScreen2
|
||||||
|
? new ChangeScreen2(id, null, false)
|
||||||
|
: new ChangeScreen(id))
|
||||||
: new NotFoundScreen());
|
: new NotFoundScreen());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -502,7 +504,7 @@ public class Dispatcher {
|
|||||||
} else {
|
} else {
|
||||||
if (panel == null) {
|
if (panel == null) {
|
||||||
Gerrit.display(token, useChangeScreen2
|
Gerrit.display(token, useChangeScreen2
|
||||||
? new ChangeScreen2(id, String.valueOf(ps.get()))
|
? new ChangeScreen2(id, String.valueOf(ps.get()), false)
|
||||||
: new ChangeScreen(id));
|
: new ChangeScreen(id));
|
||||||
} else if ("publish".equals(panel)) {
|
} else if ("publish".equals(panel)) {
|
||||||
publish(ps);
|
publish(ps);
|
||||||
@@ -524,7 +526,7 @@ public class Dispatcher {
|
|||||||
rest = "";
|
rest = "";
|
||||||
}
|
}
|
||||||
useChangeScreen2 = true;
|
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) {
|
private static void publish(final PatchSet.Id ps) {
|
||||||
|
@@ -115,6 +115,7 @@ public class ChangeScreen2 extends Screen {
|
|||||||
private UpdateCheckTimer updateCheck;
|
private UpdateCheckTimer updateCheck;
|
||||||
private Timestamp lastDisplayedUpdate;
|
private Timestamp lastDisplayedUpdate;
|
||||||
private UpdateAvailableBar updateAvailable;
|
private UpdateAvailableBar updateAvailable;
|
||||||
|
private boolean openReplyBox;
|
||||||
|
|
||||||
@UiField Style style;
|
@UiField Style style;
|
||||||
@UiField ToggleButton star;
|
@UiField ToggleButton star;
|
||||||
@@ -150,9 +151,10 @@ public class ChangeScreen2 extends Screen {
|
|||||||
@UiField QuickApprove quickApprove;
|
@UiField QuickApprove quickApprove;
|
||||||
private ReplyAction replyAction;
|
private ReplyAction replyAction;
|
||||||
|
|
||||||
public ChangeScreen2(Change.Id changeId, String revision) {
|
public ChangeScreen2(Change.Id changeId, String revision, boolean openReplyBox) {
|
||||||
this.changeId = changeId;
|
this.changeId = changeId;
|
||||||
this.revision = revision != null && !revision.isEmpty() ? revision : null;
|
this.revision = revision != null && !revision.isEmpty() ? revision : null;
|
||||||
|
this.openReplyBox = openReplyBox;
|
||||||
add(uiBinder.createAndBindUi(this));
|
add(uiBinder.createAndBindUi(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,10 +258,15 @@ public class ChangeScreen2 extends Screen {
|
|||||||
.getParentElement()
|
.getParentElement()
|
||||||
.getOffsetHeight());
|
.getOffsetHeight());
|
||||||
|
|
||||||
String prior = Gerrit.getPriorView();
|
if (openReplyBox) {
|
||||||
if (prior != null && prior.startsWith("/c/")) {
|
onReply();
|
||||||
scrollToPath(prior.substring(3));
|
} else {
|
||||||
|
String prior = Gerrit.getPriorView();
|
||||||
|
if (prior != null && prior.startsWith("/c/")) {
|
||||||
|
scrollToPath(prior.substring(3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startPoller();
|
startPoller();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,14 +308,16 @@ public class ChangeScreen2 extends Screen {
|
|||||||
if (0 <= idx) {
|
if (0 <= idx) {
|
||||||
String n = revisionList.getValue(idx);
|
String n = revisionList.getValue(idx);
|
||||||
revisionList.setEnabled(false);
|
revisionList.setEnabled(false);
|
||||||
Gerrit.display(
|
Gerrit.display(PageLinks.toChange2(changeId, n));
|
||||||
PageLinks.toChange2(changeId, n),
|
|
||||||
new ChangeScreen2(changeId, n));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("reply")
|
@UiHandler("reply")
|
||||||
void onReply(ClickEvent e) {
|
void onReply(ClickEvent e) {
|
||||||
|
onReply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onReply() {
|
||||||
if (Gerrit.isSignedIn()) {
|
if (Gerrit.isSignedIn()) {
|
||||||
replyAction.onReply();
|
replyAction.onReply();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.client.diff;
|
package com.google.gerrit.client.diff;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
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.CommentApi;
|
||||||
import com.google.gerrit.client.changes.CommentInfo;
|
import com.google.gerrit.client.changes.CommentInfo;
|
||||||
import com.google.gerrit.client.diff.DiffInfo.Region;
|
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.PageLinks;
|
||||||
import com.google.gerrit.common.changes.Side;
|
import com.google.gerrit.common.changes.Side;
|
||||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||||
|
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.core.client.JavaScriptObject;
|
||||||
@@ -264,6 +266,7 @@ public class SideBySide2 extends Screen {
|
|||||||
cm.addKeyMap(KeyMap.create()
|
cm.addKeyMap(KeyMap.create()
|
||||||
.on("'j'", moveCursorDown(cm, 1))
|
.on("'j'", moveCursorDown(cm, 1))
|
||||||
.on("'k'", moveCursorDown(cm, -1))
|
.on("'k'", moveCursorDown(cm, -1))
|
||||||
|
.on("'a'", openReplyBox())
|
||||||
.on("'u'", upToChange())
|
.on("'u'", upToChange())
|
||||||
.on("'r'", toggleReviewed())
|
.on("'r'", toggleReviewed())
|
||||||
.on("'o'", toggleOpenBox(cm))
|
.on("'o'", toggleOpenBox(cm))
|
||||||
@@ -287,6 +290,12 @@ public class SideBySide2 extends Screen {
|
|||||||
toggleReviewed().run();
|
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 = new KeyCommandSet(Gerrit.C.sectionNavigation());
|
||||||
keysOpenByEnter.add(new NoOpKeyCommand(0, KeyCodes.KEY_ENTER,
|
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() {
|
private Runnable upToChange() {
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@@ -40,6 +40,7 @@ public interface PatchConstants extends Constants {
|
|||||||
String illegalNumberOfColumns();
|
String illegalNumberOfColumns();
|
||||||
|
|
||||||
String upToChange();
|
String upToChange();
|
||||||
|
String openReply();
|
||||||
String linePrev();
|
String linePrev();
|
||||||
String lineNext();
|
String lineNext();
|
||||||
String chunkPrev();
|
String chunkPrev();
|
||||||
|
@@ -22,6 +22,7 @@ intralineTimeout = Intraline difference not available due to timeout.
|
|||||||
illegalNumberOfColumns = The number of columns cannot be zero or negative
|
illegalNumberOfColumns = The number of columns cannot be zero or negative
|
||||||
|
|
||||||
upToChange = Up to change
|
upToChange = Up to change
|
||||||
|
openReply = Reply and score
|
||||||
linePrev = Previous line
|
linePrev = Previous line
|
||||||
lineNext = Next line
|
lineNext = Next line
|
||||||
chunkPrev = Previous diff chunk or comment
|
chunkPrev = Previous diff chunk or comment
|
||||||
|
Reference in New Issue
Block a user