Commit 21d2ebff authored by Douwe Maan's avatar Douwe Maan

Render blob viewer error

parent 44cf2470
......@@ -217,4 +217,13 @@ module BlobHelper
def open_raw_file_button(path)
link_to icon('file-code-o'), path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: 'Open raw', data: { container: 'body' }
end
def blob_render_error_reason(viewer, error)
case error
when :too_large
"it is larger than #{number_to_human_size(viewer.relevant_max_size)}"
when :server_side_but_stored_in_lfs
"it is stored in LFS"
end
end
end
- reason = blob_render_error_reason(viewer, error)
- options = []
- if error == :too_large && viewer.can_override_max_size?
- options << link_to('load it anyway', url_for(params.merge(viewer: viewer.type, override_max_size: true, format: nil)))
- if viewer.rich? && viewer.blob.rendered_as_text?(override_max_size: true)
- options << link_to('view the source', '#', class: 'js-blob-viewer-switcher', data: { viewer: 'simple' })
- options << link_to('download it', blob_raw_url, target: '_blank', rel: 'noopener noreferrer')
.file-content.code
.nothing-here-block
The #{viewer.switcher_title} could not be displayed because #{reason}.
You can
= options.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ').html_safe
instead.
.file-content.code
.nothing-here-block
The file could not be displayed as it is too large, you can
#{link_to('view the raw file', namespace_project_raw_path(@project.namespace, @project, @id), target: '_blank', rel: 'noopener noreferrer')}
instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment