Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f8e27b92
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,发现更多精彩内容 >>
提交
f8e27b92
编写于
11月 02, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1902 from tsigo/breadcrumbs
Fix breadcrumb links on Commits page
上级
b4be3c73
e6018569
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
30 deletion
+63
-30
app/assets/javascripts/tree.js.coffee
app/assets/javascripts/tree.js.coffee
+18
-20
app/decorators/tree_decorator.rb
app/decorators/tree_decorator.rb
+2
-2
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+25
-0
app/views/commits/show.html.haml
app/views/commits/show.html.haml
+1
-8
features/project/commits/commits.feature
features/project/commits/commits.feature
+4
-0
features/steps/project/project_browse_commits.rb
features/steps/project/project_browse_commits.rb
+9
-0
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+4
-0
未找到文件。
app/assets/javascripts/tree.js.coffee
浏览文件 @
f8e27b92
...
...
@@ -17,23 +17,21 @@ $ ->
"ajax:beforeSend"
:
->
$
(
'.tree_progress'
).
addClass
(
"loading"
)
"ajax:complete"
:
->
$
(
'.tree_progress'
).
removeClass
(
"loading"
)
# Maintain forward/back history while browsing the file tree
((
window
)
->
History
=
window
.
History
$
=
window
.
jQuery
document
=
window
.
document
# Check to see if History.js is enabled for our Browser
unless
History
.
enabled
return
false
$
->
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb li > a'
).
live
'click'
,
(
e
)
->
History
.
pushState
(
null
,
null
,
$
(
@
).
attr
(
'href'
))
return
false
History
.
Adapter
.
bind
window
,
'statechange'
,
->
state
=
History
.
getState
()
window
.
ajaxGet
(
state
.
url
)
)(
window
)
# Maintain forward/back history while browsing the file tree
((
window
)
->
History
=
window
.
History
$
=
window
.
jQuery
document
=
window
.
document
# Check to see if History.js is enabled for our Browser
unless
History
.
enabled
return
false
$
(
'#tree-slider .tree-item-file-name a, .breadcrumb li > a'
).
live
'click'
,
(
e
)
->
History
.
pushState
(
null
,
null
,
$
(
@
).
attr
(
'href'
))
return
false
History
.
Adapter
.
bind
window
,
'statechange'
,
->
state
=
History
.
getState
()
window
.
ajaxGet
(
state
.
url
)
)(
window
)
app/decorators/tree_decorator.rb
浏览文件 @
f8e27b92
...
...
@@ -8,14 +8,14 @@ class TreeDecorator < ApplicationDecorator
#parts = parts[0...-1] if is_blob?
yield
(
h
.
link_to
(
".."
,
"#"
,
remote:
true
))
if
parts
.
count
>
max_links
yield
(
h
.
link_to
(
".."
,
"#"
))
if
parts
.
count
>
max_links
parts
.
each
do
|
part
|
part_path
=
File
.
join
(
part_path
,
part
)
unless
part_path
.
empty?
part_path
=
part
if
part_path
.
empty?
next
unless
parts
.
last
(
2
).
include?
(
part
)
if
parts
.
count
>
max_links
yield
(
h
.
link_to
(
h
.
truncate
(
part
,
length:
40
),
h
.
project_tree_path
(
project
,
h
.
tree_join
(
ref
,
part_path
))
,
remote:
true
))
yield
(
h
.
link_to
(
h
.
truncate
(
part
,
length:
40
),
h
.
project_tree_path
(
project
,
h
.
tree_join
(
ref
,
part_path
))))
end
end
end
...
...
app/helpers/tree_helper.rb
浏览文件 @
f8e27b92
...
...
@@ -67,4 +67,29 @@ module TreeHelper
can?
(
current_user
,
:push_code
,
@project
)
end
end
# Breadcrumb links for a Project and, if applicable, a tree path
def
breadcrumbs
return
unless
@project
&&
@ref
# Add the root project link and the arrow icon
crumbs
=
content_tag
(
:li
)
do
content_tag
(
:span
,
nil
,
class:
'arrow'
)
+
link_to
(
@project
.
name
,
project_commits_path
(
@project
,
@ref
))
end
if
@path
parts
=
@path
.
split
(
'/'
)
parts
.
each_with_index
do
|
part
,
i
|
crumbs
+=
content_tag
(
:span
,
'/'
,
class:
'divider'
)
crumbs
+=
content_tag
(
:li
)
do
# The text is just the individual part, but the link needs all the parts before it
link_to
part
,
project_commits_path
(
@project
,
tree_join
(
@ref
,
parts
[
0
..
i
].
join
(
'/'
)))
end
end
end
crumbs
.
html_safe
end
end
app/views/commits/show.html.haml
浏览文件 @
f8e27b92
...
...
@@ -2,14 +2,7 @@
-
if
@path
.
present?
%ul
.breadcrumb
%li
%span
.arrow
=
link_to
project_commits_path
(
@project
)
do
=
@project
.
name
%span
.divider
\/
%li
%a
{
href:
"#"
}=
@path
.
split
(
"/"
).
join
(
" / "
)
=
breadcrumbs
%div
{
id:
dom_id
(
@project
)}
#commits_list
=
render
"commits"
...
...
features/project/commits/commits.feature
浏览文件 @
f8e27b92
...
...
@@ -19,3 +19,7 @@ Feature: Project Browse commits
Given
I visit compare refs page
And
I fill compare fields with refs
Then
I see compared refs
Scenario
:
I
browse commits for a specific path
Given
I visit my project's commits page for a specific path
Then
I see breadcrumb links
features/steps/project/project_browse_commits.rb
浏览文件 @
f8e27b92
...
...
@@ -42,4 +42,13 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
page
.
should
have_content
"Commits (1)"
page
.
should
have_content
"Showing 2 changed files"
end
Then
'I see breadcrumb links'
do
page
.
should
have_selector
(
'ul.breadcrumb'
)
page
.
should
have_selector
(
'ul.breadcrumb span.divider'
,
count:
3
)
page
.
should
have_selector
(
'ul.breadcrumb a'
,
count:
4
)
find
(
'ul.breadcrumb li:first a'
)[
'href'
].
should
match
(
/
#{
@project
.
path
}
\/commits\/master\z/
)
find
(
'ul.breadcrumb li:last a'
)[
'href'
].
should
match
(
%r{master/app/models/project
\.
rb
\z
}
)
end
end
features/steps/shared/paths.rb
浏览文件 @
f8e27b92
...
...
@@ -121,6 +121,10 @@ module SharedPaths
visit
project_commits_path
(
@project
,
@project
.
root_ref
,
{
limit:
5
})
end
Given
"I visit my project's commits page for a specific path"
do
visit
project_commits_path
(
@project
,
@project
.
root_ref
+
"/app/models/project.rb"
,
{
limit:
5
})
end
Given
"I visit my project's network page"
do
# Stub GraphCommit max_size to speed up test (10 commits vs. 650)
Gitlab
::
GraphCommit
.
stub
(
max_count:
10
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录