summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-14 20:23:01 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-14 20:23:01 +0200
commitb5c681c0c931df9408dc266a5d2d0326e23c7cb8 (patch)
tree0d823ac2ee84c5d6aa33352e096fb53f974712d3
parentd3be65a811f1e5e30cba919e65de162217d9f7cc (diff)
downloadgitlab-ce-b5c681c0c931df9408dc266a5d2d0326e23c7cb8.tar.gz
Add current_ref helper methodheader-titles
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/helpers/projects_helper.rb6
-rw-r--r--app/views/layouts/nav/_project.html.haml4
-rw-r--r--app/views/projects/commits/_head.html.haml4
-rw-r--r--app/views/projects/show.html.haml2
4 files changed, 9 insertions, 7 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 268c563700c..6a2de0de77c 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -313,9 +313,11 @@ module ProjectsHelper
end
end
- def detect_project_title(project)
- current_ref = @ref || project.repository.root_ref
+ def current_ref
+ @ref || @repository.try(:root_ref)
+ end
+ def detect_project_title(project)
name, url =
if current_controller? 'wikis'
['Wiki', get_project_wiki_path(project)]
diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml
index 2159d931da2..8ce46d4865b 100644
--- a/app/views/layouts/nav/_project.html.haml
+++ b/app/views/layouts/nav/_project.html.haml
@@ -40,14 +40,14 @@
- if project_nav_tab? :network
= nav_link(controller: %w(network)) do
- = link_to namespace_project_network_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Network', class: 'shortcuts-network', data: {placement: 'right'} do
+ = link_to namespace_project_network_path(@project.namespace, @project, current_ref), title: 'Network', class: 'shortcuts-network', data: {placement: 'right'} do
= icon('code-fork fw')
%span
Network
- if project_nav_tab? :graphs
= nav_link(controller: %w(graphs)) do
- = link_to namespace_project_graph_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Graphs', class: 'shortcuts-graphs', data: {placement: 'right'} do
+ = link_to namespace_project_graph_path(@project.namespace, @project, current_ref), title: 'Graphs', class: 'shortcuts-graphs', data: {placement: 'right'} do
= icon('area-chart fw')
%span
Graphs
diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml
index 50c0fd6803d..a849bf84698 100644
--- a/app/views/projects/commits/_head.html.haml
+++ b/app/views/projects/commits/_head.html.haml
@@ -1,10 +1,10 @@
%ul.center-top-menu
= nav_link(controller: [:commit, :commits]) do
- = link_to namespace_project_commits_path(@project.namespace, @project, @ref || @repository.root_ref) do
+ = link_to namespace_project_commits_path(@project.namespace, @project, current_ref) do
Commits
%span.badge= number_with_delimiter(@repository.commit_count)
= nav_link(controller: :compare) do
- = link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: @ref || @repository.root_ref) do
+ = link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: current_ref) do
Compare
= nav_link(html_options: {class: branches_tab_class}) do
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index d5c4ee71978..aa5914e3ed9 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -14,7 +14,7 @@
.project-stats.gray-content-block
%ul.nav.nav-pills
%li
- = link_to namespace_project_commits_path(@project.namespace, @project, @ref || @repository.root_ref) do
+ = link_to namespace_project_commits_path(@project.namespace, @project, current_ref) do
= pluralize(number_with_delimiter(@project.commit_count), 'commit')
%li
= link_to namespace_project_branches_path(@project.namespace, @project) do