Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
54040ce0
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
54040ce0
编写于
4月 13, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Show Raw button as Download for binary files
上级
60ebd101
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
40 addition
and
6 deletion
+40
-6
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+12
-2
app/views/projects/blob/_header.html.haml
app/views/projects/blob/_header.html.haml
+2
-2
app/views/shared/snippets/_blob.html.haml
app/views/shared/snippets/_blob.html.haml
+1
-1
features/steps/project/source/browse_files.rb
features/steps/project/source/browse_files.rb
+1
-1
spec/features/projects/blobs/blob_show_spec.rb
spec/features/projects/blobs/blob_show_spec.rb
+24
-0
未找到文件。
app/helpers/blob_helper.rb
浏览文件 @
54040ce0
...
...
@@ -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
)
...
...
app/views/projects/blob/_header.html.haml
浏览文件 @
54040ce0
...
...
@@ -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"
}
<
...
...
app/views/shared/snippets/_blob.html.haml
浏览文件 @
54040ce0
...
...
@@ -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'
}
...
...
features/steps/project/source/browse_files.rb
浏览文件 @
54040ce0
...
...
@@ -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'
...
...
spec/features/projects/blobs/blob_show_spec.rb
浏览文件 @
54040ce0
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
...
...
@@ -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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录