diff --git a/config/site_settings.yml b/config/site_settings.yml index 7d6f03510cc..0ea994e947c 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -2033,6 +2033,18 @@ developer: default: false client: true hidden: true + enable_new_user_profile_nav_groups: + client: true + type: group_list + list_type: compact + default: "" + allow_any: false + refresh: true + include_associated_account_ids: + default: false + hidden: true + +sidebar: enable_sidebar: default: true client: true @@ -2044,16 +2056,6 @@ developer: type: tag_list default: "" client: true - enable_new_user_profile_nav_groups: - client: true - type: group_list - list_type: compact - default: "" - allow_any: false - refresh: true - include_associated_account_ids: - default: false - hidden: true embedding: embed_by_username: diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb index 0a5699bbc1d..4c215de835c 100644 --- a/lib/site_setting_extension.rb +++ b/lib/site_setting_extension.rb @@ -234,36 +234,42 @@ module SiteSettingExtension } defaults.all(default_locale) - .reject { |s, _| !include_hidden && hidden_settings.include?(s) } - .map do |s, v| + .reject do |setting_name, _| + if !include_hidden && hidden_settings.include?(setting_name) + true + elsif categories[setting_name].to_s == "sidebar" && !SiteSetting.enable_experimental_sidebar_hamburger + true + else + false + end + end.map do |s, v| + type_hash = type_supervisor.type_hash(s) + default = defaults.get(s, default_locale).to_s - type_hash = type_supervisor.type_hash(s) - default = defaults.get(s, default_locale).to_s + value = public_send(s) + value = value.map(&:to_s).join("|") if type_hash[:type].to_s == "uploaded_image_list" - value = public_send(s) - value = value.map(&:to_s).join("|") if type_hash[:type].to_s == "uploaded_image_list" + if type_hash[:type].to_s == "upload" && + default.to_i < Upload::SEEDED_ID_THRESHOLD - if type_hash[:type].to_s == "upload" && - default.to_i < Upload::SEEDED_ID_THRESHOLD + default = default_uploads[default.to_i] + end - default = default_uploads[default.to_i] - end + opts = { + setting: s, + description: description(s), + default: default, + value: value.to_s, + category: categories[s], + preview: previews[s], + secret: secret_settings.include?(s), + placeholder: placeholder(s) + }.merge!(type_hash) - opts = { - setting: s, - description: description(s), - default: default, - value: value.to_s, - category: categories[s], - preview: previews[s], - secret: secret_settings.include?(s), - placeholder: placeholder(s) - }.merge!(type_hash) + opts[:plugin] = plugins[s] if plugins[s] - opts[:plugin] = plugins[s] if plugins[s] - - opts - end.unshift(locale_setting_hash) + opts + end.unshift(locale_setting_hash) end def description(setting) diff --git a/spec/lib/site_setting_extension_spec.rb b/spec/lib/site_setting_extension_spec.rb index c26024b6728..ad39c656ef5 100644 --- a/spec/lib/site_setting_extension_spec.rb +++ b/spec/lib/site_setting_extension_spec.rb @@ -832,4 +832,24 @@ RSpec.describe SiteSettingExtension do end end end + + describe 'sidebar category site settings' do + describe '.all_settings' do + before do + settings.setting(:test_setting, 88, category: :sidebar) + end + + it 'does not include the sidebar category setting when enable_experimental_sidebar_hamburger site setting is disabled' do + SiteSetting.enable_experimental_sidebar_hamburger = false + + expect(settings.all_settings.detect { |s| s[:setting] == :test_setting }).to eq(nil) + end + + it 'includes the sidebar category setting when enable_experimental_sidebar_hamburger site setting is enabled' do + SiteSetting.enable_experimental_sidebar_hamburger = true + + expect(settings.all_settings.detect { |s| s[:setting] == :test_setting }[:setting]).to eq(:test_setting) + end + end + end end