From 7820686f7397ea946e16d94f63b679468cc1f7d5 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Tue, 26 May 2020 12:56:36 -0500 Subject: [PATCH] FIX: Wizard previews if color step is excluded (#9881) --- app/assets/javascripts/wizard/models/wizard.js | 2 +- app/serializers/wizard_serializer.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/wizard/models/wizard.js b/app/assets/javascripts/wizard/models/wizard.js index e907687e11a..69d166bf7a0 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 d830ad73256..6ffe49a1f93 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