mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Move config area site setting fetch into new controller (#28136)
Followup 4aea12fdcb
In certain config areas (like About) we want to be able
to fetch specific site settings by name. In this case,
sometimes we need to be able to fetch hidden settings,
in cases where a config area is still experimental.
Splitting out a different endpoint for this purpose
allows us to be stricter with what we return for config
areas without affecting the main site settings UI, revealing
hidden settings before they are ready.
This commit is contained in:
27
app/controllers/admin/config/site_settings_controller.rb
Normal file
27
app/controllers/admin/config/site_settings_controller.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Admin::Config::SiteSettingsController < Admin::AdminController
|
||||
ADMIN_CONFIG_AREA_ALLOWLISTED_HIDDEN_SETTINGS = %i[
|
||||
extended_site_description
|
||||
about_banner_image
|
||||
community_owner
|
||||
]
|
||||
|
||||
# This endpoint is intended to be used only for admin config areas,
|
||||
# for a specific collection of site settings. The admin site settings
|
||||
# UI itself uses the Admin::SiteSettingsController#index endpoint,
|
||||
# which also supports a `category` and `plugin` filter.
|
||||
def index
|
||||
params.require(:filter_names)
|
||||
|
||||
render_json_dump(
|
||||
site_settings:
|
||||
SiteSetting.all_settings(
|
||||
filter_names: params[:filter_names],
|
||||
include_locale_setting: false,
|
||||
include_hidden: true,
|
||||
filter_allowed_hidden: ADMIN_CONFIG_AREA_ALLOWLISTED_HIDDEN_SETTINGS,
|
||||
),
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -5,25 +5,14 @@ class Admin::SiteSettingsController < Admin::AdminController
|
||||
render_json_error e.message, status: 422
|
||||
end
|
||||
|
||||
ADMIN_CONFIG_AREA_ALLOWLISTED_HIDDEN_SETTINGS = %i[
|
||||
extended_site_description
|
||||
about_banner_image
|
||||
community_owner
|
||||
]
|
||||
|
||||
def index
|
||||
params.permit(:categories, :plugin)
|
||||
params.permit(:filter_names, [])
|
||||
|
||||
render_json_dump(
|
||||
site_settings:
|
||||
SiteSetting.all_settings(
|
||||
filter_categories: params[:categories],
|
||||
filter_plugin: params[:plugin],
|
||||
filter_names: params[:filter_names],
|
||||
include_locale_setting: params[:filter_names].blank?,
|
||||
include_hidden: true,
|
||||
filter_allowed_hidden: ADMIN_CONFIG_AREA_ALLOWLISTED_HIDDEN_SETTINGS,
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user