diff options
Diffstat (limited to 'app/assets/javascripts/diffs')
5 files changed, 20 insertions, 2 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index 8babc05f1ce..e09bf1f8005 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -58,6 +58,9 @@ export default { hasDiff() { return hasDiff(this.file); }, + isActive() { + return this.currentDiffFileId === this.file.file_hash; + }, isFileTooLarge() { return this.file.viewer.error === diffViewerErrors.too_large; }, @@ -143,7 +146,7 @@ export default { <div :id="file.file_hash" :class="{ - 'is-active': currentDiffFileId === file.file_hash, + 'is-active': isActive, }" class="diff-file file-holder" > @@ -153,6 +156,7 @@ export default { :collapsible="true" :expanded="!isCollapsed" :add-merge-request-buttons="true" + :is-active="isActive" class="js-file-title file-title" @toggleFile="handleToggle" @showForkMessage="showForkMessage" diff --git a/app/assets/javascripts/diffs/components/diff_file_header.vue b/app/assets/javascripts/diffs/components/diff_file_header.vue index d4270960f57..bad82c84601 100644 --- a/app/assets/javascripts/diffs/components/diff_file_header.vue +++ b/app/assets/javascripts/diffs/components/diff_file_header.vue @@ -55,6 +55,11 @@ export default { type: Boolean, required: true, }, + isActive: { + type: Boolean, + required: false, + default: false, + }, }, computed: { ...mapGetters('diffs', ['diffHasExpandedDiscussions', 'diffHasDiscussions']), @@ -158,6 +163,9 @@ export default { <div ref="header" class="js-file-title file-title file-title-flex-parent" + :class="{ + 'is-active': isActive, + }" @click.self="handleToggleFile" > <div class="file-header-content"> diff --git a/app/assets/javascripts/diffs/components/tree_list.vue b/app/assets/javascripts/diffs/components/tree_list.vue index eca9091f92f..fcf87807e75 100644 --- a/app/assets/javascripts/diffs/components/tree_list.vue +++ b/app/assets/javascripts/diffs/components/tree_list.vue @@ -26,7 +26,7 @@ export default { }; }, computed: { - ...mapState('diffs', ['tree', 'renderTreeList']), + ...mapState('diffs', ['tree', 'renderTreeList', 'currentDiffFileId', 'viewedDiffFileIds']), ...mapGetters('diffs', ['allBlobs']), filteredTreeList() { const search = this.search.toLowerCase().trim(); @@ -96,6 +96,8 @@ export default { :level="0" :hide-file-stats="hideFileStats" :file-row-component="$options.DiffFileRow" + :active-file="currentDiffFileId" + :viewed-files="viewedDiffFileIds" @toggleTreeOpen="toggleTreeOpen" @clickFile="scrollToFile" /> diff --git a/app/assets/javascripts/diffs/store/modules/diff_state.js b/app/assets/javascripts/diffs/store/modules/diff_state.js index 81f1506260c..f1bd9d8981d 100644 --- a/app/assets/javascripts/diffs/store/modules/diff_state.js +++ b/app/assets/javascripts/diffs/store/modules/diff_state.js @@ -26,6 +26,7 @@ export default () => ({ showTreeList: true, currentDiffFileId: '', projectPath: '', + viewedDiffFileIds: [], commentForms: [], highlightedRow: null, renderTreeList: true, diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index bb4c80b5759..6438dad4f7f 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -284,6 +284,9 @@ export default { }, [types.UPDATE_CURRENT_DIFF_FILE_ID](state, fileId) { state.currentDiffFileId = fileId; + if (!state.viewedDiffFileIds.includes(fileId)) { + state.viewedDiffFileIds = [fileId, ...state.viewedDiffFileIds]; + } }, [types.OPEN_DIFF_FILE_COMMENT_FORM](state, formData) { state.commentForms.push({ |