parent
b1be377fb0
commit
e60185699b
2 changed files with 26 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue