From fd664628aca038d7ddb80672be8bff49ccca8ada Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 24 Jul 2017 15:31:00 -0400 Subject: [PATCH] add r key shortcut to toggle review flag This adds support to the PG UI for the review toggle like we had in the old UI. Bug: Issue 6784 Change-Id: Ib44c46d17333c2a48fc647593c377f9c0bbc6314 --- .../elements/change/gr-file-list/gr-file-list.js | 12 ++++++++++++ .../change/gr-file-list/gr-file-list_test.html | 15 +++++++++++++++ .../gr-keyboard-shortcuts-dialog.html | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js index d7efb8f1db..e86c088791 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js @@ -136,6 +136,7 @@ 'o': '_handleOKey', 'n': '_handleNKey', 'p': '_handlePKey', + 'r': '_handleRKey', 'shift+a': '_handleCapitalAKey', 'esc': '_handleEscKey', }, @@ -581,6 +582,17 @@ } }, + _handleRKey(e) { + if (this.shouldSuppressKeyboardShortcut(e) || + this.modifierPressed(e) && !this.isModifierPressed(e, 'shiftKey')) { + return; + } + + e.preventDefault(); + if (!this._files[this.$.fileCursor.index]) { return; } + this._reviewFile(this._files[this.$.fileCursor.index].__path); + }, + _handleCapitalAKey(e) { if (this.shouldSuppressKeyboardShortcut(e)) { return; } diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html index 2aab92e7fc..4791dc354e 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html @@ -385,6 +385,21 @@ limitations under the License. } }); + test('r key toggles reviewed flag', () => { + flushAsynchronousOperations(); + + // Default state should be unreviewed. + assert.equal(element._reviewed.length, 0); + + // Press the review key to toggle it (set the flag). + MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r'); + assert.equal(element._reviewed.length, 1); + + // Press the review key to toggle it (clear the flag). + MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r'); + assert.equal(element._reviewed.length, 0); + }); + suite('_handleOKey', () => { let interact; diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html index d61def1903..427a042875 100644 --- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html +++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html @@ -234,6 +234,10 @@ limitations under the License. o Show selected file + + r + Toggle review flag on selected file + Shift