2020-02-13 21:08:59 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class Namespace < Entities::NamespaceBasic
|
|
|
|
expose :members_count_with_descendants, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _|
|
|
|
|
namespace.users_with_descendants.count
|
|
|
|
end
|
|
|
|
|
|
|
|
def expose_members_count_with_descendants?(namespace, opts)
|
|
|
|
namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-02-17 12:09:20 +00:00
|
|
|
|
2021-05-11 21:10:21 +00:00
|
|
|
API::Entities::Namespace.prepend_mod_with('API::Entities::Namespace')
|