DEV: enable Foundation and stop Default (#33508)

Reveal Foundation theme and stop creating a Default for new instances.
Instead, the Foundation should be set as the default.
This commit is contained in:
Krzysztof Kotlarek
2025-07-14 15:35:07 +08:00
committed by GitHub
parent d164351458
commit 699f35aa70
13 changed files with 22 additions and 98 deletions
@@ -4,10 +4,7 @@ class Admin::ColorSchemesController < Admin::AdminController
before_action :fetch_color_scheme, only: %i[update destroy]
def index
schemes =
ColorScheme.without_theme_owned_palettes.with_experimental_system_theme_palettes.order(
"color_schemes.id ASC",
)
schemes = ColorScheme.without_theme_owned_palettes.order("color_schemes.id ASC")
schemes = schemes.where(theme_id: nil) if params[:exclude_theme_owned]
@@ -8,7 +8,6 @@ class Admin::Config::CustomizeController < Admin::AdminController
Theme
.include_basic_relations
.includes(:theme_fields, color_scheme: [:color_scheme_colors])
.with_experimental_system_themes
.where(component: false)
.order(:name)
+1 -2
View File
@@ -170,14 +170,13 @@ class Admin::ThemesController < Admin::AdminController
end
def index
@themes = Theme.with_experimental_system_themes.strict_loading.include_relations.order(:name)
@themes = Theme.strict_loading.include_relations.order(:name)
@color_schemes =
ColorScheme
.strict_loading
.all
.without_theme_owned_palettes
.with_experimental_system_theme_palettes
.includes(:theme, color_scheme_colors: :color_scheme)
.to_a
-8
View File
@@ -318,14 +318,6 @@ class ColorScheme < ActiveRecord::Base
scope :without_theme_owned_palettes,
-> { where("color_schemes.id NOT IN (SELECT color_scheme_id FROM theme_color_schemes)") }
scope :with_experimental_system_theme_palettes,
-> do
joins("LEFT JOIN themes on themes.id = color_schemes.theme_id").where(
"themes.id is NULL OR themes.id > 0 OR themes.id IN (?)",
Theme.experimental_system_theme_ids,
)
end
validates_associated :color_scheme_colors
BASE_COLORS_FILE = "#{Rails.root}/app/assets/stylesheets/common/foundation/colors.scss"
-8
View File
@@ -128,8 +128,6 @@ class Theme < ActiveRecord::Base
scope :not_system, -> { where("id > 0") }
scope :system, -> { where("id < 0") }
scope :with_experimental_system_themes,
-> { where("id > 0 OR id IN (?)", Theme.experimental_system_theme_ids) }
delegate :remote_url, to: :remote_theme, private: true, allow_nil: true
@@ -348,12 +346,6 @@ class Theme < ActiveRecord::Base
end
end
def self.experimental_system_theme_ids
Theme::CORE_THEMES
.select { |k, v| SiteSetting.experimental_system_themes_map.include?(k) }
.values
end
def set_default!
if component
raise Discourse::InvalidParameters.new(I18n.t("themes.errors.component_no_default"))
-1
View File
@@ -4677,7 +4677,6 @@ en:
solarized_dark_theme_name: "Solarized Dark"
wcag_dark: "WCAG Dark"
wcag_dark_theme_name: "WCAG Dark"
default_theme_name: "Default"
light_theme_name: "Light"
dark_theme_name: "Dark"
neutral_theme_name: "Neutral"
-8
View File
@@ -4071,11 +4071,3 @@ experimental:
client: true
type: group_list
default: ""
experimental_system_themes:
type: list
default: "horizon"
hidden: true
allow_any: false
choices:
- "foundation"
- "horizon"
+6 -6
View File
@@ -1,7 +1,11 @@
# frozen_string_literal: true
theme_exists = Theme.exists?
SystemThemesManager.sync!
# we can not guess what to do if customization already started, so skip it
if !Theme.exists?
if !theme_exists
STDERR.puts "> Seeding theme and color schemes"
color_schemes = [
@@ -24,9 +28,7 @@ if !Theme.exists?
)
end
name = I18n.t("color_schemes.default_theme_name")
default_theme = Theme.create!(name: name, user_id: Discourse::SYSTEM_USER_ID)
default_theme.set_default!
Theme.foundation_theme.set_default!
if SiteSetting.default_dark_mode_color_scheme_id ==
SiteSetting.defaults[:default_dark_mode_color_scheme_id]
@@ -35,5 +37,3 @@ if !Theme.exists?
SiteSetting.default_dark_mode_color_scheme_id = dark_scheme_id if dark_scheme_id.present?
end
end
SystemThemesManager.sync!
@@ -0,0 +1,10 @@
# frozen_string_literal: true
class RemoveExperimentalSystemThemesSiteSetting < ActiveRecord::Migration[7.2]
def up
execute "DELETE FROM site_settings WHERE name = 'experimental_system_themes'"
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
+1 -1
View File
@@ -234,7 +234,7 @@ HTML
f =
ThemeField.create!(
target_id: Theme.targets[:mobile],
theme_id: 1,
theme_id: -1,
name: "after_header",
value: html,
)
@@ -32,20 +32,6 @@ RSpec.describe Admin::ColorSchemesController do
expect(scheme_colors[0]["hex"]).to eq(base_scheme_colors[0].hex)
end
it "filters colors belonging to experimental system themes" do
SiteSetting.experimental_system_themes = ""
get "/admin/color_schemes.json"
expect(response.status).to eq(200)
scheme_names = response.parsed_body.map { |scheme| scheme["name"] }
expect(scheme_names).not_to include("Horizon")
SiteSetting.experimental_system_themes = "horizon"
get "/admin/color_schemes.json"
expect(response.status).to eq(200)
scheme_names = response.parsed_body.map { |scheme| scheme["name"] }
expect(scheme_names).to include("Horizon")
end
it "serializes default colors even when not present in database" do
scheme = ColorScheme.create_from_base({ name: "my color scheme" })
scheme.colors.find_by(name: "primary").destroy!
@@ -510,26 +510,6 @@ RSpec.describe Admin::ThemesController do
expect(theme_json["remote_theme"]["remote_version"]).to eq("7")
end
it "filters experimental system themes" do
SiteSetting.experimental_system_themes = ""
get "/admin/themes.json"
expect(response.status).to eq(200)
theme_names = response.parsed_body["themes"].map { |theme| theme[:name] }
color_scheme_names =
response.parsed_body["extras"]["color_schemes"].map { |scheme| scheme[:name] }
expect(theme_names).not_to include("Horizon")
expect(color_scheme_names).not_to include("Horizon")
SiteSetting.experimental_system_themes = "horizon"
get "/admin/themes.json"
expect(response.status).to eq(200)
theme_names = response.parsed_body["themes"].map { |t| t[:name] }
color_scheme_names =
response.parsed_body["extras"]["color_schemes"].map { |scheme| scheme[:name] }
expect(theme_names).to include("Horizon")
expect(color_scheme_names).to include("Horizon")
end
it "does not result in N+1 queries" do
# warmup
get "/admin/themes.json"
@@ -3,8 +3,8 @@
describe "Admin Customize Themes Config Area Page", type: :system do
fab!(:admin)
fab!(:theme) { Fabricate(:theme, name: "First theme") }
fab!(:default_theme) { Theme.where(component: false, name: "Default").first }
fab!(:foundation_theme) { Theme.foundation_theme }
fab!(:horizon_theme) { Theme.horizon_theme }
fab!(:theme_child_theme) do
Fabricate(:theme, name: "Child theme", component: true, enabled: true, parent_themes: [theme])
end
@@ -14,10 +14,7 @@ describe "Admin Customize Themes Config Area Page", type: :system do
let(:install_modal) { PageObjects::Modals::InstallTheme.new }
let(:admin_customize_themes_page) { PageObjects::Pages::AdminCustomizeThemes.new }
before do
SiteSetting.experimental_system_themes = "foundation|horizon"
sign_in(admin)
end
before { sign_in(admin) }
it "has an install button in the subheader" do
config_area.visit
@@ -42,14 +39,11 @@ describe "Admin Customize Themes Config Area Page", type: :system do
it "allows to mark theme as active" do
config_area.visit
expect(config_area).to have_badge(default_theme, "--active")
expect(config_area).to have_badge(foundation_theme, "--active")
expect(config_area).to have_no_badge(theme_2, "--active")
config_area.mark_as_active(theme_2)
expect(config_area).to have_badge(theme_2, "--active")
expect(config_area).to have_no_badge(foundation_theme, "--active")
expect(config_area).to have_themes(
["Second theme", "Horizon", "Foundation", "Default", "First theme"],
)
end
it "allows to make theme selectable by users" do
@@ -81,20 +75,4 @@ describe "Admin Customize Themes Config Area Page", type: :system do
I18n.t("admin_js.admin.config_areas.themes_and_components.themes.title"),
)
end
it "allows controlling visibility of system themes with experimental_system_themes setting" do
SiteSetting.experimental_system_themes = ""
config_area.visit
expect(config_area).to have_themes(["Default", "First theme", "Second theme"])
SiteSetting.experimental_system_themes = "foundation"
config_area.visit
expect(config_area).to have_themes(["Default", "Foundation", "First theme", "Second theme"])
SiteSetting.experimental_system_themes = "foundation|horizon"
config_area.visit
expect(config_area).to have_themes(
["Default", "Horizon", "Foundation", "First theme", "Second theme"],
)
end
end