summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-02-04 11:10:11 -0500
committerJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-02-04 11:10:11 -0500
commit2e6c5fb28e2fb924addffd29345dab45b7980905 (patch)
treef829e95874e284eb383469affd4055585fd01338
parentf25ba6e03c6635b75a46e6f53c3cfee8109b74f9 (diff)
downloadgitlab-ce-feature/jschatz1/issuable-sidebar.tar.gz
Properly link to the right issue or merge requestfeature/jschatz1/issuable-sidebar
-rw-r--r--app/helpers/application_helper.rb20
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml4
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