mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
FEATURE: Introduce site settings which require confirmation (#27315)
Many site settings can be distructive or have huge side-effects for a site that the admin may not be aware of when changing it. This commit introduces a `requires_confirmation` attribute that can be added to any site setting. When it is true, a confirmation dialog will open if that setting is changed in the admin UI, optionally with a custom message that is defined in client.en.yml. If the admin does not confirm, we reset the setting to its previous clean value and do not save the new value.
This commit is contained in:
@ -892,6 +892,24 @@ RSpec.describe SiteSettingExtension do
|
||||
end
|
||||
end
|
||||
|
||||
describe "requires_confirmation settings" do
|
||||
it "returns 'simple' for settings that require confirmation with 'simple' type" do
|
||||
expect(
|
||||
SiteSetting.all_settings.find { |s| s[:setting] == :min_password_length }[
|
||||
:requires_confirmation
|
||||
],
|
||||
).to eq("simple")
|
||||
end
|
||||
|
||||
it "returns nil for settings that do not require confirmation" do
|
||||
expect(
|
||||
SiteSetting.all_settings.find { |s| s[:setting] == :display_local_time_in_user_card }[
|
||||
:requires_confirmation
|
||||
],
|
||||
).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe "_map extension for list settings" do
|
||||
it "handles splitting group_list settings" do
|
||||
SiteSetting.personal_message_enabled_groups = "1|2"
|
||||
|
Reference in New Issue
Block a user