+ ▶ |
[[file.status]] |
+ case 79: // 'o'
+ e.preventDefault();
+ page(this._computeDiffURL(this.changeNum, this.patchNum,
+ this.files[this.selectedIndex].__path));
+ break;
+ }
+ },
+
+ _computeFileSelected: function(index, selectedIndex) {
+ return index == selectedIndex;
+ },
+
_computeDiffURL: function(changeNum, patchNum, path) {
return '/c/' + changeNum + '/' + patchNum + '/' + path;
},
diff --git a/polygerrit-ui/app/scripts/app.js b/polygerrit-ui/app/scripts/app.js
index ce1a9b8959..1922311944 100644
--- a/polygerrit-ui/app/scripts/app.js
+++ b/polygerrit-ui/app/scripts/app.js
@@ -47,7 +47,7 @@ window.addEventListener('WebComponentsReady', function() {
page('/dashboard/(.*)', loadUser, function(data) {
if (app.loggedIn) {
- app.route = 'gr-dashboard-view';
+ data.params.view = 'gr-dashboard-view';
app.params = data.params;
} else {
page.redirect('/login/' + encodeURIComponent(data.canonicalPath));
@@ -55,7 +55,7 @@ window.addEventListener('WebComponentsReady', function() {
});
function queryHandler(data) {
- app.route = 'gr-change-list-view';
+ data.params.view = 'gr-change-list-view';
app.params = data.params;
}
@@ -67,17 +67,17 @@ window.addEventListener('WebComponentsReady', function() {
});
page('/c/:changeNum/:patchNum?', function(data) {
- app.route = 'gr-change-view';
+ data.params.view = 'gr-change-view';
app.params = data.params;
});
page(/^\/c\/(\d+)\/((\d+)(\.\.(\d+))?)\/(.+)/, function(ctx) {
- app.route = 'gr-diff-view';
var params = {
changeNum: ctx.params[0],
basePatchNum: ctx.params[2],
patchNum: ctx.params[4],
- path: ctx.params[5]
+ path: ctx.params[5],
+ view: 'gr-diff-view',
};
// Don't allow diffing the same patch number against itself because WHY?
if (params.basePatchNum == params.patchNum) {
diff --git a/polygerrit-ui/app/test/gr-file-list-test.html b/polygerrit-ui/app/test/gr-file-list-test.html
index eef97902a1..a6fd840b5c 100644
--- a/polygerrit-ui/app/test/gr-file-list-test.html
+++ b/polygerrit-ui/app/test/gr-file-list-test.html
@@ -123,6 +123,46 @@ limitations under the License.
}, 1);
});
+ test('keyboard shortcuts', function(done) {
+ element.changeNum = '42';
+ element.patchNum = '2';
+ element.selectedIndex = 0;
+ element.reload();
+ server.respond();
+
+ element.async(function() {
+ var elementItems = Polymer.dom(element.root).querySelectorAll(
+ '.fileRow');
+ assert.equal(elementItems.length, 3);
+ assert.isTrue(elementItems[0].hasAttribute('selected'));
+ assert.isFalse(elementItems[1].hasAttribute('selected'));
+ assert.isFalse(elementItems[2].hasAttribute('selected'));
+ MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
+ assert.equal(element.selectedIndex, 1);
+ MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
+
+ var showStub = sinon.stub(page, 'show');
+ assert.equal(element.selectedIndex, 2);
+ MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
+ assert(showStub.lastCall.calledWith('/c/42/2/myfile.txt'),
+ 'Should navigate to /c/42/2/myfile.txt');
+
+ MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
+ assert.equal(element.selectedIndex, 1);
+ MockInteractions.pressAndReleaseKeyOn(element, 79); // 'o'
+ assert(showStub.lastCall.calledWith('/c/42/2/file_added_in_rev2.txt'),
+ 'Should navigate to /c/42/2/file_added_in_rev2.txt');
+
+ MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
+ MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
+ MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
+ assert.equal(element.selectedIndex, 0);
+
+ showStub.restore();
+ done();
+ }, 1);
+ });
+
test('comment filtering', function() {
var comments = {
'/COMMIT_MSG': [
|