Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-12 15:09:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-12 15:09:39 +0300
commit4a31b8786892820e8029844c34fd5296c52c37c0 (patch)
treeef04909e73e0ffe6e4c2b0d40408cada88aa5afc /app/assets/javascripts/diffs
parent1fdf76252e8fdf1a30826fe3f32a6216e50c563c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/diffs')
-rw-r--r--app/assets/javascripts/diffs/components/diff_line_note_form.vue28
1 files changed, 21 insertions, 7 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_line_note_form.vue b/app/assets/javascripts/diffs/components/diff_line_note_form.vue
index 700e6302102..55f5a736cdf 100644
--- a/app/assets/javascripts/diffs/components/diff_line_note_form.vue
+++ b/app/assets/javascripts/diffs/components/diff_line_note_form.vue
@@ -7,7 +7,7 @@ import noteForm from '../../notes/components/note_form.vue';
import MultilineCommentForm from '../../notes/components/multiline_comment_form.vue';
import autosave from '../../notes/mixins/autosave';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
-import { DIFF_NOTE_TYPE } from '../constants';
+import { DIFF_NOTE_TYPE, PARALLEL_DIFF_VIEW_TYPE } from '../constants';
import {
commentLineOptions,
formatLineRange,
@@ -60,7 +60,7 @@ export default {
diffViewType: state => state.diffs.diffViewType,
}),
...mapState('diffs', ['showSuggestPopover']),
- ...mapGetters('diffs', ['getDiffFileByHash']),
+ ...mapGetters('diffs', ['getDiffFileByHash', 'diffLines']),
...mapGetters([
'isLoggedIn',
'noteableType',
@@ -88,16 +88,30 @@ export default {
commentLineOptions() {
const combineSides = (acc, { left, right }) => {
// ignore null values match lines
- if (left && left.type !== 'match') acc.push(left);
+ if (left) acc.push(left);
// if the line_codes are identically, return to avoid duplicates
- if (left?.line_code === right?.line_code) return acc;
+ if (
+ left?.line_code === right?.line_code ||
+ left?.type === 'old-nonewline' ||
+ right?.type === 'new-nonewline'
+ ) {
+ return acc;
+ }
if (right && right.type !== 'match') acc.push(right);
return acc;
};
+ const getDiffLines = () => {
+ if (this.diffViewType === PARALLEL_DIFF_VIEW_TYPE) {
+ return (this.glFeatures.unifiedDiffLines
+ ? this.diffLines(this.diffFile)
+ : this.diffFile.parallel_diff_lines
+ ).reduce(combineSides, []);
+ }
+
+ return this.diffFile.highlighted_diff_lines;
+ };
const side = this.line.type === 'new' ? 'right' : 'left';
- const lines = this.diffFile.highlighted_diff_lines.length
- ? this.diffFile.highlighted_diff_lines
- : this.diffFile.parallel_diff_lines.reduce(combineSides, []);
+ const lines = getDiffLines();
return commentLineOptions(lines, this.line, this.line.line_code, side);
},
},