diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-10-06 01:36:20 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-10-06 01:36:20 +0300 |
commit | caf10464c0e78817c91ff01e3be5f2f9472aba19 (patch) | |
tree | ba7e070f9266532fa9eefacc4712cf8690e30369 /app | |
parent | 1bd08177761a6599d2ebfdfb02bcadee574e9c44 (diff) |
Fix LFS uploaded images not being rendered
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_content.vue | 2 | ||||
-rw-r--r-- | app/serializers/diff_file_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/diff_viewer_entity.rb | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_content.vue b/app/assets/javascripts/diffs/components/diff_content.vue index 02d5be1821b..fb5556e3cd7 100644 --- a/app/assets/javascripts/diffs/components/diff_content.vue +++ b/app/assets/javascripts/diffs/components/diff_content.vue @@ -28,7 +28,7 @@ export default { return diffModes[diffModeKey] || diffModes.replaced; }, isTextFile() { - return this.diffFile.text; + return this.diffFile.viewer.name === 'text'; }, }, }; diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb index c193ed10fef..63ea8e8f95f 100644 --- a/app/serializers/diff_file_entity.rb +++ b/app/serializers/diff_file_entity.rb @@ -116,6 +116,10 @@ class DiffFileEntity < Grape::Entity project_blob_path(project, tree_join(diff_file.content_sha, diff_file.new_path)) end + expose :viewer, using: DiffViewerEntity do |diff_file| + diff_file.rich_viewer || diff_file.simple_viewer + end + expose :replaced_view_path, if: -> (_, options) { options[:merge_request] } do |diff_file| image_diff = diff_file.rich_viewer && diff_file.rich_viewer.partial_name == 'image' image_replaced = diff_file.old_content_sha && diff_file.old_content_sha != diff_file.content_sha diff --git a/app/serializers/diff_viewer_entity.rb b/app/serializers/diff_viewer_entity.rb new file mode 100644 index 00000000000..27fba03cb3f --- /dev/null +++ b/app/serializers/diff_viewer_entity.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class DiffViewerEntity < Grape::Entity + # Partial name refers directly to a Rails feature, let's avoid + # using this on the frontend. + expose :partial_name, as: :name +end |