diff --git a/app/reflexes/application_reflex.rb b/app/reflexes/application_reflex.rb index ff41bf8288..4ed251f8bb 100644 --- a/app/reflexes/application_reflex.rb +++ b/app/reflexes/application_reflex.rb @@ -20,6 +20,8 @@ class ApplicationReflex < StimulusReflex::Reflex delegate :current_user, to: :connection + private + def current_ability Spree::Ability.new(current_user) end @@ -27,4 +29,8 @@ class ApplicationReflex < StimulusReflex::Reflex def with_locale(&block) I18n.with_locale(current_user.locale, &block) end + + def morph_admin_flashes + morph "#flashes", render(partial: "admin/shared/flashes", locals: { flashes: flash }) + end end diff --git a/app/reflexes/white_label_reflex.rb b/app/reflexes/white_label_reflex.rb index 667ed98912..140079add6 100644 --- a/app/reflexes/white_label_reflex.rb +++ b/app/reflexes/white_label_reflex.rb @@ -21,6 +21,6 @@ class WhiteLabelReflex < ApplicationReflex I18n.t("admin.enterprises.form.white_label.remove_logo_success") } cable_ready.dispatch_event(name: "modal:close") - morph "#flashes", render(partial: "shared/flashes", locals: { flashes: flash }) + morph_admin_flashes end end diff --git a/app/views/admin/shared/_flashes.html.haml b/app/views/admin/shared/_flashes.html.haml new file mode 100644 index 0000000000..57673b3f48 --- /dev/null +++ b/app/views/admin/shared/_flashes.html.haml @@ -0,0 +1,6 @@ +#flashes + - if defined? flashes + - flashes.each do |type, msg| + .animate-show{"data-controller": "flash"} + .flash{type: "#{type}", class: "#{type}"} + %span= msg diff --git a/app/views/spree/layouts/_admin_body.html.haml b/app/views/spree/layouts/_admin_body.html.haml index f43eb3452e..e0710fdf36 100644 --- a/app/views/spree/layouts/_admin_body.html.haml +++ b/app/views/spree/layouts/_admin_body.html.haml @@ -4,14 +4,7 @@ #wrapper .flash-container - - if flash[:error] - .flash.error= flash[:error] - - if notice - .flash.notice= notice - - if flash[:success] - .flash.success= flash[:success] - - = render partial: "shared/flashes" + = render partial: "admin/shared/flashes", locals: { flashes: flash } = render partial: "spree/layouts/admin/progress_spinner" diff --git a/app/views/spree/layouts/bare_admin.html.haml b/app/views/spree/layouts/bare_admin.html.haml index db744183f1..39fe796f84 100644 --- a/app/views/spree/layouts/bare_admin.html.haml +++ b/app/views/spree/layouts/bare_admin.html.haml @@ -2,12 +2,8 @@ %head= render :partial => 'spree/admin/shared/head' %body.admin{"data-turbo": "false", "data-ajax-root-path": main_app.root_path} #wrapper - - if flash[:error] - .flash.error= flash[:error] - - if notice - .flash.notice= notice - - if flash[:success] - .flash.success= flash[:success] + = render partial: "admin/shared/flashes", locals: { flashes: flash } + = render partial: "spree/layouts/admin/progress_spinner" %header#header