Commit ed480855 authored by Rubén Dávila's avatar Rubén Dávila

Refactor Merge Requests tab into a custom partial

* Add Labels tab to Groups
* Add decorator for label so it's aware of Milestones.
parent 834b5d49
class LabelWithMilestone
attr_reader :milestone
def initialize(label, milestone)
@label, @milestone = label, milestone
end
def method_missing(meth, *args)
if @label.respond_to?(meth)
@label.send(meth, *args)
else
super
end
end
def respond_to?(meth)
@label.respond_to?(meth)
end
end
...@@ -87,6 +87,12 @@ class GlobalMilestone ...@@ -87,6 +87,12 @@ class GlobalMilestone
@participants ||= milestones.map(&:participants).flatten.compact.uniq @participants ||= milestones.map(&:participants).flatten.compact.uniq
end end
def labels
@labels ||= milestones.map do |ms|
ms.labels.map { |label| LabelWithMilestone.new(label, ms) }
end.flatten.sort_by!(&:title)
end
def opened_issues def opened_issues
issues.opened issues.opened
end end
......
...@@ -67,13 +67,17 @@ ...@@ -67,13 +67,17 @@
= link_to '#tab-participants', 'data-toggle' => 'tab' do = link_to '#tab-participants', 'data-toggle' => 'tab' do
Participants Participants
%span.badge= @milestone.participants.count %span.badge= @milestone.participants.count
%li
= link_to '#tab-labels', 'data-toggle' => 'tab', 'data-show' => '.tab-issues-buttons' do
Labels
%span.badge= @milestone.labels.count
.tab-content.milestone-content .tab-content.milestone-content
.tab-pane.active#tab-issues .tab-pane.active#tab-issues
= render 'shared/milestones/issues_tab', unassigned: @milestone.opened_issues.unassigned, assigned: @milestone.opened_issues.assigned, closed: @milestone.closed_issues = render 'shared/milestones/issues_tab', unassigned: @milestone.opened_issues.unassigned, assigned: @milestone.opened_issues.assigned, closed: @milestone.closed_issues
.tab-pane#tab-merge-requests .tab-pane#tab-merge-requests
= render 'shared/milestones/merge_requests_tab', unassigned: @milestone.opened_merge_requests.unassigned, assigned: @milestone.opened_merge_requests.assigned, closed: @milestone.merge_requests.closed, merged: @milestone.merge_requests.merged = render 'shared/milestones/merge_requests_tab', unassigned: @milestone.opened_merge_requests.unassigned, assigned: @milestone.opened_merge_requests.assigned, closed: @milestone.merge_requests.closed, merged: @milestone.merge_requests.merged
.tab-pane#tab-participants .tab-pane#tab-participants
= render 'shared/milestones/participants_tab', users: @milestone.participants = render 'shared/milestones/participants_tab', users: @milestone.participants
.tab-pane#tab-labels
= render 'shared/milestones/labels_tab', labels: @milestone.labels
...@@ -100,16 +100,4 @@ ...@@ -100,16 +100,4 @@
.tab-pane#tab-participants .tab-pane#tab-participants
= render 'shared/milestones/participants_tab', users: @users = render 'shared/milestones/participants_tab', users: @users
.tab-pane#tab-labels .tab-pane#tab-labels
%ul.bordered-list.manage-labels-list = render 'shared/milestones/labels_tab', labels: @labels
- @labels.each do |label|
%li
= render_colored_label(label)
- args = [@milestone.project.namespace, @milestone.project, milestone_title: @milestone.title, label_name: label.title]
- options = args.extract_options!
%span.issues-count
= link_to namespace_project_issues_path(*args, options.merge(state: 'opened')) do
= pluralize label.open_issues_count, 'open issue'
%span.issues-count
= link_to namespace_project_issues_path(*args, options.merge(state: 'closed')) do
= pluralize label.closed_issues_count, 'closed issue'
%ul.bordered-list.manage-labels-list
- labels.each do |label|
- milestone = @milestone.is_a?(Milestone) ? @milestone : label.milestone
%li
= render_colored_label(label)
- args = [milestone.project.namespace, milestone.project, milestone_title: milestone.title, label_name: label.title]
- options = args.extract_options!
%span.issues-count
= link_to namespace_project_issues_path(*args, options.merge(state: 'opened')) do
= pluralize label.open_issues_count, 'open issue'
%span.issues-count
= link_to namespace_project_issues_path(*args, options.merge(state: 'closed')) do
= pluralize label.closed_issues_count, 'closed issue'
...@@ -15,6 +15,7 @@ module Gitlab ...@@ -15,6 +15,7 @@ module Gitlab
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths.push(*%W(#{config.root}/lib config.autoload_paths.push(*%W(#{config.root}/lib
#{config.root}/app/decorators
#{config.root}/app/models/hooks #{config.root}/app/models/hooks
#{config.root}/app/models/concerns #{config.root}/app/models/concerns
#{config.root}/app/models/project_services #{config.root}/app/models/project_services
......
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