From 7cf99f2391af39e20d61fbcd990540a4ca2d8a97 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 15 Jun 2022 09:57:20 +0200 Subject: [PATCH] Final cherry pick fixes --- app/controllers/custom_wizard/wizard.rb | 8 +++----- plugin.rb | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/controllers/custom_wizard/wizard.rb b/app/controllers/custom_wizard/wizard.rb index 11df97d7..bb53670b 100644 --- a/app/controllers/custom_wizard/wizard.rb +++ b/app/controllers/custom_wizard/wizard.rb @@ -6,7 +6,7 @@ class CustomWizard::WizardController < ::ActionController::Base include CanonicalURL::ControllerExtensions include GlobalPath - prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'views')) + prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'app', 'views')) layout :set_wizard_layout before_action :preload_wizard_json @@ -47,10 +47,8 @@ class CustomWizard::WizardController < ::ActionController::Base result = { success: 'OK' } if current_user && wizard.can_access? - submission = wizard.current_submission - - if submission.present? && submission.redirect_to - result.merge!(redirect_to: submission.redirect_to) + if redirect_to = wizard.current_submission&.redirect_to + result.merge!(redirect_to: redirect_to) end wizard.cleanup_on_skip! diff --git a/plugin.rb b/plugin.rb index 6f5719fb..41d7a1db 100644 --- a/plugin.rb +++ b/plugin.rb @@ -52,6 +52,24 @@ class ::Sprockets::DirectiveProcessor end end +## Override necessary due to 'assets/javascripts/wizard', particularly its tests. +def each_globbed_asset + if @path + root_path = "#{File.dirname(@path)}/assets/javascripts/discourse" + + Dir.glob(["#{root_path}/**/*"]).sort.each do |f| + f_str = f.to_s + if File.directory?(f) + yield [f, true] + elsif f_str.end_with?(".js.es6") || f_str.end_with?(".hbs") || f_str.end_with?(".hbr") + yield [f, false] + elsif transpile_js && f_str.end_with?(".js") + yield [f, false] + end + end + end +end + after_initialize do %w[ ../lib/custom_wizard/engine.rb