Skip to content
Snippets Groups Projects
Commit 54040ce0 authored by Douwe Maan's avatar Douwe Maan
Browse files

Show Raw button as Download for binary files

parent 60ebd101
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -217,11 +217,21 @@ module BlobHelper
end
 
def copy_blob_source_button(blob)
return unless blob.rendered_as_text?(ignore_errors: false)
clipboard_button(target: ".blob-content[data-blob-id='#{blob.id}']", class: "btn btn-sm js-copy-blob-source-btn", title: "Copy source to clipboard")
end
 
def open_raw_blob_button
link_to icon('file-code-o'), blob_raw_url, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: 'Open raw', data: { container: 'body' }
def open_raw_blob_button(blob)
if blob.raw_binary?
icon = icon('download')
title = 'Download'
else
icon = icon('file-code-o')
title = 'Open raw'
end
link_to icon, blob_raw_url, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' }
end
 
def blob_render_error_reason(viewer)
Loading
Loading
Loading
Loading
@@ -15,8 +15,8 @@
= render 'projects/blob/viewer_switcher', blob: blob unless blame
 
.btn-group{ role: "group" }<
= copy_blob_source_button(blob) if !blame && blob.rendered_as_text?(ignore_errors: false)
= open_raw_blob_button
= copy_blob_source_button(blob) unless blame
= open_raw_blob_button(blob)
= view_on_environment_button(@commit.sha, @path, @environment) if @environment
 
.btn-group{ role: "group" }<
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@
 
.btn-group{ role: "group" }<
= copy_blob_source_button(blob)
= open_raw_blob_button
= open_raw_blob_button(blob)
 
- if defined?(download_path) && download_path
= link_to icon('download'), download_path, class: "btn btn-sm has-tooltip", title: 'Download', data: { container: 'body' }
Loading
Loading
Loading
Loading
@@ -367,7 +367,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
 
step 'I should see buttons for allowed commands' do
page.within '.content' do
expect(page).to have_link 'Open raw'
expect(page).to have_link 'Download'
expect(page).to have_content 'History'
expect(page).to have_content 'Permalink'
expect(page).not_to have_content 'Edit'
Loading
Loading
Loading
Loading
@@ -24,6 +24,9 @@ feature 'File blob', :js, feature: true do
 
# shows an enabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
# shows a raw button
expect(page).to have_link('Open raw')
end
end
end
Loading
Loading
@@ -50,6 +53,9 @@ feature 'File blob', :js, feature: true do
 
# shows a disabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
# shows a raw button
expect(page).to have_link('Open raw')
end
end
 
Loading
Loading
@@ -160,6 +166,9 @@ feature 'File blob', :js, feature: true do
 
# does not show a copy button
expect(page).not_to have_selector('.js-copy-blob-source-btn')
# shows a raw button
expect(page).to have_link('Open raw')
end
end
 
Loading
Loading
@@ -203,6 +212,9 @@ feature 'File blob', :js, feature: true do
 
# shows an enabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
# shows a raw button
expect(page).to have_link('Open raw')
end
end
end
Loading
Loading
@@ -237,6 +249,9 @@ feature 'File blob', :js, feature: true do
 
# does not show a copy button
expect(page).not_to have_selector('.js-copy-blob-source-btn')
# shows a download button
expect(page).to have_link('Download')
end
end
end
Loading
Loading
@@ -262,6 +277,9 @@ feature 'File blob', :js, feature: true do
 
# does not show a copy button
expect(page).not_to have_selector('.js-copy-blob-source-btn')
# shows a download button
expect(page).to have_link('Download')
end
end
end
Loading
Loading
@@ -283,6 +301,9 @@ feature 'File blob', :js, feature: true do
 
# shows an enabled copy button
expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
# shows a raw button
expect(page).to have_link('Open raw')
end
end
end
Loading
Loading
@@ -305,6 +326,9 @@ feature 'File blob', :js, feature: true do
 
# does not show a copy button
expect(page).not_to have_selector('.js-copy-blob-source-btn')
# shows a download button
expect(page).to have_link('Download')
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment