2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module RendersMemberAccess
|
|
|
|
def prepare_groups_for_rendering(groups)
|
|
|
|
preload_max_member_access_for_collection(Group, groups)
|
|
|
|
|
|
|
|
groups
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
def preload_max_member_access_for_collection(klass, collection)
|
|
|
|
return if !current_user || collection.blank?
|
|
|
|
|
|
|
|
method_name = "max_member_access_for_#{klass.name.underscore}_ids"
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
collection_ids = collection.try(:map, &:id) || collection.ids
|
|
|
|
current_user.public_send(method_name, collection_ids) # rubocop:disable GitlabSecurity/PublicSend
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|