mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 23:00:09 +08:00
Our UpcomingChangeStableOptedOut problem check was showing problems on brand new sites, when it should only show a problem after admin has opted out of a stable upcoming change. This was happening because on some sites a plugin might be disabled or not configurable, so it would return false when calling `SiteSetting.send(change_name)`, but crucially we weren't filtering out upcoming changes that shouldn't display on the site. This commit fixes the issue by returning no problem if the upcoming change is not configured to display on the site.
29 lines
1,017 B
Ruby
Vendored
29 lines
1,017 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class ProblemCheck::UpcomingChangeStableOptedOut < ProblemCheck
|
|
self.perform_every = 1.hour
|
|
self.targets = -> { SiteSetting.upcoming_change_site_settings }
|
|
|
|
def call
|
|
return no_problem if !UpcomingChanges::ConditionalDisplay.should_display?(target)
|
|
|
|
# If the site setting is enabled, then the change is opted in, either
|
|
# manually or automatically, so we skip it.
|
|
return no_problem if UpcomingChanges.enabled?(target)
|
|
|
|
# Don't care about any changes that are not yet stable, admins can opt
|
|
# in and out of these without worry.
|
|
return no_problem if UpcomingChanges.not_yet_stable?(target)
|
|
|
|
# At this point, we have an upcoming change that is stable or permanent,
|
|
# and the site is opted out of it. Admins need to know that the change
|
|
# will either become permanent or be removed soon.
|
|
problem(target)
|
|
end
|
|
|
|
private
|
|
|
|
def translation_data(upcoming_change)
|
|
{ upcoming_change: SiteSetting.humanized_name(upcoming_change) }
|
|
end
|
|
end
|