mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
This commit introduces a `enable_horizon_high_context_topic_cards` upcoming change, which when enabled, will toggle the high context topic cards to enabled for the Horizon theme. Existing sites will have the option disabled by default with a legacy DB entry in the theme_settings table. New sites will have high context topic cards enabled by default via the theme settings yml file. The upcoming change is conditional: * On brand new sites, we do not need the Upcoming Change because they’ll be starting off with the new default. * On existing sites… * If Horizon is not in use (i.e. Theme is enabled by default and Theme can be selected by users are both disabled), we do not need the Upcoming Change. No one on the site is really impacted by this change. * If Horizon is the default theme (i.e. Theme is enabled by default is enabled; Theme can be selected by users is enabled or disabled), we do need the Upcoming Change. Many users on the site will be impacted by this change. * If Horizon is user-selectable but not the default theme (i.e. Theme is enabled by default is disabled but Theme can be selected by users is enabled), we do need the Upcoming Change. Perhaps not many users will be impacted, but there’s still some impact so I figure better to be safe.
35 lines
1.6 KiB
Ruby
Vendored
35 lines
1.6 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
Rails.application.config.after_initialize { UpcomingChanges.clear_caches! }
|
|
|
|
#
|
|
# Similar to 014-track-setting-changes.rb, we can react to upcoming changes
|
|
# being enabled/or disabled here for more complicated scenarios, where
|
|
# we are not just changing UI or behaviour when the state of the underlying
|
|
# setting is changed.
|
|
#
|
|
# We need to do this separately from 014-track-setting-changes.rb because
|
|
# we don't actually change the underlying setting value in the database
|
|
# when an upcoming change is automatically promoted. See UpcomingChanges::NotifyPromotions
|
|
# for further context.
|
|
#
|
|
# We do also send these events when admins manually opt-in or opt-out of an upcoming change
|
|
# via the UI and the UpcomingChanges::Toggle service.
|
|
|
|
DiscourseEvent.on(:upcoming_change_enabled) do |setting_name|
|
|
# Respond to event here, e.g. if setting_name == :enable_form_templates do X.
|
|
if setting_name == :simple_email_subject
|
|
SiteSetting::Action::SimpleEmailSubjectToggled.call(params: { setting_enabled: true })
|
|
elsif setting_name == :enable_horizon_high_context_topic_cards
|
|
Themes::Action::HorizonHighContextTopicCardsToggled.call(enabled: true)
|
|
end
|
|
end
|
|
|
|
DiscourseEvent.on(:upcoming_change_disabled) do |setting_name|
|
|
# Respond to event here, e.g. if setting_name == :enable_form_templates do X.
|
|
if setting_name == :simple_email_subject
|
|
SiteSetting::Action::SimpleEmailSubjectToggled.call(params: { setting_enabled: false })
|
|
elsif setting_name == :enable_horizon_high_context_topic_cards
|
|
Themes::Action::HorizonHighContextTopicCardsToggled.call(enabled: false)
|
|
end
|
|
end
|