debian-mirror-gitlab/app/controllers/dashboard_controller.rb

68 lines
1.8 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-09-11 14:41:01 +05:30
class DashboardController < Dashboard::ApplicationController
2019-03-02 22:35:43 +05:30
include IssuableCollectionsAction
2020-07-28 23:09:34 +05:30
include FiltersEvents
2015-12-23 02:04:40 +05:30
2018-11-29 20:51:05 +05:30
prepend_before_action(only: [:issues]) { authenticate_sessionless_user!(:rss) }
prepend_before_action(only: [:issues_calendar]) { authenticate_sessionless_user!(:ics) }
2015-09-25 12:07:36 +05:30
before_action :event_filter, only: :activity
2015-11-26 14:37:03 +05:30
before_action :projects, only: [:issues, :merge_requests]
2017-08-17 22:00:37 +05:30
before_action :set_show_full_reference, only: [:issues, :merge_requests]
2018-05-09 12:01:36 +05:30
before_action :check_filters_presence!, only: [:issues, :merge_requests]
2020-05-24 23:13:21 +05:30
before_action :set_not_query_feature_flag
2014-09-02 18:07:02 +05:30
2015-09-11 14:41:01 +05:30
respond_to :html
2014-09-02 18:07:02 +05:30
2015-09-25 12:07:36 +05:30
def activity
respond_to do |format|
format.html
format.json do
load_events
2020-02-01 01:16:34 +05:30
pager_json('events/_events', @events.count { |event| event.visible_to_user?(current_user) })
2015-09-25 12:07:36 +05:30
end
end
2014-09-02 18:07:02 +05:30
end
2015-09-25 12:07:36 +05:30
protected
2015-04-26 12:48:37 +05:30
def load_events
2016-04-02 18:10:28 +05:30
projects =
2015-09-25 12:07:36 +05:30
if params[:filter] == "starred"
2017-09-10 17:25:29 +05:30
ProjectsFinder.new(current_user: current_user, params: { starred: true }).execute
2015-09-25 12:07:36 +05:30
else
current_user.authorized_projects
2016-04-02 18:10:28 +05:30
end
2015-09-25 12:07:36 +05:30
2017-09-10 17:25:29 +05:30
@events = EventCollection
2018-12-05 23:21:45 +05:30
.new(projects, offset: params[:offset].to_i, filter: event_filter)
2017-09-10 17:25:29 +05:30
.to_a
2020-02-01 01:16:34 +05:30
.map(&:present)
2018-03-17 18:26:18 +05:30
Events::RenderService.new(current_user).execute(@events)
2014-09-02 18:07:02 +05:30
end
2017-08-17 22:00:37 +05:30
def set_show_full_reference
@show_full_reference = true
end
2018-05-09 12:01:36 +05:30
def check_filters_presence!
2019-07-07 11:18:12 +05:30
no_scalar_filters_set = finder_type.scalar_params.none? { |k| params.key?(k) }
no_array_filters_set = finder_type.array_params.none? { |k, _| params.key?(k) }
@no_filters_set = no_scalar_filters_set && no_array_filters_set
2018-05-09 12:01:36 +05:30
return unless @no_filters_set
2019-02-15 15:39:39 +05:30
# Call to set selected `state` and `sort` options in view
finder_options
2018-05-09 12:01:36 +05:30
respond_to do |format|
2018-11-08 19:23:39 +05:30
format.html { render }
2018-05-09 12:01:36 +05:30
format.atom { head :bad_request }
end
end
2014-09-02 18:07:02 +05:30
end