Add single file download in repository

This commit is contained in:
Kia Mei Somabes 2018-07-09 09:55:36 +08:00
parent 0ed8f3490e
commit 50c128944e
3 changed files with 17 additions and 11 deletions

View File

@ -226,18 +226,18 @@ module BlobHelper
def open_raw_blob_button(blob)
return if blob.empty?
if blob.raw_binary? || blob.stored_externally?
icon = sprite_icon('download')
title = 'Download'
else
icon = icon('file-code-o')
title = 'Open raw'
end
icon = icon('file-code-o')
title = 'Open raw'
link_to icon, blob_raw_path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' }
end
def download_button(blob)
return if blob.empty?
icon = sprite_icon('download')
title = 'Download'
link_to icon, blob_raw_path, download: '', class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' }
end
def blob_render_error_reason(viewer)
case viewer.render_error
when :collapsed

View File

@ -7,9 +7,10 @@
.btn-group{ role: "group" }<
= copy_blob_source_button(blob) unless blame
= open_raw_blob_button(blob)
- if !(blob.raw_binary? || blob.stored_externally?)
= open_raw_blob_button(blob)
= download_button(blob)
= view_on_environment_button(@commit.sha, @path, @environment) if @environment
.btn-group{ role: "group" }<
= render_if_exists 'projects/blob/header_file_locks_link'
= edit_blob_button

View File

@ -0,0 +1,5 @@
---
title: Add download button for single file (including raw files) in repository
merge_request:
author:
type: added