Merge "Add shift+m shortcut to diff view"
This commit is contained in:
@@ -165,6 +165,7 @@ shortcuts are.
|
|||||||
PREV_FILE: 'PREV_FILE',
|
PREV_FILE: 'PREV_FILE',
|
||||||
NEXT_FILE_WITH_COMMENTS: 'NEXT_FILE_WITH_COMMENTS',
|
NEXT_FILE_WITH_COMMENTS: 'NEXT_FILE_WITH_COMMENTS',
|
||||||
PREV_FILE_WITH_COMMENTS: 'PREV_FILE_WITH_COMMENTS',
|
PREV_FILE_WITH_COMMENTS: 'PREV_FILE_WITH_COMMENTS',
|
||||||
|
NEXT_UNREVIEWED_FILE: 'NEXT_UNREVIEWED_FILE',
|
||||||
CURSOR_NEXT_FILE: 'CURSOR_NEXT_FILE',
|
CURSOR_NEXT_FILE: 'CURSOR_NEXT_FILE',
|
||||||
CURSOR_PREV_FILE: 'CURSOR_PREV_FILE',
|
CURSOR_PREV_FILE: 'CURSOR_PREV_FILE',
|
||||||
OPEN_FILE: 'OPEN_FILE',
|
OPEN_FILE: 'OPEN_FILE',
|
||||||
@@ -255,6 +256,8 @@ shortcuts are.
|
|||||||
'Mark/unmark file as reviewed');
|
'Mark/unmark file as reviewed');
|
||||||
_describe(Shortcut.TOGGLE_DIFF_MODE, ShortcutSection.DIFFS,
|
_describe(Shortcut.TOGGLE_DIFF_MODE, ShortcutSection.DIFFS,
|
||||||
'Toggle unified/side-by-side diff');
|
'Toggle unified/side-by-side diff');
|
||||||
|
_describe(Shortcut.NEXT_UNREVIEWED_FILE, ShortcutSection.DIFFS,
|
||||||
|
'Mark file as reviewed and go to next unreviewed file');
|
||||||
|
|
||||||
_describe(Shortcut.NEXT_FILE, ShortcutSection.NAVIGATION, 'Select next file');
|
_describe(Shortcut.NEXT_FILE, ShortcutSection.NAVIGATION, 'Select next file');
|
||||||
_describe(Shortcut.PREV_FILE, ShortcutSection.NAVIGATION,
|
_describe(Shortcut.PREV_FILE, ShortcutSection.NAVIGATION,
|
||||||
|
|||||||
@@ -169,6 +169,10 @@
|
|||||||
type: Object,
|
type: Object,
|
||||||
computed: '_getRevisionInfo(_change)',
|
computed: '_getRevisionInfo(_change)',
|
||||||
},
|
},
|
||||||
|
_reviewedFiles: {
|
||||||
|
type: Object,
|
||||||
|
value: () => new Set(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
behaviors: [
|
behaviors: [
|
||||||
@@ -215,6 +219,7 @@
|
|||||||
[this.Shortcut.TOGGLE_DIFF_MODE]: '_handleToggleDiffMode',
|
[this.Shortcut.TOGGLE_DIFF_MODE]: '_handleToggleDiffMode',
|
||||||
[this.Shortcut.TOGGLE_FILE_REVIEWED]: '_handleToggleFileReviewed',
|
[this.Shortcut.TOGGLE_FILE_REVIEWED]: '_handleToggleFileReviewed',
|
||||||
[this.Shortcut.EXPAND_ALL_DIFF_CONTEXT]: '_handleExpandAllDiffContext',
|
[this.Shortcut.EXPAND_ALL_DIFF_CONTEXT]: '_handleExpandAllDiffContext',
|
||||||
|
[this.Shortcut.NEXT_UNREVIEWED_FILE]: '_handleNextUnreviewedFile',
|
||||||
|
|
||||||
// Final two are actually handled by gr-diff-comment-thread.
|
// Final two are actually handled by gr-diff-comment-thread.
|
||||||
[this.Shortcut.EXPAND_ALL_COMMENT_THREADS]: null,
|
[this.Shortcut.EXPAND_ALL_COMMENT_THREADS]: null,
|
||||||
@@ -564,10 +569,18 @@
|
|||||||
return {path: fileList[idx]};
|
return {path: fileList[idx]};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getReviewedFiles(changeNum, patchNum) {
|
||||||
|
return this.$.restAPI.getReviewedFiles(changeNum, patchNum)
|
||||||
|
.then(files => {
|
||||||
|
this._reviewedFiles = new Set(files);
|
||||||
|
return this._reviewedFiles;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_getReviewedStatus(editMode, changeNum, patchNum, path) {
|
_getReviewedStatus(editMode, changeNum, patchNum, path) {
|
||||||
if (editMode) { return Promise.resolve(false); }
|
if (editMode) { return Promise.resolve(false); }
|
||||||
return this.$.restAPI.getReviewedFiles(changeNum, patchNum)
|
return this._getReviewedFiles(changeNum, patchNum)
|
||||||
.then(files => files.includes(path));
|
.then(files => files.has(path));
|
||||||
},
|
},
|
||||||
|
|
||||||
_paramsChanged(value) {
|
_paramsChanged(value) {
|
||||||
@@ -1025,5 +1038,15 @@
|
|||||||
_computeDiffPrefsDisabled(disableDiffPrefs, loggedIn) {
|
_computeDiffPrefsDisabled(disableDiffPrefs, loggedIn) {
|
||||||
return disableDiffPrefs || !loggedIn;
|
return disableDiffPrefs || !loggedIn;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_handleNextUnreviewedFile(e) {
|
||||||
|
this._setReviewed(true);
|
||||||
|
// Ensure that the currently viewed file always appears in unreviewedFiles
|
||||||
|
// so we resolve the right "next" file.
|
||||||
|
const unreviewedFiles = this._fileList
|
||||||
|
.filter(file =>
|
||||||
|
(file === this._path || !this._reviewedFiles.has(file)));
|
||||||
|
this._navToFile(this._path, unreviewedFiles, 1);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ limitations under the License.
|
|||||||
kb.bindShortcut(kb.Shortcut.EXPAND_ALL_DIFF_CONTEXT, 'shift+x');
|
kb.bindShortcut(kb.Shortcut.EXPAND_ALL_DIFF_CONTEXT, 'shift+x');
|
||||||
kb.bindShortcut(kb.Shortcut.EXPAND_ALL_COMMENT_THREADS, 'e');
|
kb.bindShortcut(kb.Shortcut.EXPAND_ALL_COMMENT_THREADS, 'e');
|
||||||
kb.bindShortcut(kb.Shortcut.COLLAPSE_ALL_COMMENT_THREADS, 'shift+e');
|
kb.bindShortcut(kb.Shortcut.COLLAPSE_ALL_COMMENT_THREADS, 'shift+e');
|
||||||
|
kb.bindShortcut(kb.Shortcut.NEXT_UNREVIEWED_FILE, 'shift+m');
|
||||||
|
|
||||||
let element;
|
let element;
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -1127,5 +1128,22 @@ limitations under the License.
|
|||||||
assert.isTrue(setStub.calledOnce);
|
assert.isTrue(setStub.calledOnce);
|
||||||
assert.isTrue(setStub.calledWith(101, 'test-project'));
|
assert.isTrue(setStub.calledWith(101, 'test-project'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('shift+m navigates to next unreviewed file', () => {
|
||||||
|
element._fileList = ['file1', 'file2', 'file3'];
|
||||||
|
element._reviewedFiles = new Set(['file1', 'file2']);
|
||||||
|
element._path = 'file1';
|
||||||
|
const reviewedStub = sandbox.stub(element, '_setReviewed');
|
||||||
|
const navStub = sandbox.stub(element, '_navToFile');
|
||||||
|
MockInteractions.pressAndReleaseKeyOn(element, 77, 'shift', 'm');
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
|
assert.isTrue(reviewedStub.lastCall.args[0]);
|
||||||
|
assert.deepEqual(navStub.lastCall.args, [
|
||||||
|
'file1',
|
||||||
|
['file1', 'file3'],
|
||||||
|
1,
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -274,6 +274,8 @@
|
|||||||
this.Shortcut.OPEN_FILE, 'o', 'enter');
|
this.Shortcut.OPEN_FILE, 'o', 'enter');
|
||||||
this.bindShortcut(
|
this.bindShortcut(
|
||||||
this.Shortcut.TOGGLE_FILE_REVIEWED, 'r');
|
this.Shortcut.TOGGLE_FILE_REVIEWED, 'r');
|
||||||
|
this.bindShortcut(
|
||||||
|
this.Shortcut.NEXT_UNREVIEWED_FILE, 'shift+m');
|
||||||
this.bindShortcut(
|
this.bindShortcut(
|
||||||
this.Shortcut.TOGGLE_ALL_INLINE_DIFFS, 'shift+i:keyup');
|
this.Shortcut.TOGGLE_ALL_INLINE_DIFFS, 'shift+i:keyup');
|
||||||
this.bindShortcut(
|
this.bindShortcut(
|
||||||
|
|||||||
Reference in New Issue
Block a user