diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/diffs/store/mutations.js | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs/store/mutations.js')
-rw-r--r-- | app/assets/javascripts/diffs/store/mutations.js | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 13ecf6a997d..096c4f69439 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -1,6 +1,10 @@ import Vue from 'vue'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; -import { INLINE_DIFF_VIEW_TYPE } from '../constants'; +import { + DIFF_FILE_MANUAL_COLLAPSE, + DIFF_FILE_AUTOMATIC_COLLAPSE, + INLINE_DIFF_VIEW_TYPE, +} from '../constants'; import { findDiffFile, addLineReferences, @@ -16,6 +20,12 @@ function updateDiffFilesInState(state, files) { return Object.assign(state, { diffFiles: files }); } +function renderFile(file) { + Object.assign(file, { + renderIt: true, + }); +} + export default { [types.SET_BASE_CONFIG](state, options) { const { @@ -81,9 +91,7 @@ export default { }, [types.RENDER_FILE](state, file) { - Object.assign(file, { - renderIt: true, - }); + renderFile(file); }, [types.SET_MERGE_REQUEST_DIFFS](state, mergeRequestDiffs) { @@ -168,16 +176,6 @@ export default { Object.assign(selectedFile, { ...newFileData }); }, - [types.EXPAND_ALL_FILES](state) { - state.diffFiles.forEach(file => { - Object.assign(file, { - viewer: Object.assign(file.viewer, { - automaticallyCollapsed: false, - }), - }); - }); - }, - [types.SET_LINE_DISCUSSIONS_FOR_FILE](state, { discussion, diffPositionByLineCode, hash }) { const { latestDiff } = state; @@ -351,11 +349,24 @@ export default { file.isShowingFullFile = true; file.isLoadingFullFile = false; }, - [types.SET_FILE_COLLAPSED](state, { filePath, collapsed }) { + [types.SET_FILE_COLLAPSED]( + state, + { filePath, collapsed, trigger = DIFF_FILE_AUTOMATIC_COLLAPSE }, + ) { const file = state.diffFiles.find(f => f.file_path === filePath); if (file && file.viewer) { - file.viewer.automaticallyCollapsed = collapsed; + if (trigger === DIFF_FILE_MANUAL_COLLAPSE) { + file.viewer.automaticallyCollapsed = false; + file.viewer.manuallyCollapsed = collapsed; + } else if (trigger === DIFF_FILE_AUTOMATIC_COLLAPSE) { + file.viewer.automaticallyCollapsed = collapsed; + file.viewer.manuallyCollapsed = null; + } + } + + if (file && !collapsed) { + renderFile(file); } }, [types.SET_HIDDEN_VIEW_DIFF_FILE_LINES](state, { filePath, lines }) { @@ -367,8 +378,13 @@ export default { }, [types.SET_CURRENT_VIEW_DIFF_FILE_LINES](state, { filePath, lines }) { const file = state.diffFiles.find(f => f.file_path === filePath); - const currentDiffLinesKey = - state.diffViewType === 'inline' ? 'highlighted_diff_lines' : 'parallel_diff_lines'; + let currentDiffLinesKey; + + if (window.gon?.features?.unifiedDiffLines || state.diffViewType === 'inline') { + currentDiffLinesKey = 'highlighted_diff_lines'; + } else { + currentDiffLinesKey = 'parallel_diff_lines'; + } file[currentDiffLinesKey] = lines; }, |