mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
Adds an optional `hide_settings:` key to `upcoming_change` metadata in `site_settings.yml`. It declares other site settings that should be hidden from admins while the change is enabled (manual opt-in or auto-promotion) — useful for legacy settings that stop making sense once the change replaces them. The hidden set is computed live by `UpcomingChanges.settings_hidden_while_enabled` and consulted by `SiteSettings::HiddenProvider#all`, rather than toggled imperatively at opt-in time. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
958 B
Ruby
Vendored
32 lines
958 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module SiteSettings
|
|
end
|
|
|
|
# A class to store and modify hidden site settings
|
|
class SiteSettings::HiddenProvider
|
|
def initialize
|
|
@hidden_settings = Set.new
|
|
end
|
|
|
|
def add_hidden(site_setting_name)
|
|
@hidden_settings << site_setting_name
|
|
end
|
|
|
|
def remove_hidden(site_setting_name)
|
|
@hidden_settings.delete(site_setting_name)
|
|
end
|
|
|
|
def all
|
|
hidden = @hidden_settings
|
|
|
|
# Settings hidden because an upcoming change that replaces them is enabled.
|
|
# Unioned before the modifier so plugins can still explicitly un-hide a
|
|
# setting via the :hidden_site_settings modifier. Skipped entirely when no
|
|
# change opts in, to avoid allocating a new Set on every read.
|
|
upcoming_change_hidden = UpcomingChanges.settings_hidden_while_enabled
|
|
hidden = hidden | upcoming_change_hidden if upcoming_change_hidden.present?
|
|
|
|
DiscoursePluginRegistry.apply_modifier(:hidden_site_settings, hidden)
|
|
end
|
|
end
|