From 2e6c5fb28e2fb924addffd29345dab45b7980905 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Thu, 4 Feb 2016 11:10:11 -0500 Subject: Properly link to the right issue or merge request --- app/helpers/application_helper.rb | 20 ++++++++++++++++++++ app/views/shared/issuable/_sidebar.html.haml | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 00f38932861..14f098d8355 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -293,6 +293,26 @@ module ApplicationHelper end end + def issuable_link_next(project,issuable) + if project.nil? + nil + elsif current_controller?(:issues) + namespace_project_issue_path(project.namespace, project, next_issuable_for(project, issuable.id).try(:iid)) + elsif current_controller?(:merge_requests) + namespace_project_merge_request_path(project.namespace, project, next_issuable_for(project, issuable.id).try(:iid)) + end + end + + def issuable_link_prev(project,issuable) + if project.nil? + nil + elsif current_controller?(:issues) + namespace_project_issue_path(project.namespace, project, prev_issuable_for(project, issuable.id).try(:iid)) + elsif current_controller?(:merge_requests) + namespace_project_merge_request_path(project.namespace, project, prev_issuable_for(project, issuable.id).try(:iid)) + end + end + def issuable_count(entity, project) if project.nil? 0 diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index f4f04a42196..cab500d7244 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -13,12 +13,12 @@ = icon('angle-double-right') .issuable-nav.pull-right.btn-group{role: 'group', "aria-label" => '...'} - if has_prev_issuable?(@project, issuable.id) - = link_to 'Prev', namespace_project_issue_path(@project.namespace, @project, prev_issuable_for(@project, issuable.id).try(:iid)), class: 'btn btn-default' + = link_to 'Prev', issuable_link_prev(@project, issuable), class: 'btn btn-default' - else %a.btn.btn-default.disabled{href: '#'} Prev - if has_next_issuable?(@project, issuable.id) - = link_to 'Next', namespace_project_issue_path(@project.namespace, @project, next_issuable_for(@project, issuable.id).try(:iid)), class: 'btn btn-default' + = link_to 'Next', issuable_link_next(@project, issuable), class: 'btn btn-default' - else %a.btn.btn-default.disabled{href: '#'} Next -- cgit v1.2.1