summaryrefslogtreecommitdiff
path: root/lib/gitlab/performance_bar.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-06-21 16:59:13 +0200
committerRémy Coutable <remy@rymai.me>2017-07-06 11:18:25 +0200
commit186048a404b2f5b84f4472a7d05cbb2309b1e9bf (patch)
tree8e850caf2a8315b799ee36cfd6be34f230d85b4d /lib/gitlab/performance_bar.rb
parentafd5c34d9f1bf5ad7d85209dfecbaf28c6c12496 (diff)
downloadgitlab-ce-186048a404b2f5b84f4472a7d05cbb2309b1e9bf.tar.gz
Allow to enable the performance bar per user or Flipper group
A `performance_team` Flipper group has been created. By default this group is nil but this can be customized in `gitlab.yml` via the performance_bar.allowed_group setting. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/gitlab/performance_bar.rb')
-rw-r--r--lib/gitlab/performance_bar.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb
index 163a40ad306..2ca2cbeac08 100644
--- a/lib/gitlab/performance_bar.rb
+++ b/lib/gitlab/performance_bar.rb
@@ -1,7 +1,23 @@
module Gitlab
module PerformanceBar
- def self.enabled?
- Feature.enabled?('gitlab_performance_bar')
+ def self.enabled?(current_user = nil)
+ Feature.enabled?(:gitlab_performance_bar, current_user)
+ end
+
+ def self.allowed_actor?(actor)
+ group = allowed_group
+ return false unless actor&.is_a?(User) && group
+
+ GroupMembersFinder.new(group)
+ .execute
+ .where(user_id: actor.id)
+ .any?
+ end
+
+ def self.allowed_group
+ return nil unless Gitlab.config.performance_bar.allowed_group
+
+ Group.by_path(Gitlab.config.performance_bar.allowed_group)
end
end
end