Add keyboard shortcut to toggle showing comments in diff view
Add shortcut "h" to allow users to hide/show all comments in the diff view. Allows users to focus completely on the diff Change-Id: Ia7638bd480d657eee3971f6aa6358675f40deeae
This commit is contained in:
@@ -171,6 +171,7 @@ const Shortcut = {
|
|||||||
TOGGLE_FILE_REVIEWED: 'TOGGLE_FILE_REVIEWED',
|
TOGGLE_FILE_REVIEWED: 'TOGGLE_FILE_REVIEWED',
|
||||||
TOGGLE_ALL_INLINE_DIFFS: 'TOGGLE_ALL_INLINE_DIFFS',
|
TOGGLE_ALL_INLINE_DIFFS: 'TOGGLE_ALL_INLINE_DIFFS',
|
||||||
TOGGLE_INLINE_DIFF: 'TOGGLE_INLINE_DIFF',
|
TOGGLE_INLINE_DIFF: 'TOGGLE_INLINE_DIFF',
|
||||||
|
TOGGLE_HIDE_ALL_COMMENT_THREADS: 'TOGGLE_HIDE_ALL_COMMENT_THREADS',
|
||||||
|
|
||||||
OPEN_FIRST_FILE: 'OPEN_FIRST_FILE',
|
OPEN_FIRST_FILE: 'OPEN_FIRST_FILE',
|
||||||
OPEN_LAST_FILE: 'OPEN_LAST_FILE',
|
OPEN_LAST_FILE: 'OPEN_LAST_FILE',
|
||||||
@@ -251,6 +252,8 @@ _describe(Shortcut.EXPAND_ALL_COMMENT_THREADS, ShortcutSection.DIFFS,
|
|||||||
'Expand all comment threads');
|
'Expand all comment threads');
|
||||||
_describe(Shortcut.COLLAPSE_ALL_COMMENT_THREADS, ShortcutSection.DIFFS,
|
_describe(Shortcut.COLLAPSE_ALL_COMMENT_THREADS, ShortcutSection.DIFFS,
|
||||||
'Collapse all comment threads');
|
'Collapse all comment threads');
|
||||||
|
_describe(Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS, ShortcutSection.DIFFS,
|
||||||
|
'Hide/Display all comment threads');
|
||||||
_describe(Shortcut.LEFT_PANE, ShortcutSection.DIFFS, 'Select left pane');
|
_describe(Shortcut.LEFT_PANE, ShortcutSection.DIFFS, 'Select left pane');
|
||||||
_describe(Shortcut.RIGHT_PANE, ShortcutSection.DIFFS, 'Select right pane');
|
_describe(Shortcut.RIGHT_PANE, ShortcutSection.DIFFS, 'Select right pane');
|
||||||
_describe(Shortcut.TOGGLE_LEFT_PANE, ShortcutSection.DIFFS,
|
_describe(Shortcut.TOGGLE_LEFT_PANE, ShortcutSection.DIFFS,
|
||||||
@@ -290,6 +293,8 @@ _describe(Shortcut.OPEN_FILE, ShortcutSection.FILE_LIST,
|
|||||||
'Go to selected file');
|
'Go to selected file');
|
||||||
_describe(Shortcut.TOGGLE_ALL_INLINE_DIFFS, ShortcutSection.FILE_LIST,
|
_describe(Shortcut.TOGGLE_ALL_INLINE_DIFFS, ShortcutSection.FILE_LIST,
|
||||||
'Show/hide all inline diffs');
|
'Show/hide all inline diffs');
|
||||||
|
_describe(Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS, ShortcutSection.FILE_LIST,
|
||||||
|
'Hide/Display all comment threads');
|
||||||
_describe(Shortcut.TOGGLE_INLINE_DIFF, ShortcutSection.FILE_LIST,
|
_describe(Shortcut.TOGGLE_INLINE_DIFF, ShortcutSection.FILE_LIST,
|
||||||
'Show/hide selected inline diff');
|
'Show/hide selected inline diff');
|
||||||
|
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ class GrFileList extends mixinBehaviors( [
|
|||||||
[this.Shortcut.RIGHT_PANE]: '_handleRightPane',
|
[this.Shortcut.RIGHT_PANE]: '_handleRightPane',
|
||||||
[this.Shortcut.TOGGLE_INLINE_DIFF]: '_handleToggleInlineDiff',
|
[this.Shortcut.TOGGLE_INLINE_DIFF]: '_handleToggleInlineDiff',
|
||||||
[this.Shortcut.TOGGLE_ALL_INLINE_DIFFS]: '_handleToggleAllInlineDiffs',
|
[this.Shortcut.TOGGLE_ALL_INLINE_DIFFS]: '_handleToggleAllInlineDiffs',
|
||||||
|
[this.Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS]:
|
||||||
|
'_handleToggleHideAllCommentThreads',
|
||||||
[this.Shortcut.CURSOR_NEXT_FILE]: '_handleCursorNext',
|
[this.Shortcut.CURSOR_NEXT_FILE]: '_handleCursorNext',
|
||||||
[this.Shortcut.CURSOR_PREV_FILE]: '_handleCursorPrev',
|
[this.Shortcut.CURSOR_PREV_FILE]: '_handleCursorPrev',
|
||||||
[this.Shortcut.NEXT_LINE]: '_handleCursorNext',
|
[this.Shortcut.NEXT_LINE]: '_handleCursorNext',
|
||||||
@@ -808,6 +810,15 @@ class GrFileList extends mixinBehaviors( [
|
|||||||
this._toggleInlineDiffs();
|
this._toggleInlineDiffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleToggleHideAllCommentThreads(e) {
|
||||||
|
if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
this.toggleClass('hideComments');
|
||||||
|
}
|
||||||
|
|
||||||
_handleCursorNext(e) {
|
_handleCursorNext(e) {
|
||||||
if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
|
if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -310,6 +310,9 @@ export const htmlTemplate = html`
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:host(.hideComments) {
|
||||||
|
--gr-comment-thread-display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<div
|
<div
|
||||||
id="container"
|
id="container"
|
||||||
|
|||||||
@@ -298,6 +298,8 @@ class GrDiffView extends mixinBehaviors( [
|
|||||||
[this.Shortcut.EXPAND_ALL_DIFF_CONTEXT]: '_handleExpandAllDiffContext',
|
[this.Shortcut.EXPAND_ALL_DIFF_CONTEXT]: '_handleExpandAllDiffContext',
|
||||||
[this.Shortcut.NEXT_UNREVIEWED_FILE]: '_handleNextUnreviewedFile',
|
[this.Shortcut.NEXT_UNREVIEWED_FILE]: '_handleNextUnreviewedFile',
|
||||||
[this.Shortcut.TOGGLE_BLAME]: '_handleToggleBlame',
|
[this.Shortcut.TOGGLE_BLAME]: '_handleToggleBlame',
|
||||||
|
[this.Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS]:
|
||||||
|
'_handleToggleHideAllCommentThreads',
|
||||||
|
|
||||||
// Final two are actually handled by gr-comment-thread.
|
// Final two are actually handled by gr-comment-thread.
|
||||||
[this.Shortcut.EXPAND_ALL_COMMENT_THREADS]: null,
|
[this.Shortcut.EXPAND_ALL_COMMENT_THREADS]: null,
|
||||||
@@ -740,6 +742,7 @@ class GrDiffView extends mixinBehaviors( [
|
|||||||
this._initCursor(this.params);
|
this._initCursor(this.params);
|
||||||
|
|
||||||
this._changeNum = value.changeNum;
|
this._changeNum = value.changeNum;
|
||||||
|
this.classList.remove('hideComments');
|
||||||
this._path = value.path;
|
this._path = value.path;
|
||||||
this._patchRange = {
|
this._patchRange = {
|
||||||
patchNum: value.patchNum,
|
patchNum: value.patchNum,
|
||||||
@@ -1277,6 +1280,12 @@ class GrDiffView extends mixinBehaviors( [
|
|||||||
this._toggleBlame();
|
this._toggleBlame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleToggleHideAllCommentThreads(e) {
|
||||||
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
||||||
|
this.modifierPressed(e)) { return; }
|
||||||
|
this.toggleClass('hideComments');
|
||||||
|
}
|
||||||
|
|
||||||
_computeBlameLoaderClass(isImageDiff, path) {
|
_computeBlameLoaderClass(isImageDiff, path) {
|
||||||
return !this.isMagicPath(path) && !isImageDiff ? 'show' : '';
|
return !this.isMagicPath(path) && !isImageDiff ? 'show' : '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,6 +196,9 @@ export const htmlTemplate = html`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:host(.hideComments) {
|
||||||
|
--gr-comment-thread-display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<gr-fixed-panel
|
<gr-fixed-panel
|
||||||
class$="[[_computeContainerClass(_editMode)]]"
|
class$="[[_computeContainerClass(_editMode)]]"
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ suite('gr-diff-view tests', () => {
|
|||||||
kb.bindShortcut(kb.Shortcut.TOGGLE_FILE_REVIEWED, 'r');
|
kb.bindShortcut(kb.Shortcut.TOGGLE_FILE_REVIEWED, 'r');
|
||||||
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.TOGGLE_HIDE_ALL_COMMENT_THREADS, 'h');
|
||||||
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');
|
kb.bindShortcut(kb.Shortcut.NEXT_UNREVIEWED_FILE, 'shift+m');
|
||||||
kb.bindShortcut(kb.Shortcut.TOGGLE_BLAME, 'b');
|
kb.bindShortcut(kb.Shortcut.TOGGLE_BLAME, 'b');
|
||||||
|
|||||||
@@ -350,6 +350,8 @@ class GrAppElement extends mixinBehaviors( [
|
|||||||
this.Shortcut.TOGGLE_INLINE_DIFF, 'i:keyup');
|
this.Shortcut.TOGGLE_INLINE_DIFF, 'i:keyup');
|
||||||
this.bindShortcut(
|
this.bindShortcut(
|
||||||
this.Shortcut.TOGGLE_BLAME, 'b');
|
this.Shortcut.TOGGLE_BLAME, 'b');
|
||||||
|
this.bindShortcut(
|
||||||
|
this.Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS, 'h');
|
||||||
|
|
||||||
this.bindShortcut(
|
this.bindShortcut(
|
||||||
this.Shortcut.OPEN_FIRST_FILE, ']');
|
this.Shortcut.OPEN_FIRST_FILE, ']');
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const htmlTemplate = html`
|
|||||||
#container {
|
#container {
|
||||||
background-color: var(--comment-background-color);
|
background-color: var(--comment-background-color);
|
||||||
color: var(--comment-text-color);
|
color: var(--comment-text-color);
|
||||||
display: block;
|
display: var(--gr-comment-thread-display, block);
|
||||||
margin: 0 var(--spacing-s) var(--spacing-s);
|
margin: 0 var(--spacing-s) var(--spacing-s);
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
box-shadow: var(--elevation-level-2);
|
box-shadow: var(--elevation-level-2);
|
||||||
|
|||||||
Reference in New Issue
Block a user