Commit 076956cb authored by Robert Speicher's avatar Robert Speicher

Merge branch 'issue_13501' into 'master'

Add link to open merge requests on label index

Closes #13501 

See merge request !3057
parents 1fe9b933 c5df14ff
......@@ -27,6 +27,7 @@ class Label < ActiveRecord::Base
belongs_to :project
has_many :label_links, dependent: :destroy
has_many :issues, through: :label_links, source: :target, source_type: 'Issue'
has_many :merge_requests, through: :label_links, source: :target, source_type: 'MergeRequest'
validates :color, color: true, allow_blank: false
validates :project, presence: true, unless: Proc.new { |service| service.template? }
......@@ -90,6 +91,10 @@ class Label < ActiveRecord::Base
issues.closed.count
end
def open_merge_requests_count
merge_requests.opened.count
end
def template?
template
end
......
......@@ -2,6 +2,10 @@
= render "shared/label_row", label: label
.pull-right
%strong.append-right-20
= link_to_label(label, type: :merge_request) do
= pluralize label.open_merge_requests_count, 'open merge request'
%strong.append-right-20
= link_to_label(label) do
= pluralize label.open_issues_count, 'open issue'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment