summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/components/diff_content.vue
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/diffs/components/diff_content.vue
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
downloadgitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs/components/diff_content.vue')
-rw-r--r--app/assets/javascripts/diffs/components/diff_content.vue35
1 files changed, 30 insertions, 5 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_content.vue b/app/assets/javascripts/diffs/components/diff_content.vue
index e68260b3e62..401064fb18f 100644
--- a/app/assets/javascripts/diffs/components/diff_content.vue
+++ b/app/assets/javascripts/diffs/components/diff_content.vue
@@ -10,6 +10,7 @@ import NoPreviewViewer from '~/vue_shared/components/diff_viewer/viewers/no_prev
import DiffFileDrafts from '~/batch_comments/components/diff_file_drafts.vue';
import InlineDiffView from './inline_diff_view.vue';
import ParallelDiffView from './parallel_diff_view.vue';
+import DiffView from './diff_view.vue';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import NoteForm from '../../notes/components/note_form.vue';
import ImageDiffOverlay from './image_diff_overlay.vue';
@@ -18,12 +19,14 @@ import eventHub from '../../notes/event_hub';
import { IMAGE_DIFF_POSITION_TYPE } from '../constants';
import { getDiffMode } from '../store/utils';
import { diffViewerModes } from '~/ide/constants';
+import { mapInline, mapParallel } from './diff_row_utils';
export default {
components: {
GlLoadingIcon,
InlineDiffView,
ParallelDiffView,
+ DiffView,
DiffViewer,
NoteForm,
DiffDiscussions,
@@ -83,6 +86,19 @@ export default {
author() {
return this.getUserData;
},
+ mappedLines() {
+ if (this.glFeatures.unifiedDiffLines && this.glFeatures.unifiedDiffComponents) {
+ return this.diffLines(this.diffFile, true).map(mapParallel(this)) || [];
+ }
+
+ // TODO: Everything below this line can be deleted when unifiedDiffComponents FF is removed
+ if (this.isInlineView) {
+ return this.diffFile.highlighted_diff_lines.map(mapInline(this));
+ }
+ return this.glFeatures.unifiedDiffLines
+ ? this.diffLines(this.diffFile).map(mapParallel(this))
+ : this.diffFile.parallel_diff_lines.map(mapParallel(this)) || [];
+ },
},
updated() {
this.$nextTick(() => {
@@ -113,19 +129,28 @@ export default {
<template>
<div class="diff-content">
<div class="diff-viewer">
- <template v-if="isTextFile">
+ <template
+ v-if="isTextFile && glFeatures.unifiedDiffLines && glFeatures.unifiedDiffComponents"
+ >
+ <diff-view
+ :diff-file="diffFile"
+ :diff-lines="mappedLines"
+ :help-page-path="helpPagePath"
+ :inline="isInlineView"
+ />
+ <gl-loading-icon v-if="diffFile.renderingLines" size="md" class="mt-3" />
+ </template>
+ <template v-else-if="isTextFile">
<inline-diff-view
v-if="isInlineView"
:diff-file="diffFile"
- :diff-lines="diffFile.highlighted_diff_lines"
+ :diff-lines="mappedLines"
:help-page-path="helpPagePath"
/>
<parallel-diff-view
v-else-if="isParallelView"
:diff-file="diffFile"
- :diff-lines="
- glFeatures.unifiedDiffLines ? diffLines(diffFile) : diffFile.parallel_diff_lines || []
- "
+ :diff-lines="mappedLines"
:help-page-path="helpPagePath"
/>
<gl-loading-icon v-if="diffFile.renderingLines" size="md" class="mt-3" />