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
path: root/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-25 19:44:15 +0300
committerRémy Coutable <remy@rymai.me>2018-05-29 11:38:59 +0300
commit2b8eb7273efee84180b322a0aac33e1f4ee30d2c (patch)
tree9afd597903504acf183d93505e6c19aabea1207a /lib
parentc5adf04cd69035a7a1737df8c2303bc228ea4089 (diff)
Ensure ApplicationSetting#performance_bar_allowed_group_id is properly set when retrieved from cache
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb12
-rw-r--r--lib/api/settings.rb20
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3e615f7ac05..3688b44b8df 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -933,8 +933,16 @@ module API
end
class ApplicationSetting < Grape::Entity
- expose :id
- expose(*::ApplicationSettingsHelper.visible_attributes)
+ def self.exposed_attributes
+ attributes = ::ApplicationSettingsHelper.visible_attributes
+ attributes.delete(:performance_bar_allowed_group_path)
+ attributes.delete(:performance_bar_enabled)
+
+ attributes
+ end
+
+ expose :id, :performance_bar_allowed_group_id
+ expose(*exposed_attributes)
expose(:restricted_visibility_levels) do |setting, _options|
setting.restricted_visibility_levels.map { |level| Gitlab::VisibilityLevel.string_level(level) }
end
diff --git a/lib/api/settings.rb b/lib/api/settings.rb
index e31c332b6e4..7e739fb6b0e 100644
--- a/lib/api/settings.rb
+++ b/lib/api/settings.rb
@@ -49,6 +49,9 @@ module API
optional :signin_enabled, type: Boolean, desc: 'Flag indicating if password authentication is enabled for the web interface' # support legacy names, can be removed in v5
mutually_exclusive :password_authentication_enabled_for_web, :password_authentication_enabled, :signin_enabled
optional :password_authentication_enabled_for_git, type: Boolean, desc: 'Flag indicating if password authentication is enabled for Git over HTTP(S)'
+ optional :performance_bar_allowed_group_path, type: String, desc: 'Path of the group that is allowed to toggle the performance bar.'
+ optional :performance_bar_allowed_group_id, type: String, desc: 'Depreated: Use :performance_bar_allowed_group_path instead. Path of the group that is allowed to toggle the performance bar.' # support legacy names, can be removed in v6
+ optional :performance_bar_enabled, type: String, desc: 'Deprecated: Pass `performance_bar_allowed_group_path: nil` instead. Allow enabling the performance.' # support legacy names, can be removed in v6
optional :require_two_factor_authentication, type: Boolean, desc: 'Require all users to setup Two-factor authentication'
given require_two_factor_authentication: ->(val) { val } do
requires :two_factor_grace_period, type: Integer, desc: 'Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication'
@@ -134,12 +137,25 @@ module API
desc: "Restrictions on the complexity of uploaded #{type.upcase} keys. A value of #{ApplicationSetting::FORBIDDEN_KEY_VALUE} disables all #{type.upcase} keys."
end
- optional(*::ApplicationSettingsHelper.visible_attributes)
- at_least_one_of(*::ApplicationSettingsHelper.visible_attributes)
+ optional_attributes = ::ApplicationSettingsHelper.visible_attributes << :performance_bar_allowed_group_id
+
+ optional(*optional_attributes)
+ at_least_one_of(*optional_attributes)
end
put "application/settings" do
attrs = declared_params(include_missing: false)
+ # support legacy names, can be removed in v6
+ if attrs.has_key?(:performance_bar_allowed_group_id)
+ attrs[:performance_bar_allowed_group_path] = attrs.delete(:performance_bar_allowed_group_id)
+ end
+
+ # support legacy names, can be removed in v6
+ if attrs.has_key?(:performance_bar_enabled)
+ performance_bar_enabled = attrs.delete(:performance_bar_allowed_group_id)
+ attrs[:performance_bar_allowed_group_path] = nil unless performance_bar_enabled
+ end
+
# support legacy names, can be removed in v5
if attrs.has_key?(:signin_enabled)
attrs[:password_authentication_enabled_for_web] = attrs.delete(:signin_enabled)