DEV: Allow fetching specific site settings and introduce a service for updating site settings (#27481)

This commit adds ability to fetch a subset of site settings from the `/admin/site_settings` endpoint so that it can be used in all places where the client app needs access to a subset of the site settings.

Additionally, this commit also introduces a new service class called `UpdateSiteSetting` that encapsulates all the logic that surrounds updating a site setting so that it can be used to update site setting(s) anywhere in the backend. This service comes in handy with, for example, the controller for the flags admin config area which may need to update some site settings related to flags.

Internal topic: t/130713.
This commit is contained in:
Osama Sayegh
2024-06-14 13:07:27 +03:00
committed by GitHub
parent 86e768f9e9
commit 4aea12fdcb
7 changed files with 351 additions and 180 deletions

View File

@ -185,7 +185,8 @@ module SiteSettingExtension
include_locale_setting: true,
only_overridden: false,
filter_categories: nil,
filter_plugin: nil
filter_plugin: nil,
filter_names: nil
)
locale_setting_hash = {
setting: "default_locale",
@ -256,6 +257,13 @@ module SiteSettingExtension
true
end
end
.select do |setting|
if filter_names
filter_names.include?(setting[:setting].to_s)
else
true
end
end
.unshift(include_locale_setting && !only_overridden ? locale_setting_hash : nil)
.compact
end