mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Simplify theme and color scheme seeding (#10872)
Now that we have support for user-selectable color schemes, it makes sense to simplify seeding and theme updates in the wizard. We now: - seed only one theme, named "Default" (previously "Light") - seed a user-selectable Dark color scheme - rename the "Themes" wizard step to "Colors" - update the default theme's color scheme if a default is set (a new theme is created if there is no default)
This commit is contained in:
@ -181,26 +181,22 @@ class Wizard
|
||||
next unless scheme_name.present? && ColorScheme.is_base?(scheme_name)
|
||||
|
||||
name = I18n.t("color_schemes.#{scheme_name.downcase.gsub(' ', '_')}_theme_name")
|
||||
theme = nil
|
||||
|
||||
scheme = ColorScheme.find_by(base_scheme_id: scheme_name, via_wizard: true)
|
||||
is_light_theme = (scheme_name == ColorScheme::LIGHT_THEME_ID)
|
||||
scheme ||= ColorScheme.create_from_base(name: name, via_wizard: true, base_scheme_id: scheme_name)
|
||||
|
||||
themes = Theme.where(color_scheme_id: scheme.id).order(:id).to_a
|
||||
if is_light_theme
|
||||
themes = (themes || []).concat(Theme.where(color_scheme_id: nil).order(:id).to_a)
|
||||
themes.sort_by(&:id)
|
||||
if default_theme
|
||||
default_theme.color_scheme_id = scheme.id
|
||||
default_theme.save!
|
||||
else
|
||||
theme = Theme.create!(
|
||||
name: name,
|
||||
user_id: @wizard.user.id,
|
||||
color_scheme_id: scheme.id
|
||||
)
|
||||
|
||||
theme.set_default!
|
||||
end
|
||||
theme = themes.find(&:default?)
|
||||
theme ||= themes.first
|
||||
|
||||
theme ||= Theme.create!(
|
||||
name: name,
|
||||
user_id: @wizard.user.id,
|
||||
color_scheme_id: scheme.id
|
||||
)
|
||||
|
||||
theme.set_default!
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user