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/diff_file.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/diff_file.js')
-rw-r--r-- | app/assets/javascripts/diffs/diff_file.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/assets/javascripts/diffs/diff_file.js b/app/assets/javascripts/diffs/diff_file.js index 933197a2c7f..a14a30b41a9 100644 --- a/app/assets/javascripts/diffs/diff_file.js +++ b/app/assets/javascripts/diffs/diff_file.js @@ -1,4 +1,9 @@ -import { DIFF_FILE_SYMLINK_MODE, DIFF_FILE_DELETED_MODE } from './constants'; +import { + DIFF_FILE_SYMLINK_MODE, + DIFF_FILE_DELETED_MODE, + DIFF_FILE_MANUAL_COLLAPSE, + DIFF_FILE_AUTOMATIC_COLLAPSE, +} from './constants'; function fileSymlinkInformation(file, fileList) { const duplicates = fileList.filter(iteratedFile => iteratedFile.file_hash === file.file_hash); @@ -23,6 +28,7 @@ function collapsed(file) { return { automaticallyCollapsed: viewer.automaticallyCollapsed || viewer.collapsed || false, + manuallyCollapsed: null, }; } @@ -37,3 +43,19 @@ export function prepareRawDiffFile({ file, allFiles }) { return file; } + +export function collapsedType(file) { + const isManual = typeof file.viewer?.manuallyCollapsed === 'boolean'; + + return isManual ? DIFF_FILE_MANUAL_COLLAPSE : DIFF_FILE_AUTOMATIC_COLLAPSE; +} + +export function isCollapsed(file) { + const type = collapsedType(file); + const collapsedStates = { + [DIFF_FILE_AUTOMATIC_COLLAPSE]: file.viewer?.automaticallyCollapsed || false, + [DIFF_FILE_MANUAL_COLLAPSE]: file.viewer?.manuallyCollapsed, + }; + + return collapsedStates[type]; +} |