diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
commit | 3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch) | |
tree | 3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /app/assets/javascripts/diffs/store/mutations.js | |
parent | 9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs/store/mutations.js')
-rw-r--r-- | app/assets/javascripts/diffs/store/mutations.js | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 5e7fe8b5cd8..2786e971f4b 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -5,6 +5,7 @@ import { DIFF_FILE_AUTOMATIC_COLLAPSE, INLINE_DIFF_LINES_KEY, EXPANDED_LINE_TYPE, + FILE_DIFF_POSITION_TYPE, } from '../constants'; import * as types from './mutation_types'; import { @@ -168,6 +169,7 @@ export default { const { latestDiff } = state; const originalStartLineCode = discussion.original_position?.line_range?.start?.line_code; + const positionType = discussion.position?.position_type; const discussionLineCodes = [ discussion.line_code, originalStartLineCode, @@ -212,16 +214,7 @@ export default { state.diffFiles.forEach((file) => { if (file.file_hash === fileHash) { - if (file[INLINE_DIFF_LINES_KEY].length) { - file[INLINE_DIFF_LINES_KEY].forEach((line) => { - Object.assign( - line, - setDiscussionsExpanded(lineCheck(line) ? mapDiscussions(line) : line), - ); - }); - } - - if (!file[INLINE_DIFF_LINES_KEY].length) { + if (positionType === FILE_DIFF_POSITION_TYPE) { const newDiscussions = (file.discussions || []) .filter((d) => d.id !== discussion.id) .concat(discussion); @@ -229,6 +222,25 @@ export default { Object.assign(file, { discussions: newDiscussions, }); + } else { + if (file[INLINE_DIFF_LINES_KEY].length) { + file[INLINE_DIFF_LINES_KEY].forEach((line) => { + Object.assign( + line, + setDiscussionsExpanded(lineCheck(line) ? mapDiscussions(line) : line), + ); + }); + } + + if (!file[INLINE_DIFF_LINES_KEY].length) { + const newDiscussions = (file.discussions || []) + .filter((d) => d.id !== discussion.id) + .concat(discussion); + + Object.assign(file, { + discussions: newDiscussions, + }); + } } } }); @@ -378,4 +390,14 @@ export default { [types.DISABLE_VIRTUAL_SCROLLING](state) { state.disableVirtualScroller = true; }, + [types.TOGGLE_FILE_COMMENT_FORM](state, filePath) { + const file = findDiffFile(state.diffFiles, filePath, 'file_path'); + + file.hasCommentForm = !file.hasCommentForm; + }, + [types.ADD_DRAFT_TO_FILE](state, { filePath, draft }) { + const file = findDiffFile(state.diffFiles, filePath, 'file_path'); + + file?.drafts.push(draft); + }, }; |