diff options
author | Rémy Coutable <remy@rymai.me> | 2015-12-18 14:20:15 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-02-04 19:14:48 +0100 |
commit | 6e79ce2efd68b59f3814c1107f6bd70c95fa1405 (patch) | |
tree | c20ddb851dfb357f7f629c8647dfe562099a98ba /app | |
parent | 3720b98e1bdea5901817dd7a58df532bd5e75077 (diff) | |
download | gitlab-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.rb | 13 | ||||
-rw-r--r-- | app/views/projects/merge_requests/_merge_request.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/issuable/_sidebar.html.haml | 4 |
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? - 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? %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(); |