diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-27 01:58:36 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 19:58:24 +0300 |
commit | b654229dcd3e4460ad7305ee7714395f044a72aa (patch) | |
tree | b5bd0df6a0e8c85dd24d0a5f5ac132193ee46e4a /app | |
parent | ae88126d13d05ea040af495d77dcd1a84253d282 (diff) |
Fix LabelsHelper#link_to_label to use the subject argument
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/labels_helper.rb | 22 | ||||
-rw-r--r-- | app/views/shared/_label.html.haml | 8 | ||||
-rw-r--r-- | app/views/shared/_label_row.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/_labels_row.html.haml | 2 |
4 files changed, 20 insertions, 14 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 844bd3fd183..e26e82c6448 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -31,7 +31,13 @@ module LabelsHelper # # Returns a String def link_to_label(label, subject: nil, type: :issue, tooltip: true, css_class: nil, &block) - link = label_filter_path(label, type: type) + subject ||= + case label + when GroupLabel then label.group + when ProjectLabel then label.project + end + + link = label_filter_path(subject, label, type: type) if block_given? link_to link, class: css_class, &block @@ -40,16 +46,16 @@ module LabelsHelper end end - def label_filter_path(label, type: issue) - case label - when GroupLabel + def label_filter_path(subject, label, type: issue) + case subject + when Group send("#{type.to_s.pluralize}_group_path", - label.group, + subject, label_name: [label.name]) - else + when Project send("namespace_project_#{type.to_s.pluralize}_path", - label.project.namespace, - label.project, + subject.namespace, + subject, label_name: [label.name]) end end diff --git a/app/views/shared/_label.html.haml b/app/views/shared/_label.html.haml index c0b912b0584..ba8a3efccda 100644 --- a/app/views/shared/_label.html.haml +++ b/app/views/shared/_label.html.haml @@ -12,10 +12,10 @@ .dropdown-menu.dropdown-menu-align-right %ul %li - = link_to_label(label, type: :merge_request) do + = link_to_label(label, subject: @project, type: :merge_request) do = pluralize open_merge_requests_count, 'merge request' %li - = link_to_label(label) do + = link_to_label(label, subject: @project) do = pluralize open_issues_count, 'open issue' - if current_user %li.label-subscription{ data: { url: toggle_subscription_label_path(label) } } @@ -28,9 +28,9 @@ = link_to 'Delete', destroy_label_path(label), title: 'Delete', method: :delete, remote: true, data: {confirm: 'Remove this label? Are you sure?'} .pull-right.hidden-xs.hidden-sm.hidden-md - = link_to_label(label, type: :merge_request, css_class: 'btn btn-transparent btn-action') do + = link_to_label(label, subject: @project, type: :merge_request, css_class: 'btn btn-transparent btn-action') do = pluralize open_merge_requests_count, 'merge request' - = link_to_label(label, css_class: 'btn btn-transparent btn-action') do + = link_to_label(label, subject: @project, css_class: 'btn btn-transparent btn-action') do = pluralize open_issues_count, 'open issue' - if current_user diff --git a/app/views/shared/_label_row.html.haml b/app/views/shared/_label_row.html.haml index 8a1ebdd7fb6..a623bbc6b11 100644 --- a/app/views/shared/_label_row.html.haml +++ b/app/views/shared/_label_row.html.haml @@ -9,7 +9,7 @@ %button.remove-priority.btn.has-tooltip{ title: 'Remove priority', :'data-placement' => 'top' } = icon('star') %span.label-name - = link_to_label(label, tooltip: false) + = link_to_label(label, subject: @project, tooltip: false) - if can?(current_user, :admin_label, @project) = label_type_icon(label, hidden: label.priority.blank?) - if label.description diff --git a/app/views/shared/_labels_row.html.haml b/app/views/shared/_labels_row.html.haml index e324d0e5203..21b37a7c9ae 100644 --- a/app/views/shared/_labels_row.html.haml +++ b/app/views/shared/_labels_row.html.haml @@ -1,5 +1,5 @@ - labels.each do |label| %span.label-row.btn-group{ role: "group", aria: { label: label.name }, style: "color: #{text_color_for_bg(label.color)}" } - = link_to_label(label, css_class: 'btn btn-transparent') + = link_to_label(label, subject: @project, css_class: 'btn btn-transparent') %button.btn.btn-transparent.label-remove.js-label-filter-remove{ type: "button", style: "background-color: #{label.color};", data: { label: label.title } } = icon("times") |