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:
authorRémy Coutable <remy@rymai.me>2017-07-06 19:57:02 +0300
committerRémy Coutable <remy@rymai.me>2017-07-06 19:57:02 +0300
commit040eeb1039b4298ea56a670a0a4ae511288806d6 (patch)
tree6777d4d6c4fb1322f0d6ef7c4d2a59195aef3255 /app/models/application_setting.rb
parentde9eca0af65e8fd235aed8c9ea598f16562956e7 (diff)
Allow to enable the Performance Bar for a group from the admin area
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/application_setting.rb')
-rw-r--r--app/models/application_setting.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 668caef0d2c..c6d8e45c86d 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -234,6 +234,7 @@ class ApplicationSetting < ActiveRecord::Base
koding_url: nil,
max_artifacts_size: Settings.artifacts['max_size'],
max_attachment_size: Settings.gitlab['max_attachment_size'],
+ performance_bar_allowed_group_id: nil,
plantuml_enabled: false,
plantuml_url: nil,
recaptcha_enabled: false,
@@ -336,6 +337,42 @@ class ApplicationSetting < ActiveRecord::Base
super(levels.map { |level| Gitlab::VisibilityLevel.level_value(level) })
end
+ def performance_bar_allowed_group_id=(group_full_path)
+ group = Group.find_by_full_path(group_full_path)
+ return unless group && group.id != performance_bar_allowed_group_id
+
+ super(group.id)
+ Gitlab::PerformanceBar.expire_allowed_user_ids_cache
+ end
+
+ def performance_bar_allowed_group
+ Group.find_by_id(performance_bar_allowed_group_id)
+ end
+
+ # Return true is the Performance Bar is available globally or for the
+ # `performance_team` feature group
+ def performance_bar_enabled?
+ feature = Feature.get(:performance_bar)
+
+ feature.on? || feature.groups_value.include?('performance_team')
+ end
+
+ # - If `enable` is true, enable the `performance_bar` feature for the
+ # `performance_team` feature group
+ # - If `enable` is false, disable the `performance_bar` feature globally
+ def performance_bar_enabled=(enable)
+ feature = Feature.get(:performance_bar)
+ performance_bar_on = performance_bar_enabled?
+
+ if enable && !performance_bar_on
+ feature.enable_group(:performance_team)
+ Gitlab::PerformanceBar.expire_allowed_user_ids_cache
+ elsif !enable && performance_bar_on
+ feature.disable
+ Gitlab::PerformanceBar.expire_allowed_user_ids_cache
+ end
+ end
+
# Choose one of the available repository storage options. Currently all have
# equal weighting.
def pick_repository_storage