diff options
author | Marin Jankovski <marin@gitlab.com> | 2014-07-08 19:28:02 +0400 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-07-09 12:12:09 +0400 |
commit | 6b121aa5a7d2a02bf758c13cb9b5ef9845700b08 (patch) | |
tree | b7bac53111bf2946e3ea544763bcad9d9473e935 | |
parent | 5d25f3d9b12203c3010ba92d7dacfcbeaf51781e (diff) |
Move the links decision to helper.
-rw-r--r-- | app/helpers/commits_helper.rb | 12 | ||||
-rw-r--r-- | app/views/projects/commits/_commit.html.haml | 7 |
2 files changed, 13 insertions, 6 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 4d27cf2851e..9643a0a965c 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -180,6 +180,18 @@ module CommitsHelper return old_lines, new_lines end + def link_to_browse_code(project, commit) + if current_controller?(:projects, :commits) + if @repo.blob_at(commit.id, @path) + link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right" + else + link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right" + end + else + link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right" + end + end + protected # Private: Returns a link to a person. If the person has a matching user and diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 20fe2688fb4..5adb6b9e3b1 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -7,12 +7,7 @@ - if commit.description? %a.text-expander.js-toggle-button ... - - if @repo && @repo.blob_at(commit.id, @path) - = link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right" - - elsif @path.blank? - = link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right" - - else - = link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right" + = link_to_browse_code(project, commit) .notes_count - if @note_counts |