From 8d0383c6f89353feeac174e05659780559547e6e Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 19 Apr 2022 12:27:38 +0200 Subject: [PATCH] refactor(turbo): use turbo in root controller --- app/controllers/root_controller.rb | 2 +- app/views/layouts/_outdated_browser_banner.html.haml | 2 +- app/views/root/dismiss_outdated_browser.turbo_stream.haml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 app/views/root/dismiss_outdated_browser.turbo_stream.haml diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 8a35c774c..0e1335ef3 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -84,7 +84,7 @@ class RootController < ApplicationController respond_to do |format| format.html { redirect_back(fallback_location: root_path) } - format.js { render js: helpers.remove_element('#outdated-browser-banner') } + format.turbo_stream end end diff --git a/app/views/layouts/_outdated_browser_banner.html.haml b/app/views/layouts/_outdated_browser_banner.html.haml index 5efc631c2..e1ad0350a 100644 --- a/app/views/layouts/_outdated_browser_banner.html.haml +++ b/app/views/layouts/_outdated_browser_banner.html.haml @@ -16,6 +16,6 @@ %br Certaines parties du site ne fonctionneront pas correctement. .site-banner-actions - = button_to 'Ignorer', dismiss_outdated_browser_path, method: :post, remote: true, class: 'button btn', title: 'Ne plus afficher cet avertissement pendant une semaine' + = button_to 'Ignorer', dismiss_outdated_browser_path, method: :post, form: { data: { turbo: true } }, class: 'button btn', title: 'Ne plus afficher cet avertissement pendant une semaine' %a.btn.button.primary{ href: "https://browser-update.org/fr/update.html", target: "_blank", rel: "noopener" } Mettre à jour mon navigateur diff --git a/app/views/root/dismiss_outdated_browser.turbo_stream.haml b/app/views/root/dismiss_outdated_browser.turbo_stream.haml new file mode 100644 index 000000000..e95546cc5 --- /dev/null +++ b/app/views/root/dismiss_outdated_browser.turbo_stream.haml @@ -0,0 +1 @@ += turbo_stream.remove('outdated-browser-banner')