Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/entities/namespace.rb')
-rw-r--r--lib/api/entities/namespace.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/api/entities/namespace.rb b/lib/api/entities/namespace.rb
new file mode 100644
index 00000000000..b21dd29c7b4
--- /dev/null
+++ b/lib/api/entities/namespace.rb
@@ -0,0 +1,15 @@
+# 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