summaryrefslogtreecommitdiff
path: root/app/controllers/profiles
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-28 15:10:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-28 15:10:21 +0000
commitc41b66bd0510571d6a426ec6c701278ecd79b683 (patch)
treecaa800f1d461aec59ff9b733058ef56ed9856769 /app/controllers/profiles
parent9f8061811b2ab29fc6e48a8845eaf531b40d037a (diff)
downloadgitlab-ce-c41b66bd0510571d6a426ec6c701278ecd79b683.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r--app/controllers/profiles/notifications_controller.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb
index 064b2a2cc12..6ba32fd45b3 100644
--- a/app/controllers/profiles/notifications_controller.rb
+++ b/app/controllers/profiles/notifications_controller.rb
@@ -1,15 +1,14 @@
# frozen_string_literal: true
class Profiles::NotificationsController < Profiles::ApplicationController
+ NOTIFICATIONS_PER_PAGE = 10
+
# rubocop: disable CodeReuse/ActiveRecord
def show
@user = current_user
- @group_notifications = current_user.notification_settings.preload_source_route.for_groups.order(:id)
- @group_notifications += GroupsFinder.new(
- current_user,
- all_available: false,
- exclude_group_ids: @group_notifications.select(:source_id)
- ).execute.map { |group| current_user.notification_settings_for(group, inherit: true) }
+ @user_groups = user_groups
+ @group_notifications = user_groups.map { |group| current_user.notification_settings_for(group, inherit: true) }
+
@project_notifications = current_user.notification_settings.for_projects.order(:id)
.preload_source_route
.select { |notification| current_user.can?(:read_project, notification.source) }
@@ -32,4 +31,10 @@ class Profiles::NotificationsController < Profiles::ApplicationController
def user_params
params.require(:user).permit(:notification_email, :notified_of_own_activity)
end
+
+ private
+
+ def user_groups
+ GroupsFinder.new(current_user).execute.order_name_asc.page(params[:page]).per(NOTIFICATIONS_PER_PAGE)
+ end
end