Commit e257e81c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix/14505' into 'master'

Fix an issue causing the Dashboard/Milestones page to be blank

Fixes #14505 and #14514.

See merge request !3348
parent e1f999a2
......@@ -11,6 +11,7 @@ v 8.6.1 (unreleased)
- Auto collapses the navigation sidebar when resizing. !3343
- Shows error messages when trying to create label in dropdown menu. !3345
- Fixes issue with assign milestone not loading milestone list. !3346
- Fix an issue causing the Dashboard/Milestones page to be blank. !3348
v 8.6.0
- Add ability to move issue to another project
......
......@@ -6,7 +6,6 @@ module GlobalMilestones
@milestones = MilestonesFinder.new.execute(@projects, params)
@milestones = GlobalMilestone.build_collection(@milestones)
@milestones = @milestones.sort_by { |x| x.due_date.nil? ? epoch : x.due_date }
@milestones = Kaminari.paginate_array(@milestones).page(params[:page]).per(ApplicationController::PER_PAGE)
end
def milestone
......
class Dashboard::ApplicationController < ApplicationController
layout 'dashboard'
private
def projects
@projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
end
end
class Dashboard::LabelsController < Dashboard::ApplicationController
def index
labels = Label.where(project_id: projects).select(:title, :color).uniq(:title)
respond_to do |format|
format.json { render json: labels }
end
end
end
......@@ -2,18 +2,19 @@ class Dashboard::MilestonesController < Dashboard::ApplicationController
include GlobalMilestones
before_action :projects
before_action :milestones, only: [:index]
before_action :milestone, only: [:show]
def index
respond_to do |format|
format.html do
@milestones = Kaminari.paginate_array(milestones).page(params[:page])
end
format.json do
render json: milestones
end
end
end
def show
end
private
def projects
@projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
end
end
......@@ -3,7 +3,7 @@ class DashboardController < Dashboard::ApplicationController
include MergeRequestsAction
before_action :event_filter, only: :activity
before_action :projects, only: [:issues, :merge_requests, :labels, :milestones]
before_action :projects, only: [:issues, :merge_requests]
respond_to :html
......@@ -20,29 +20,6 @@ class DashboardController < Dashboard::ApplicationController
end
end
def labels
labels = Label.where(project_id: @projects).select(:title, :color).uniq(:title)
respond_to do |format|
format.json do
render json: labels
end
end
end
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|
format.json do
render json: grouped_milestones
end
end
end
protected
def load_events
......@@ -57,8 +34,4 @@ class DashboardController < Dashboard::ApplicationController
@events = @event_filter.apply_filter(@events).with_associations
@events = @events.limit(20).offset(params[:offset] || 0)
end
def projects
@projects ||= current_user.authorized_projects.sorted_by_activity.non_archived
end
end
......@@ -2,11 +2,15 @@ class Groups::MilestonesController < Groups::ApplicationController
include GlobalMilestones
before_action :group_projects
before_action :milestones, only: [:index]
before_action :milestone, only: [:show, :update]
before_action :authorize_admin_milestones!, only: [:new, :create, :update]
def index
respond_to do |format|
format.html do
@milestones = Kaminari.paginate_array(milestones).page(params[:page])
end
end
end
def new
......
......@@ -114,7 +114,7 @@ module LabelsHelper
if @project
namespace_project_labels_path(@project.namespace, @project, :json)
else
labels_dashboard_path(:json)
dashboard_labels_path(:json)
end
end
......
......@@ -50,7 +50,7 @@ module MilestonesHelper
if @project
namespace_project_milestones_path(@project.namespace, @project, :json)
else
milestones_dashboard_path(:json)
dashboard_milestones_path(:json)
end
end
......
......@@ -351,11 +351,10 @@ Rails.application.routes.draw do
get :issues
get :merge_requests
get :activity
get :labels
get :milestones
scope module: :dashboard do
resources :milestones, only: [:index, :show]
resources :labels, only: [:index]
resources :groups, only: [:index]
resources :snippets, only: [:index]
......
require 'spec_helper'
feature 'Dashboard > Milestones', feature: true do
describe 'as anonymous user' do
before do
visit dashboard_milestones_path
end
it 'is redirected to sign-in page' do
expect(current_path).to eq new_user_session_path
end
end
describe 'as logged-in user' do
let(:user) { create(:user) }
let(:project) { create(:empty_project, namespace: user.namespace) }
let!(:milestone) { create(:milestone, project: project) }
before do
project.team << [user, :master]
login_with(user)
visit dashboard_milestones_path
end
it 'sees milestones' do
expect(current_path).to eq dashboard_milestones_path
expect(page).to have_content(milestone.title)
end
end
end
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