chore(browser): be more agressive about browser deprecation

This commit is contained in:
Paul Chavard 2024-04-02 21:30:38 +02:00
parent c005991470
commit 9593e8825f
6 changed files with 12 additions and 84 deletions

View file

@ -96,15 +96,6 @@ class RootController < ApplicationController
def suivi def suivi
end 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 def save_locale
set_locale(params[:locale]) set_locale(params[:locale])
redirect_back(fallback_location: root_path) redirect_back(fallback_location: root_path)

View file

@ -122,23 +122,8 @@ module ApplicationHelper
end end
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? def show_outdated_browser_banner?
!supported_browser? && !has_dismissed_outdated_browser_banner? !BrowserSupport.supported?(browser)
end end
def vite_legacy? def vite_legacy?

View file

@ -1,21 +1,10 @@
- if show_outdated_browser_banner? - if show_outdated_browser_banner?
#outdated-browser-banner.site-banner = render Dsfr::AlertComponent.new(state: :warning, title: "Navigateur trop ancien", heading_level: :h2) do |c|
.container - c.with_body do
.site-banner-icon ⚠️ Votre navigateur internet, #{browser.name} #{browser.version}, est malheureusement trop ancien. Il ne sera plus compatible avec #{APPLICATION_NAME} à partir du 
- if browser.ie?(11) %strong
.site-banner-text 1 juin 2024.
Internet Explorer 11 est un navigateur trop ancien. Nous cesserons de gérer son fonctionnement à partir du %br
%strong Veuillez installer un navigateur plus récent en suivant le lien suivant :
31 janvier 2021. %br
%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"
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

View file

@ -1 +0,0 @@
= turbo_stream.remove('outdated-browser-banner')

View file

@ -216,7 +216,6 @@ Rails.application.routes.draw do
get "patron" => "root#patron" if Rails.env.development? || Rails.env.test? get "patron" => "root#patron" if Rails.env.development? || Rails.env.test?
get "suivi" => "root#suivi" get "suivi" => "root#suivi"
post "dismiss_outdated_browser" => "root#dismiss_outdated_browser"
post "save_locale" => "root#save_locale" post "save_locale" => "root#save_locale"
get "contact", to: "support#index" get "contact", to: "support#index"

View file

@ -7,43 +7,8 @@ describe 'Outdated browsers support:' do
scenario 'a banner is displayed' do scenario 'a banner is displayed' do
visit new_user_session_path visit new_user_session_path
expect(page).to have_content('Internet Explorer 10 est trop ancien') expect(page).to have_content('1 juin 2024')
end expect(page).to have_content('Votre navigateur internet, Internet Explorer 10, est malheureusement trop ancien')
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')
end end
end end
end end