BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2b7e3182
Commit
2b7e3182
authored
May 01, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dm-blob-download-button' into 'master'
Show Raw button as Download for binary files See merge request !10743
parents
f963f761
1686ce03
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
6 deletions
+44
-6
blob_helper.rb
app/helpers/blob_helper.rb
+12
-2
_header.html.haml
app/views/projects/blob/_header.html.haml
+2
-2
_blob.html.haml
app/views/shared/snippets/_blob.html.haml
+1
-1
dm-blob-download-button.yml
changelogs/unreleased/dm-blob-download-button.yml
+4
-0
browse_files.rb
features/steps/project/source/browse_files.rb
+1
-1
blob_show_spec.rb
spec/features/projects/blobs/blob_show_spec.rb
+24
-0
No files found.
app/helpers/blob_helper.rb
View file @
2b7e3182
...
@@ -217,11 +217,21 @@ module BlobHelper
...
@@ -217,11 +217,21 @@ module BlobHelper
end
end
def
copy_blob_source_button
(
blob
)
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"
)
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
end
def
open_raw_blob_button
def
open_raw_blob_button
(
blob
)
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'
}
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
end
def
blob_render_error_reason
(
viewer
)
def
blob_render_error_reason
(
viewer
)
...
...
app/views/projects/blob/_header.html.haml
View file @
2b7e3182
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
=
render
'projects/blob/viewer_switcher'
,
blob:
blob
unless
blame
=
render
'projects/blob/viewer_switcher'
,
blob:
blob
unless
blame
.btn-group
{
role:
"group"
}
<
.btn-group
{
role:
"group"
}
<
=
copy_blob_source_button
(
blob
)
if
!
blame
&&
blob
.
rendered_as_text?
(
ignore_errors:
false
)
=
copy_blob_source_button
(
blob
)
unless
blame
=
open_raw_blob_button
=
open_raw_blob_button
(
blob
)
=
view_on_environment_button
(
@commit
.
sha
,
@path
,
@environment
)
if
@environment
=
view_on_environment_button
(
@commit
.
sha
,
@path
,
@environment
)
if
@environment
.btn-group
{
role:
"group"
}
<
.btn-group
{
role:
"group"
}
<
...
...
app/views/shared/snippets/_blob.html.haml
View file @
2b7e3182
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
.btn-group
{
role:
"group"
}
<
.btn-group
{
role:
"group"
}
<
=
copy_blob_source_button
(
blob
)
=
copy_blob_source_button
(
blob
)
=
open_raw_blob_button
=
open_raw_blob_button
(
blob
)
-
if
defined?
(
download_path
)
&&
download_path
-
if
defined?
(
download_path
)
&&
download_path
=
link_to
icon
(
'download'
),
download_path
,
class:
"btn btn-sm has-tooltip"
,
title:
'Download'
,
data:
{
container:
'body'
}
=
link_to
icon
(
'download'
),
download_path
,
class:
"btn btn-sm has-tooltip"
,
title:
'Download'
,
data:
{
container:
'body'
}
...
...
changelogs/unreleased/dm-blob-download-button.yml
0 → 100644
View file @
2b7e3182
---
title
:
Show Raw button as Download for binary files
merge_request
:
author
:
features/steps/project/source/browse_files.rb
View file @
2b7e3182
...
@@ -367,7 +367,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
...
@@ -367,7 +367,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
step
'I should see buttons for allowed commands'
do
step
'I should see buttons for allowed commands'
do
page
.
within
'.content'
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
'History'
expect
(
page
).
to
have_content
'Permalink'
expect
(
page
).
to
have_content
'Permalink'
expect
(
page
).
not_to
have_content
'Edit'
expect
(
page
).
not_to
have_content
'Edit'
...
...
spec/features/projects/blobs/blob_show_spec.rb
View file @
2b7e3182
...
@@ -24,6 +24,9 @@ feature 'File blob', :js, feature: true do
...
@@ -24,6 +24,9 @@ feature 'File blob', :js, feature: true do
# shows an enabled copy button
# shows an enabled copy button
expect
(
page
).
to
have_selector
(
'.js-copy-blob-source-btn:not(.disabled)'
)
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
end
end
end
...
@@ -50,6 +53,9 @@ feature 'File blob', :js, feature: true do
...
@@ -50,6 +53,9 @@ feature 'File blob', :js, feature: true do
# shows a disabled copy button
# shows a disabled copy button
expect
(
page
).
to
have_selector
(
'.js-copy-blob-source-btn.disabled'
)
expect
(
page
).
to
have_selector
(
'.js-copy-blob-source-btn.disabled'
)
# shows a raw button
expect
(
page
).
to
have_link
(
'Open raw'
)
end
end
end
end
...
@@ -160,6 +166,9 @@ feature 'File blob', :js, feature: true do
...
@@ -160,6 +166,9 @@ feature 'File blob', :js, feature: true do
# does not show a copy button
# does not show a copy button
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
# shows a raw button
expect
(
page
).
to
have_link
(
'Open raw'
)
end
end
end
end
...
@@ -203,6 +212,9 @@ feature 'File blob', :js, feature: true do
...
@@ -203,6 +212,9 @@ feature 'File blob', :js, feature: true do
# shows an enabled copy button
# shows an enabled copy button
expect
(
page
).
to
have_selector
(
'.js-copy-blob-source-btn:not(.disabled)'
)
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
end
end
end
...
@@ -237,6 +249,9 @@ feature 'File blob', :js, feature: true do
...
@@ -237,6 +249,9 @@ feature 'File blob', :js, feature: true do
# does not show a copy button
# does not show a copy button
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
# shows a download button
expect
(
page
).
to
have_link
(
'Download'
)
end
end
end
end
end
end
...
@@ -262,6 +277,9 @@ feature 'File blob', :js, feature: true do
...
@@ -262,6 +277,9 @@ feature 'File blob', :js, feature: true do
# does not show a copy button
# does not show a copy button
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
# shows a download button
expect
(
page
).
to
have_link
(
'Download'
)
end
end
end
end
end
end
...
@@ -283,6 +301,9 @@ feature 'File blob', :js, feature: true do
...
@@ -283,6 +301,9 @@ feature 'File blob', :js, feature: true do
# shows an enabled copy button
# shows an enabled copy button
expect
(
page
).
to
have_selector
(
'.js-copy-blob-source-btn:not(.disabled)'
)
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
end
end
end
...
@@ -305,6 +326,9 @@ feature 'File blob', :js, feature: true do
...
@@ -305,6 +326,9 @@ feature 'File blob', :js, feature: true do
# does not show a copy button
# does not show a copy button
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
expect
(
page
).
not_to
have_selector
(
'.js-copy-blob-source-btn'
)
# shows a download button
expect
(
page
).
to
have_link
(
'Download'
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment