diff --git a/polygerrit-ui/app/behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js b/polygerrit-ui/app/behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js index 09e3b7264e..ca31ee80b0 100644 --- a/polygerrit-ui/app/behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js +++ b/polygerrit-ui/app/behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.js @@ -171,6 +171,7 @@ const Shortcut = { TOGGLE_FILE_REVIEWED: 'TOGGLE_FILE_REVIEWED', TOGGLE_ALL_INLINE_DIFFS: 'TOGGLE_ALL_INLINE_DIFFS', TOGGLE_INLINE_DIFF: 'TOGGLE_INLINE_DIFF', + TOGGLE_HIDE_ALL_COMMENT_THREADS: 'TOGGLE_HIDE_ALL_COMMENT_THREADS', OPEN_FIRST_FILE: 'OPEN_FIRST_FILE', OPEN_LAST_FILE: 'OPEN_LAST_FILE', @@ -251,6 +252,8 @@ _describe(Shortcut.EXPAND_ALL_COMMENT_THREADS, ShortcutSection.DIFFS, 'Expand all comment threads'); _describe(Shortcut.COLLAPSE_ALL_COMMENT_THREADS, ShortcutSection.DIFFS, '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.RIGHT_PANE, ShortcutSection.DIFFS, 'Select right pane'); _describe(Shortcut.TOGGLE_LEFT_PANE, ShortcutSection.DIFFS, @@ -290,6 +293,8 @@ _describe(Shortcut.OPEN_FILE, ShortcutSection.FILE_LIST, 'Go to selected file'); _describe(Shortcut.TOGGLE_ALL_INLINE_DIFFS, ShortcutSection.FILE_LIST, '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, 'Show/hide selected inline diff'); 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 5e9825a2de..a0d4d42c0a 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 @@ -275,6 +275,8 @@ class GrFileList extends mixinBehaviors( [ [this.Shortcut.RIGHT_PANE]: '_handleRightPane', [this.Shortcut.TOGGLE_INLINE_DIFF]: '_handleToggleInlineDiff', [this.Shortcut.TOGGLE_ALL_INLINE_DIFFS]: '_handleToggleAllInlineDiffs', + [this.Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS]: + '_handleToggleHideAllCommentThreads', [this.Shortcut.CURSOR_NEXT_FILE]: '_handleCursorNext', [this.Shortcut.CURSOR_PREV_FILE]: '_handleCursorPrev', [this.Shortcut.NEXT_LINE]: '_handleCursorNext', @@ -808,6 +810,15 @@ class GrFileList extends mixinBehaviors( [ this._toggleInlineDiffs(); } + _handleToggleHideAllCommentThreads(e) { + if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) { + return; + } + + e.preventDefault(); + this.toggleClass('hideComments'); + } + _handleCursorNext(e) { if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) { return; diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js index 4ac4bb1416..df7cb00baf 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.js @@ -310,6 +310,9 @@ export const htmlTemplate = html` display: none; } } + :host(.hideComments) { + --gr-comment-thread-display: none; + }
{ kb.bindShortcut(kb.Shortcut.TOGGLE_FILE_REVIEWED, 'r'); kb.bindShortcut(kb.Shortcut.EXPAND_ALL_DIFF_CONTEXT, 'shift+x'); 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.NEXT_UNREVIEWED_FILE, 'shift+m'); kb.bindShortcut(kb.Shortcut.TOGGLE_BLAME, 'b'); diff --git a/polygerrit-ui/app/elements/gr-app-element.js b/polygerrit-ui/app/elements/gr-app-element.js index 10ca963cde..ecb40a5c1a 100644 --- a/polygerrit-ui/app/elements/gr-app-element.js +++ b/polygerrit-ui/app/elements/gr-app-element.js @@ -350,6 +350,8 @@ class GrAppElement extends mixinBehaviors( [ this.Shortcut.TOGGLE_INLINE_DIFF, 'i:keyup'); this.bindShortcut( this.Shortcut.TOGGLE_BLAME, 'b'); + this.bindShortcut( + this.Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS, 'h'); this.bindShortcut( this.Shortcut.OPEN_FIRST_FILE, ']'); diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.js b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.js index 7c5c5c4c97..2bb5b66ea7 100644 --- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.js +++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.js @@ -37,7 +37,7 @@ export const htmlTemplate = html` #container { background-color: var(--comment-background-color); color: var(--comment-text-color); - display: block; + display: var(--gr-comment-thread-display, block); margin: 0 var(--spacing-s) var(--spacing-s); white-space: normal; box-shadow: var(--elevation-level-2);