Site settings: move category into the opts hash so that it's compatibale with existing plugins
This commit is contained in:
parent
e01ce546e8
commit
fc180ccd71
|
@ -9,9 +9,9 @@ class SiteSetting < ActiveRecord::Base
|
|||
|
||||
SiteSettings::YamlLoader.new("#{Rails.root}/config/site_settings.yml").load do |category, name, default, opts|
|
||||
if opts.delete(:client)
|
||||
client_setting(name, default, category)
|
||||
client_setting(name, default, opts.merge(category: category))
|
||||
else
|
||||
setting(name, default, category, opts)
|
||||
setting(name, default, opts.merge(category: category))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ module SiteSettingExtension
|
|||
@hidden_settings ||= []
|
||||
end
|
||||
|
||||
def setting(name_arg, default = nil, category = nil, opts = {})
|
||||
def setting(name_arg, default = nil, opts = {})
|
||||
name = name_arg.to_sym
|
||||
mutex.synchronize do
|
||||
self.defaults[name] = default
|
||||
categories[name] = category.try(:to_sym) || :uncategorized
|
||||
categories[name] = opts[:category] || :uncategorized
|
||||
current_value = current.has_key?(name) ? current[name] : default
|
||||
if opts[:enum]
|
||||
enum = opts[:enum]
|
||||
|
@ -60,8 +60,8 @@ module SiteSettingExtension
|
|||
end
|
||||
|
||||
# just like a setting, except that it is available in javascript via DiscourseSession
|
||||
def client_setting(name, default = nil, category = nil)
|
||||
setting(name, default, category)
|
||||
def client_setting(name, default = nil, opts = {})
|
||||
setting(name, default, opts)
|
||||
@@client_settings ||= []
|
||||
@@client_settings << name
|
||||
end
|
||||
|
|
|
@ -164,7 +164,7 @@ describe SiteSettingExtension do
|
|||
|
||||
describe 'a setting with a category' do
|
||||
before do
|
||||
settings.setting(:test_setting, 88, :tests)
|
||||
settings.setting(:test_setting, 88, {category: :tests})
|
||||
settings.refresh!
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue