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

99 lines
2.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]
2014-09-02 18:07:02 +05:30
2023-06-20 00:43:36 +05:30
before_action only: :merge_requests do
push_frontend_feature_flag(:mr_approved_filter, type: :ops)
end
2015-09-11 14:41:01 +05:30
respond_to :html
2014-09-02 18:07:02 +05:30
2023-04-23 21:23:45 +05:30
feature_category :user_profile, [:activity]
2021-12-11 22:18:48 +05:30
feature_category :team_planning, [:issues, :issues_calendar]
2023-03-17 16:20:25 +05:30
feature_category :code_review_workflow, [:merge_requests]
2021-01-03 14:25:43 +05:30
2022-07-16 23:28:13 +05:30
urgency :low, [:merge_requests, :activity]
urgency :low, [:issues, :issues_calendar]
2022-01-26 12:08:38 +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
2021-03-11 19:13:27 +05:30
@events =
2023-04-23 21:23:45 +05:30
case params[:filter]
when "projects", "starred"
2021-03-11 19:13:27 +05:30
load_project_events
2023-04-23 21:23:45 +05:30
when "followed"
load_user_events(current_user.followees)
else
load_user_events(current_user)
2021-03-11 19:13:27 +05:30
end
Events::RenderService.new(current_user).execute(@events)
end
2023-04-23 21:23:45 +05:30
def load_user_events(user)
UserRecentEventsFinder.new(current_user, user, event_filter, params).execute
2021-03-11 19:13:27 +05:30
end
def load_project_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
2021-03-11 19:13:27 +05:30
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)
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!
2022-05-07 20:08:51 +05:30
no_scalar_filters_set = finder_type.scalar_params.none? { |k| params[k].present? }
no_array_filters_set = finder_type.array_params.none? { |k, _| params[k].present? }
# The `in` param is a modifier of `search`. If it's present while the `search`
# param isn't, the finder won't use the `in` param. We consider this as a no
# filter scenario.
no_search_filter_set = params[:in].present? && params[:search].blank?
2019-07-07 11:18:12 +05:30
2022-05-07 20:08:51 +05:30
@no_filters_set = (no_scalar_filters_set && no_array_filters_set) || no_search_filter_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