From 9593e8825ffe4822cbaedba7c2c3d0458c5c344d Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 2 Apr 2024 21:30:38 +0200 Subject: [PATCH] chore(browser): be more agressive about browser deprecation --- app/controllers/root_controller.rb | 9 ----- app/helpers/application_helper.rb | 17 +------- .../_outdated_browser_banner.html.haml | 29 +++++--------- ...dismiss_outdated_browser.turbo_stream.haml | 1 - config/routes.rb | 1 - spec/system/outdated_browser_spec.rb | 39 +------------------ 6 files changed, 12 insertions(+), 84 deletions(-) delete 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 ed4a0bc28..156be590f 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -96,15 +96,6 @@ class RootController < ApplicationController def suivi end - def dismiss_outdated_browser - dismiss_outdated_browser_banner - - respond_to do |format| - format.html { redirect_back(fallback_location: root_path) } - format.turbo_stream - end - end - def save_locale set_locale(params[:locale]) redirect_back(fallback_location: root_path) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a93b202f2..3eb353398 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -122,23 +122,8 @@ module ApplicationHelper end end - def dismiss_outdated_browser_banner - cookies[:dismissed_outdated_browser_banner] = { - value: 'true', - expires: 1.week.from_now - } - end - - def has_dismissed_outdated_browser_banner? - cookies[:dismissed_outdated_browser_banner] == 'true' - end - - def supported_browser? - BrowserSupport.supported?(browser) - end - def show_outdated_browser_banner? - !supported_browser? && !has_dismissed_outdated_browser_banner? + !BrowserSupport.supported?(browser) end def vite_legacy? diff --git a/app/views/layouts/_outdated_browser_banner.html.haml b/app/views/layouts/_outdated_browser_banner.html.haml index 2f5948948..cbf9e91cd 100644 --- a/app/views/layouts/_outdated_browser_banner.html.haml +++ b/app/views/layouts/_outdated_browser_banner.html.haml @@ -1,21 +1,10 @@ - if show_outdated_browser_banner? - #outdated-browser-banner.site-banner - .container - .site-banner-icon ⚠️ - - if browser.ie?(11) - .site-banner-text - Internet Explorer 11 est un navigateur trop ancien. Nous cesserons de gérer son fonctionnement à partir du - %strong - 31 janvier 2021. - %br - Merci de changer pour un navigateur plus récent avant cette date ; il peut être nécessaire de prendre contact avec un responsable informatique. - - else - .site-banner-text - %strong - #{browser.name} #{browser.version} est trop ancien pour utiliser #{Current.application_name}. - %br - Certaines parties du site ne fonctionneront pas correctement. - .site-banner-actions - = 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 + = render Dsfr::AlertComponent.new(state: :warning, title: "Navigateur trop ancien", heading_level: :h2) do |c| + - c.with_body do + Votre navigateur internet, #{browser.name} #{browser.version}, est malheureusement trop ancien. Il ne sera plus compatible avec #{APPLICATION_NAME} à partir du  + %strong + 1 juin 2024. + %br + Veuillez installer un navigateur plus récent en suivant le lien suivant : + %br + = link_to "Mettre à jour mon navigateur", "https://betagouv.github.io/navigateur-trop-ancien/", class: "fr-btn fr-btn--secondary fr-mt-2w", target: "_blank", rel: "noopener" diff --git a/app/views/root/dismiss_outdated_browser.turbo_stream.haml b/app/views/root/dismiss_outdated_browser.turbo_stream.haml deleted file mode 100644 index e95546cc5..000000000 --- a/app/views/root/dismiss_outdated_browser.turbo_stream.haml +++ /dev/null @@ -1 +0,0 @@ -= turbo_stream.remove('outdated-browser-banner') diff --git a/config/routes.rb b/config/routes.rb index bbdc9a25e..6939fb529 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -216,7 +216,6 @@ Rails.application.routes.draw do get "patron" => "root#patron" if Rails.env.development? || Rails.env.test? get "suivi" => "root#suivi" - post "dismiss_outdated_browser" => "root#dismiss_outdated_browser" post "save_locale" => "root#save_locale" get "contact", to: "support#index" diff --git a/spec/system/outdated_browser_spec.rb b/spec/system/outdated_browser_spec.rb index a632b951f..0284a01bd 100644 --- a/spec/system/outdated_browser_spec.rb +++ b/spec/system/outdated_browser_spec.rb @@ -7,43 +7,8 @@ describe 'Outdated browsers support:' do scenario 'a banner is displayed' do visit new_user_session_path - expect(page).to have_content('Internet Explorer 10 est trop ancien') - end - - scenario 'the banner can be dismissed' do - visit new_user_session_path - expect(page).to have_content('Internet Explorer 10 est trop ancien') - - # The banner is hidden immediately - within '#outdated-browser-banner' do - click_on 'Ignorer' - end - expect(page).not_to have_content('Internet Explorer 10 est trop ancien') - expect(page).to have_current_path(new_user_session_path) - - # The banner is hidden after a refresh - page.refresh - expect(page).not_to have_content('Internet Explorer 10 est trop ancien') - end - end - - context 'when the user browser is about to be outdated' do - before(:each) do - ie_11_user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' - Capybara.page.driver.header('user-agent', ie_11_user_agent) - end - - scenario 'IE11 gets a dedicated depreciation banner for update before jan 31st 2021' do - visit new_user_session_path - expect(page).to have_content('31 janvier 2021') - expect(page).to have_content('Internet Explorer 11 est un navigateur trop ancien') - - within '#outdated-browser-banner' do - click_on 'Ignorer' - end - - page.refresh - expect(page).not_to have_content('Internet Explorer 11 est un navigateur trop ancien') + expect(page).to have_content('1 juin 2024') + expect(page).to have_content('Votre navigateur internet, Internet Explorer 10, est malheureusement trop ancien') end end end