DEV: Move sidebar site settings to the sidebar category (#18596)

Sidebar category is only shown in the admin panel when `enable_experimental_sidebar_hamburger` site setting is enabled
This commit is contained in:
Alan Guo Xiang Tan 2022-10-17 10:33:15 +08:00 committed by GitHub
parent 3d59f767ae
commit d1304ecb46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 34 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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