FIX: Wizard previews if color step is excluded (#9881)

FIX: Wizard previews if color step is excluded (#9881)

diff --git a/app/assets/javascripts/wizard/models/wizard.js b/app/assets/javascripts/wizard/models/wizard.js
index e907687..69d166b 100644
--- a/app/assets/javascripts/wizard/models/wizard.js
+++ b/app/assets/javascripts/wizard/models/wizard.js
@@ -28,7 +28,7 @@ const Wizard = EmberObject.extend({
   getCurrentColors(schemeId) {
     const colorStep = this.steps.findBy("id", "colors");
     if (!colorStep) {
-      return;
+      return this.current_color_scheme;
     }
 
     const themeChoice = colorStep.get("fieldsById.theme_previews");
diff --git a/app/serializers/wizard_serializer.rb b/app/serializers/wizard_serializer.rb
index d830ad7..6ffe49a 100644
--- a/app/serializers/wizard_serializer.rb
+++ b/app/serializers/wizard_serializer.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class WizardSerializer < ApplicationSerializer
-  attributes :start, :completed
+  attributes :start, :completed, :current_color_scheme
 
   has_many :steps, serializer: WizardStepSerializer, embed: :objects
 
@@ -12,4 +12,14 @@ class WizardSerializer < ApplicationSerializer
   def completed
     object.completed?
   end
+
+  def current_color_scheme
+    color_scheme = Theme.find(SiteSetting.default_theme_id).color_scheme
+    colors = color_scheme ? color_scheme.colors : ColorScheme.base_colors
+
+    # The frontend expects the color hexs to start with '#'
+    colors_with_hash = {}
+    colors.each { |color, hex| colors_with_hash[color] = "##{hex}" }
+    colors_with_hash
+  end
 end

GitHub sha: 7820686f

1 Like

This commit appears in #9881 which was approved by eviltrout. It was merged by markvanlan.