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>2019-11-11 03:06:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 03:06:26 +0300
commit991a295378736c60d419c794f0accbf0336987fc (patch)
treeaaee5152256c8d4eb40a1583521bcf320082bb49 /app/serializers/diff_file_entity.rb
parent71d998ca0de672d5accdf209b4b5e3f360ea5267 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers/diff_file_entity.rb')
-rw-r--r--app/serializers/diff_file_entity.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb
index 2a5121a2266..af7d1172f17 100644
--- a/app/serializers/diff_file_entity.rb
+++ b/app/serializers/diff_file_entity.rb
@@ -53,7 +53,7 @@ class DiffFileEntity < DiffFileBaseEntity
end
# Used for inline diffs
- expose :highlighted_diff_lines, using: DiffLineEntity, if: -> (diff_file, _) { diff_file.text? } do |diff_file|
+ expose :highlighted_diff_lines, using: DiffLineEntity, if: -> (diff_file, options) { inline_diff_view?(options) && diff_file.text? } do |diff_file|
diff_file.diff_lines_for_serializer
end
@@ -62,5 +62,21 @@ class DiffFileEntity < DiffFileBaseEntity
end
# Used for parallel diffs
- expose :parallel_diff_lines, using: DiffLineParallelEntity, if: -> (diff_file, _) { diff_file.text? }
+ expose :parallel_diff_lines, using: DiffLineParallelEntity, if: -> (diff_file, options) { parallel_diff_view?(options) && diff_file.text? }
+
+ private
+
+ def parallel_diff_view?(options)
+ return true unless Feature.enabled?(:single_mr_diff_view)
+
+ # If we're not rendering inline, we must be rendering parallel
+ !inline_diff_view?(options)
+ end
+
+ def inline_diff_view?(options)
+ return true unless Feature.enabled?(:single_mr_diff_view)
+
+ # If nothing is present, inline will be the default.
+ options.fetch(:diff_view, :inline).to_sym == :inline
+ end
end