Commit 8b90b1f3 authored by Robert Speicher's avatar Robert Speicher Committed by Rémy Coutable

Merge branch 'fix/14418' into 'master'

Dedupe labels in labels selector in Dashboard pages

Fixes #14418.

See merge request !3311
parent e0d4744a
...@@ -21,17 +21,24 @@ class DashboardController < Dashboard::ApplicationController ...@@ -21,17 +21,24 @@ class DashboardController < Dashboard::ApplicationController
end end
def labels def labels
labels = Label.where(project_id: @projects).select(:title, :color).uniq(:title)
respond_to do |format| respond_to do |format|
format.json do format.json do
render json: view_context.projects_labels_options render json: labels
end end
end end
end end
def milestones def milestones
milestones = Milestone.where(project_id: @projects).active
epoch = DateTime.parse('1970-01-01')
grouped_milestones = GlobalMilestone.build_collection(milestones)
grouped_milestones = grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
respond_to do |format| respond_to do |format|
format.json do format.json do
render json: view_context.projects_milestones_options render json: grouped_milestones
end end
end end
end end
......
...@@ -110,14 +110,6 @@ module LabelsHelper ...@@ -110,14 +110,6 @@ module LabelsHelper
end end
end end
def projects_labels_options
if @project
@project.labels
else
Label.where(project_id: @projects)
end
end
def labels_filter_path def labels_filter_path
if @project if @project
namespace_project_labels_path(@project.namespace, @project, :json) namespace_project_labels_path(@project.namespace, @project, :json)
......
...@@ -46,19 +46,6 @@ module MilestonesHelper ...@@ -46,19 +46,6 @@ module MilestonesHelper
end end
end end
def projects_milestones_options
milestones =
if @project
@project.milestones
else
Milestone.where(project_id: @projects)
end.active
epoch = DateTime.parse('1970-01-01')
grouped_milestones = GlobalMilestone.build_collection(milestones)
grouped_milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
end
def milestones_filter_dropdown_path def milestones_filter_dropdown_path
if @project if @project
namespace_project_milestones_path(@project.namespace, @project, :json) namespace_project_milestones_path(@project.namespace, @project, :json)
......
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