mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 06:49:30 +08:00
DEV: allow the plugin to register valid site setting areas (#29432)
In this PR, we defined the ability to group site settings by area - https://github.com/discourse/discourse/pull/28570 Plugins should be able to register in their own areas.
This commit is contained in:

committed by
GitHub

parent
4529b0614c
commit
0839bce7b6
@ -523,6 +523,10 @@ module SiteSettingExtension
|
||||
end
|
||||
end
|
||||
|
||||
def valid_areas
|
||||
Set.new(SiteSetting::VALID_AREAS | DiscoursePluginRegistry.site_setting_areas.to_a)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def clear_cache!
|
||||
@ -695,9 +699,9 @@ module SiteSettingExtension
|
||||
|
||||
if opts[:area]
|
||||
split_areas = opts[:area].split("|")
|
||||
if split_areas.any? { |area| !SiteSetting::VALID_AREAS.include?(area) }
|
||||
if split_areas.any? { |area| !SiteSetting.valid_areas.include?(area) }
|
||||
raise Discourse::InvalidParameters.new(
|
||||
"Area is incorrect. Valid areas: #{SiteSetting::VALID_AREAS.join(", ")}",
|
||||
"Area is invalid, valid areas are: #{SiteSetting.valid_areas.join(", ")}",
|
||||
)
|
||||
end
|
||||
areas[name] = split_areas
|
||||
|
Reference in New Issue
Block a user