UX: Conditionally refresh page on wizard styling step (#31193)

Previously, were always forcing the page to reload
for the wizard after pressing Next for the styling step,
with the logic that if style changes are being made,
the admin needs to see them straight away.

However this doesn't make sense if nothing changes on
that step. This commit makes the change to only refresh
the page if any of the settings on the step changed,
bringing it in line with other steps.
This commit is contained in:
Martin Brennan
2025-02-06 10:31:22 +10:00
committed by GitHub
parent 1ab5bc2bad
commit 8f72a57363
3 changed files with 46 additions and 4 deletions

View File

@ -91,6 +91,7 @@ RSpec.describe Wizard::StepUpdater do
)
updater.update
expect(updater.success?).to eq(true)
expect(updater.refresh_required?).to eq(true)
expect(wizard.completed_steps?("styling")).to eq(true)
expect(SiteSetting.base_font).to eq("open_sans")
expect(SiteSetting.heading_font).to eq("oswald")
@ -100,11 +101,32 @@ RSpec.describe Wizard::StepUpdater do
updater = wizard.create_updater("styling", site_font: "open_sans", homepage_style: "latest")
updater.update
expect(updater.success?).to eq(true)
expect(updater.refresh_required?).to eq(true)
expect(wizard.completed_steps?("styling")).to eq(true)
expect(SiteSetting.base_font).to eq("open_sans")
expect(SiteSetting.heading_font).to eq("open_sans")
end
it "does not require refresh if the font, color scheme, or theme are unchanged" do
SiteSetting.base_font = "open_sans"
SiteSetting.heading_font = "open_sans"
SiteSetting.top_menu = "latest|categories|unread|top"
dark_scheme = ColorScheme.find_by(name: "Dark")
Theme.find_default.update!(color_scheme: dark_scheme)
SiteSetting.default_dark_mode_color_scheme_id = -1
updater =
wizard.create_updater(
"styling",
color_scheme: "Dark",
site_font: "open_sans",
heading_font: "open_sans",
homepage_style: "latest",
)
updater.update
expect(updater.success?).to eq(true)
expect(updater.refresh_required?).to eq(false)
end
context "with colors" do
context "with an existing color scheme" do
fab!(:color_scheme) { Fabricate(:color_scheme, name: "existing", via_wizard: true) }