Merge "ChangeScreen2: Add keys to navigate to next/previous patch set"
This commit is contained in:
@@ -239,6 +239,17 @@ public class ChangeScreen2 extends Screen {
|
||||
Gerrit.display(PageLinks.toChange(changeId));
|
||||
}
|
||||
});
|
||||
keysNavigation.add(new KeyCommand(0, 'n', Util.C.keyNextPatchSet()) {
|
||||
@Override
|
||||
public void onKeyPress(final KeyPressEvent event) {
|
||||
gotoSibling(1);
|
||||
}
|
||||
}, new KeyCommand(0, 'p', Util.C.keyPreviousPatchSet()) {
|
||||
@Override
|
||||
public void onKeyPress(final KeyPressEvent event) {
|
||||
gotoSibling(-1);
|
||||
}
|
||||
});
|
||||
|
||||
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
|
||||
keysAction.add(new KeyCommand(0, 'a', Util.C.keyPublishComments()) {
|
||||
@@ -279,6 +290,30 @@ public class ChangeScreen2 extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
private void gotoSibling(final int offset) {
|
||||
if (offset > 0 && changeInfo.current_revision().equals(revision)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset < 0 && changeInfo.revision(revision)._number() == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
JsArray<RevisionInfo> revisions = changeInfo.revisions().values();
|
||||
RevisionInfo.sortRevisionInfoByNumber(revisions);
|
||||
for (int i = 0; i < revisions.length(); i++) {
|
||||
if (revision.equals(revisions.get(i).name())) {
|
||||
if (0 <= i + offset && i + offset < revisions.length()) {
|
||||
Gerrit.display(PageLinks.toChange(
|
||||
new PatchSet.Id(changeInfo.legacy_id(),
|
||||
revisions.get(i + offset)._number())));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initIncludedInAction(ChangeInfo info) {
|
||||
if (info.status() == Status.MERGED) {
|
||||
includedInAction = new IncludedInAction(
|
||||
|
||||
@@ -57,6 +57,8 @@ public interface ChangeConstants extends Constants {
|
||||
String previousPatchSet();
|
||||
String nextPatchSet();
|
||||
String keyReloadChange();
|
||||
String keyNextPatchSet();
|
||||
String keyPreviousPatchSet();
|
||||
String keyReloadSearch();
|
||||
String keyPublishComments();
|
||||
String keyEditTopic();
|
||||
|
||||
@@ -37,6 +37,8 @@ expandCollapseDependencies = Expands / Collapses dependencies section
|
||||
previousPatchSet = Previous patch set
|
||||
nextPatchSet = Next patch set
|
||||
keyReloadChange = Reload change
|
||||
keyNextPatchSet = Next patch set
|
||||
keyPreviousPatchSet = Previous patch set
|
||||
keyReloadSearch = Reload change list
|
||||
keyPublishComments = Review and publish comments
|
||||
keyEditTopic = Edit change topic
|
||||
|
||||
Reference in New Issue
Block a user