Add page titles to header for group and project

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2015-09-14 19:46:58 +02:00
parent b35d5a6a16
commit 0c8f07774c
No known key found for this signature in database
GPG key ID: 161B5D6A44D3D88A
6 changed files with 67 additions and 20 deletions

View file

@ -17,6 +17,14 @@ module GitlabRoutingHelper
namespace_project_path(project.namespace, project, *args) namespace_project_path(project.namespace, project, *args)
end end
def project_files_path(project, *args)
namespace_project_tree_path(project.namespace, project, @ref || project.repository.root_ref)
end
def project_commits_path(project, *args)
namespace_project_commits_path(project.namespace, project, @ref || project.repository.root_ref)
end
def activity_project_path(project, *args) def activity_project_path(project, *args)
activity_namespace_project_path(project.namespace, project, *args) activity_namespace_project_path(project.namespace, project, *args)
end end

View file

@ -43,24 +43,22 @@ module ProjectsHelper
end end
end end
def project_title(project) def project_title(project, name = nil, url = nil)
if project.group namespace_link =
content_tag :span do if project.group
link_to( link_to(simple_sanitize(project.group.name), group_path(project.group))
simple_sanitize(project.group.name), group_path(project.group) else
) + ' / ' + owner = project.namespace.owner
link_to(simple_sanitize(project.name), link_to(simple_sanitize(owner.name), user_path(owner))
project_path(project))
end
else
owner = project.namespace.owner
content_tag :span do
link_to(
simple_sanitize(owner.name), user_path(owner)
) + ' / ' +
link_to(simple_sanitize(project.name),
project_path(project))
end end
project_link = link_to(simple_sanitize(project.name), project_path(project))
full_title = namespace_link + ' / ' + project_link
full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url) if name
content_tag :span do
full_title
end end
end end
@ -315,6 +313,43 @@ module ProjectsHelper
end end
end end
def detect_project_title(project)
current_ref = @ref || project.repository.root_ref
name, url =
if current_controller? 'wikis'
['Wiki', get_project_wiki_path(project)]
elsif current_controller? 'project_members'
['Members', namespace_project_project_members_path(project.namespace, project)]
elsif current_controller? 'labels'
['Labels', namespace_project_labels_path(project.namespace, project)]
elsif current_controller? 'members'
['Members', project_files_path(project)]
elsif current_controller? 'commits'
['Commits', project_commits_path(project)]
elsif current_controller? 'graphs'
['Graphs', namespace_project_graph_path(project.namespace, project, current_ref)]
elsif current_controller? 'network'
['Network', namespace_project_network_path(project.namespace, project, current_ref)]
elsif current_controller? 'milestones'
['Milestones', namespace_project_milestones_path(project.namespace, project)]
elsif current_controller? 'snippets'
['Snippets', namespace_project_snippets_path(project.namespace, project)]
elsif current_controller? 'issues'
['Issues', namespace_project_issues_path(project.namespace, project)]
elsif current_controller? 'merge_requests'
['Merge Requests', namespace_project_merge_requests_path(project.namespace, project)]
elsif current_controller? 'tree', 'blob'
['Files', project_files_path(project)]
elsif current_path? 'projects#activity'
['Activity', activity_project_path(project)]
else
[nil, nil]
end
project_title(project, name, url)
end
private private
def filename_path(project, filename) def filename_path(project, filename)

View file

@ -1,4 +1,6 @@
- header_title group_title(@group, "Settings", edit_group_path(@group))
- @blank_container = true - @blank_container = true
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
%strong= @group.name %strong= @group.name

View file

@ -1,4 +1,6 @@
- page_title "Projects" - page_title "Projects"
- header_title group_title(@group, "Projects", projects_group_path(@group))
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
%strong= @group.name %strong= @group.name

View file

@ -26,14 +26,14 @@
Activity Activity
- if project_nav_tab? :files - if project_nav_tab? :files
= nav_link(controller: %w(tree blob blame edit_tree new_tree)) do = nav_link(controller: %w(tree blob blame edit_tree new_tree)) do
= link_to namespace_project_tree_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Files', class: 'shortcuts-tree', data: {placement: 'right'} do = link_to project_files_path(@project), title: 'Files', class: 'shortcuts-tree', data: {placement: 'right'} do
= icon('files-o fw') = icon('files-o fw')
%span %span
Files Files
- if project_nav_tab? :commits - if project_nav_tab? :commits
= nav_link(controller: %w(commit commits compare repositories tags branches)) do = nav_link(controller: %w(commit commits compare repositories tags branches)) do
= link_to namespace_project_commits_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Commits', class: 'shortcuts-commits', data: {placement: 'right'} do = link_to project_commits_path(@project), title: 'Commits', class: 'shortcuts-commits', data: {placement: 'right'} do
= icon('history fw') = icon('history fw')
%span %span
Commits Commits

View file

@ -1,5 +1,5 @@
- page_title @project.name_with_namespace - page_title @project.name_with_namespace
- header_title project_title(@project) - header_title detect_project_title(@project)
- sidebar "project" unless sidebar - sidebar "project" unless sidebar
- content_for :scripts_body_top do - content_for :scripts_body_top do