summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2015-12-18 14:20:15 +0100
committerRémy Coutable <remy@rymai.me>2016-02-04 19:14:48 +0100
commit6e79ce2efd68b59f3814c1107f6bd70c95fa1405 (patch)
treec20ddb851dfb357f7f629c8647dfe562099a98ba /app
parent3720b98e1bdea5901817dd7a58df532bd5e75077 (diff)
downloadgitlab-ce-6e79ce2efd68b59f3814c1107f6bd70c95fa1405.tar.gz
Allow link_to_label to take an optional type argrymai/gitlab-ce-3007-fix-mr-label-links
You can set type: :merge_request to create a link to merge request lists instead of issues list. Accept both Symbol & String as type argument for the link_to_label helper
Diffstat (limited to 'app')
-rw-r--r--app/helpers/labels_helper.rb13
-rw-r--r--app/views/projects/merge_requests/_merge_request.html.haml2
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml4
3 files changed, 13 insertions, 6 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index 92eac0560bd..1c7fcc13b42 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -7,6 +7,8 @@ module LabelsHelper
# project - Project object which will be used as the context for the label's
# link. If omitted, defaults to `@project`, or the label's own
# project.
+ # type - The type of item the link will point to (:issue or
+ # :merge_request). If omitted, defaults to :issue.
# block - An optional block that will be passed to `link_to`, forming the
# body of the link element. If omitted, defaults to
# `render_colored_label`.
@@ -23,14 +25,19 @@ module LabelsHelper
# # Force the generated link to use a provided project
# link_to_label(label, project: Project.last)
#
+ # # Force the generated link to point to merge requests instead of issues
+ # link_to_label(label, type: :merge_request)
+ #
# # Customize link body with a block
# link_to_label(label) { "My Custom Label Text" }
#
# Returns a String
- def link_to_label(label, project: nil, &block)
+ def link_to_label(label, project: nil, type: :issue, &block)
project ||= @project || label.project
- link = namespace_project_issues_path(project.namespace, project,
- label_name: label.name)
+ link = send("namespace_project_#{type.to_s.pluralize}_path",
+ project.namespace,
+ project,
+ label_name: label.name)
if block_given?
link_to link, &block
diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml
index a051729dc32..e25bf917b43 100644
--- a/app/views/projects/merge_requests/_merge_request.html.haml
+++ b/app/views/projects/merge_requests/_merge_request.html.haml
@@ -53,7 +53,7 @@
- if merge_request.labels.any?
&nbsp;
- merge_request.labels.each do |label|
- = link_to_label(label, project: merge_request.project)
+ = link_to_label(label, project: merge_request.project, type: 'merge_request')
- if merge_request.tasks?
&nbsp;
%span.task-status
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index cab500d7244..75a7d9be2c1 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -90,7 +90,7 @@
.value.issuable-show-labels
- if issuable.labels.any?
- issuable.labels.each do |label|
- = link_to_label(label)
+ = link_to_label(label, type: issuable.to_ability_name)
- else
.light None
.selectbox
@@ -129,4 +129,4 @@
:javascript
new Subscription("#{toggle_subscription_path(issuable)}");
- new IssuableContext(); \ No newline at end of file
+ new IssuableContext();