From 4175aa0b284cfb450f97153c744dfc153312a434 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 2 Dec 2019 14:52:01 +0100 Subject: [PATCH 01/23] GroupeInstructeur: do not use outdated email column --- .../new_administrateur/groupe_instructeurs_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/new_administrateur/groupe_instructeurs_controller.rb b/app/controllers/new_administrateur/groupe_instructeurs_controller.rb index 620623ac5..f965781e5 100644 --- a/app/controllers/new_administrateur/groupe_instructeurs_controller.rb +++ b/app/controllers/new_administrateur/groupe_instructeurs_controller.rb @@ -61,7 +61,7 @@ module NewAdministrateur value: bad_emails.join(', ')) end - email_to_adds = correct_emails - groupe_instructeur.instructeurs.pluck(:email) + email_to_adds = correct_emails - groupe_instructeur.instructeurs.map(&:email) if email_to_adds.present? instructeurs = email_to_adds.map do |instructeur_email| @@ -159,8 +159,8 @@ module NewAdministrateur end def available_instructeur_emails - all = current_administrateur.instructeurs.pluck(:email) - assigned = groupe_instructeur.instructeurs.pluck(:email) + all = current_administrateur.instructeurs.map(&:email) + assigned = groupe_instructeur.instructeurs.map(&:email) (all - assigned).sort end end From 9ae1a3c2d357e61163c55005b6c5495e8cc21c2d Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 28 Nov 2019 17:09:51 +0100 Subject: [PATCH 02/23] add missing alt --- app/views/users/dossiers/merci.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/dossiers/merci.html.haml b/app/views/users/dossiers/merci.html.haml index d2da1ab4d..b3657867e 100644 --- a/app/views/users/dossiers/merci.html.haml +++ b/app/views/users/dossiers/merci.html.haml @@ -5,7 +5,7 @@ .merci .container - = image_tag('user/envoi-dossier.svg') + = image_tag('user/envoi-dossier.svg', alt: '') %h1 Merci ! %p.send Votre dossier sur la démarche From d712cc7a351c49ccba4dd406adccc6686c3c1506 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 28 Nov 2019 17:27:03 +0100 Subject: [PATCH 03/23] move ul outside of p --- app/views/root/accessibilite.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/root/accessibilite.html.haml b/app/views/root/accessibilite.html.haml index e790bf96a..5ed1165dd 100644 --- a/app/views/root/accessibilite.html.haml +++ b/app/views/root/accessibilite.html.haml @@ -14,7 +14,7 @@ %h2.new-h2 Défenseur des droits %p.new-p Si vous constatez un défaut d'accessibilité vous empêchant d'accéder à un contenu ou une fonctionnalité du site, que vous nous le signalez et que vous ne parvenez pas à obtenir une réponse rapide de notre part, vous êtes en droit de faire parvenir vos doléances ou une demande de saisine au Défenseur des droits. Plusieurs moyens sont à votre disposition : - %ul - %li un formulaire de contact ; - %li la liste du ou des délégués de votre région avec leurs informations de contact direct ; - %li une adresse postale : Le Défenseur des droits - 7 rue Saint-Florentin - 75409 Paris Cedex 08. + %ul + %li un formulaire de contact ; + %li la liste du ou des délégués de votre région avec leurs informations de contact direct ; + %li une adresse postale : Le Défenseur des droits - 7 rue Saint-Florentin - 75409 Paris Cedex 08. From 233c93bb7c069126c636abe682dc676fbeb61ee3 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 28 Nov 2019 17:49:40 +0100 Subject: [PATCH 04/23] move p outside of label --- app/views/support/index.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml index 60374d8e6..20c89a6e3 100644 --- a/app/views/support/index.html.haml +++ b/app/views/support/index.html.haml @@ -72,10 +72,10 @@ .contact-champ = label_tag :text do Pièce jointe - .notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AMELIORATION } } - Une capture d’écran peut nous aider à identifier plus facilement l’endroit à améliorer. - .notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AUTRE } } - Une capture d’écran peut nous aider à identifier plus facilement le problème. + %p.notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AMELIORATION } } + Une capture d’écran peut nous aider à identifier plus facilement l’endroit à améliorer. + %p.notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AUTRE } } + Une capture d’écran peut nous aider à identifier plus facilement le problème. = file_field_tag :piece_jointe = hidden_field_tag :tags, @tags&.join(',') From 9e44af70b50bb73a94ea4dd7026b023dea6fba27 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 3 Dec 2019 10:13:16 +0100 Subject: [PATCH 05/23] minor typo in textareas --- app/views/shared/dossiers/editable_champs/_textarea.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/dossiers/editable_champs/_textarea.html.haml b/app/views/shared/dossiers/editable_champs/_textarea.html.haml index 620f11c6d..a4666f22e 100644 --- a/app/views/shared/dossiers/editable_champs/_textarea.html.haml +++ b/app/views/shared/dossiers/editable_champs/_textarea.html.haml @@ -1,4 +1,4 @@ ~ form.text_area :value, - row: 6, + rows: 6, required: champ.mandatory?, value: html_to_string(champ.value) From d43f8378e8a811457716b3f4b295d07946ca016d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2019 09:34:09 +0000 Subject: [PATCH 06/23] build(deps): bump chartkick from 3.2.0 to 3.3.0 Bumps [chartkick](https://github.com/ankane/chartkick) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/ankane/chartkick/releases) - [Changelog](https://github.com/ankane/chartkick/blob/master/CHANGELOG.md) - [Commits](https://github.com/ankane/chartkick/compare/v3.2.0...v3.3.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b516e9f39..9a923b78b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -138,7 +138,7 @@ GEM selenium-webdriver case_transform (0.2) activesupport - chartkick (3.2.0) + chartkick (3.3.0) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) chunky_png (1.3.11) From 3db2d44fc02330def039394bdda0481c127c4e0b Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Thu, 28 Nov 2019 15:34:46 +0100 Subject: [PATCH 07/23] affiche un warning pour l'email qqsoit l'email --- app/assets/stylesheets/new_design/user_signup.scss | 10 ++++++++++ app/views/users/registrations/new.html.haml | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 app/assets/stylesheets/new_design/user_signup.scss diff --git a/app/assets/stylesheets/new_design/user_signup.scss b/app/assets/stylesheets/new_design/user_signup.scss new file mode 100644 index 000000000..4592e34b0 --- /dev/null +++ b/app/assets/stylesheets/new_design/user_signup.scss @@ -0,0 +1,10 @@ +@import "colors"; +@import "constants"; + +.suspect-email { + background-color: $orange-bg; + font-weight: bold; + text-align: center; + padding: $default-padding; +} + diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index d21b184be..f474b6661 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -5,6 +5,12 @@ = form_for resource, url: user_registration_path, html: { class: "form" } do |f| %h1 Créez-vous un compte demarches-simplifiees.fr + .suspect-email + .question Vouliez-vous dire blabla@gmail.com ? + .answer + .button Oui + .button Non + = f.label :email, "Email" = f.text_field :email, autofocus: true, placeholder: "Votre adresse email" From 0bfdb2d5da2f0a8a391ba108d81709db05e19c54 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 2 Dec 2019 13:07:40 +0100 Subject: [PATCH 08/23] fermeture et acceptation de la suggestion d'email --- app/javascript/new_design/user-sign_up.js | 20 ++++++++++++++++++++ app/javascript/packs/application.js | 5 ++++- app/views/users/registrations/new.html.haml | 10 ++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 app/javascript/new_design/user-sign_up.js diff --git a/app/javascript/new_design/user-sign_up.js b/app/javascript/new_design/user-sign_up.js new file mode 100644 index 000000000..ab7fafa66 --- /dev/null +++ b/app/javascript/new_design/user-sign_up.js @@ -0,0 +1,20 @@ +import { on, show, hide } from '@utils'; + +const USER_NEW_EMAIL_SELECTOR = '#new_user > #user_email'; +const suspectSuggestionsBox = document.querySelector('.suspect-email'); +const emailSuggestionSpan = document.querySelector(".suspect-email .question .suggested-email"); + +on(USER_NEW_EMAIL_SELECTOR, 'blur', _ => { + emailSuggestionSpan.innerHTML = 'bidou@plop.com'; + show(suspectSuggestionsBox) +}); + +export function acceptEmailSuggestion() { + document.querySelector(USER_NEW_EMAIL_SELECTOR).value = emailSuggestionSpan.innerHTML; + hide(suspectSuggestionsBox); +} + +export function discardEmailSuggestionBox() { + hide(suspectSuggestionsBox); +} + diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 8d0eb5d3c..7dd25f25c 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -40,6 +40,7 @@ import { } from '../new_design/state-button'; import { toggleChart } from '../new_design/toggle-chart'; import { replaceSemicolonByComma } from '../new_design/avis'; +import { acceptEmailSuggestion, discardEmailSuggestionBox } from '../new_design/user-sign_up'; // This is the global application namespace where we expose helpers used from rails views const DS = { @@ -50,7 +51,9 @@ const DS = { motivationCancel, showImportJustificatif, toggleChart, - replaceSemicolonByComma + replaceSemicolonByComma, + acceptEmailSuggestion, + discardEmailSuggestionBox }; // Start Rails helpers diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index f474b6661..b95dc3e47 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -5,11 +5,13 @@ = form_for resource, url: user_registration_path, html: { class: "form" } do |f| %h1 Créez-vous un compte demarches-simplifiees.fr - .suspect-email - .question Vouliez-vous dire blabla@gmail.com ? + .suspect-email.hidden + .question Vouliez-vous dire blabla@gmail.com ? .answer - .button Oui - .button Non + = button_tag type: 'button', class:'button', onclick: "DS.acceptEmailSuggestion()" do + Oui + = button_tag type: 'button', class:'button', onclick: "DS.discardEmailSuggestionBox()" do + Non = f.label :email, "Email" = f.text_field :email, autofocus: true, placeholder: "Votre adresse email" From 80b68afab582610c9a300f0681e4f7baff85a344 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 2 Dec 2019 14:20:26 +0100 Subject: [PATCH 09/23] implement email suggestion --- app/javascript/new_design/user-sign_up.js | 24 ++++++++++++++++------- app/javascript/packs/application.js | 5 ++++- package.json | 1 + yarn.lock | 5 +++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/javascript/new_design/user-sign_up.js b/app/javascript/new_design/user-sign_up.js index ab7fafa66..ffcc6b96a 100644 --- a/app/javascript/new_design/user-sign_up.js +++ b/app/javascript/new_design/user-sign_up.js @@ -1,20 +1,30 @@ import { on, show, hide } from '@utils'; +import { suggest } from 'email-butler'; -const USER_NEW_EMAIL_SELECTOR = '#new_user > #user_email'; +const user_new_email_selector = '#new_user > #user_email'; const suspectSuggestionsBox = document.querySelector('.suspect-email'); -const emailSuggestionSpan = document.querySelector(".suspect-email .question .suggested-email"); +const emailSuggestionSpan = document.querySelector( + '.suspect-email .question .suggested-email' +); -on(USER_NEW_EMAIL_SELECTOR, 'blur', _ => { - emailSuggestionSpan.innerHTML = 'bidou@plop.com'; - show(suspectSuggestionsBox) +on(user_new_email_selector, 'blur', () => { + // When the user leaves the email input during account creation, we check if this account looks correct. + // If not (e.g if its "bidou@gmail.coo" or "john@yahoo.rf") we attempt to suggest a fix for the invalid email. + const suggestion = suggest( + document.querySelector(user_new_email_selector).value + ); + if (suggestion.full) { + emailSuggestionSpan.innerHTML = suggestion.full; + show(suspectSuggestionsBox); + } }); export function acceptEmailSuggestion() { - document.querySelector(USER_NEW_EMAIL_SELECTOR).value = emailSuggestionSpan.innerHTML; + document.querySelector(user_new_email_selector).value = + emailSuggestionSpan.innerHTML; hide(suspectSuggestionsBox); } export function discardEmailSuggestionBox() { hide(suspectSuggestionsBox); } - diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 7dd25f25c..fbe2ee237 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -40,7 +40,10 @@ import { } from '../new_design/state-button'; import { toggleChart } from '../new_design/toggle-chart'; import { replaceSemicolonByComma } from '../new_design/avis'; -import { acceptEmailSuggestion, discardEmailSuggestionBox } from '../new_design/user-sign_up'; +import { + acceptEmailSuggestion, + discardEmailSuggestionBox +} from '../new_design/user-sign_up'; // This is the global application namespace where we expose helpers used from rails views const DS = { diff --git a/package.json b/package.json index 6a72eb949..8ccc7fce8 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "core-js": "^2.0.0", "debounce": "^1.2.0", "dom4": "^2.1.5", + "email-butler": "^1.0.12", "highcharts": "^6.1.2", "intersection-observer": "^0.7.0", "jquery": "^3.4.1", diff --git a/yarn.lock b/yarn.lock index 489582165..ff57a5c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3110,6 +3110,11 @@ elliptic@^6.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" +email-butler@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/email-butler/-/email-butler-1.0.12.tgz#f504b45658fea6257dbc0f891be2cf822d29caa6" + integrity sha512-JcvRCjCpLp3fIHlP+KgdDadSmhETA/D4KUtIi3VnwEw2bJKilMOcd+xLJUHrD631bToxxxYRnxB3xTvAQeIRCQ== + emoji-regex@^7.0.1: version "7.0.3" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" From 849008231c542024a7319164afd3add32be35bb2 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 2 Dec 2019 15:27:02 +0100 Subject: [PATCH 10/23] ajout de test capybara --- spec/features/users/sign_up_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/features/users/sign_up_spec.rb b/spec/features/users/sign_up_spec.rb index 06eb1d831..3b89a14fe 100644 --- a/spec/features/users/sign_up_spec.rb +++ b/spec/features/users/sign_up_spec.rb @@ -17,6 +17,32 @@ feature 'Signing up:' do expect(page).to have_current_path commencer_path(path: procedure.path) end + context 'a new user can sign-up and be suggested a valid email when he makes a typo' do + let(:procedure) { create :simple_procedure, :with_service } + + before do + visit commencer_path(path: procedure.path) + click_on 'Créer un compte demarches-simplifiees.fr' + expect(page).to have_selector('.suspect-email', visible: false) + fill_in :user_email, with: 'bidou@yahoo.rf' + fill_in :user_password, with: '12345' + end + + scenario 'it can accept the suggestion' do + expect(page).to have_selector('.suspect-email', visible: true) + click_on 'Oui' + # expect(page).to have_field("Email", :with => 'bidou@yahoo.fr') + expect(page).to have_selector('.suspect-email', visible: false) + end + + scenario 'it can discard the suggestion' do + expect(page).to have_selector('.suspect-email', visible: true) + click_on 'Non' + expect(page).to have_field("Email", :with => 'bidou@yahoo.rf') + expect(page).to have_selector('.suspect-email', visible: false) + end + end + scenario 'a new user can’t sign-up with too short password when visiting a procedure' do visit commencer_path(path: procedure.path) click_on 'Créer un compte demarches-simplifiees.fr' From 1d1260060e7d9e3509a01037f6cdfcf5f5b90093 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 2 Dec 2019 17:16:18 +0100 Subject: [PATCH 11/23] Fix the tests by using event delegation --- app/javascript/new_design/user-sign_up.js | 37 ++++++++++++----------- spec/features/users/sign_up_spec.rb | 12 ++++---- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/javascript/new_design/user-sign_up.js b/app/javascript/new_design/user-sign_up.js index ffcc6b96a..de826f3b1 100644 --- a/app/javascript/new_design/user-sign_up.js +++ b/app/javascript/new_design/user-sign_up.js @@ -1,30 +1,31 @@ -import { on, show, hide } from '@utils'; +import { delegate, show, hide } from '@utils'; import { suggest } from 'email-butler'; -const user_new_email_selector = '#new_user > #user_email'; -const suspectSuggestionsBox = document.querySelector('.suspect-email'); -const emailSuggestionSpan = document.querySelector( - '.suspect-email .question .suggested-email' -); +const userNewEmailSelector = '#new_user input#user_email'; +const suggestionsSelector = '.suspect-email'; +const emailSuggestionSelector = '.suspect-email .suggested-email'; -on(user_new_email_selector, 'blur', () => { +delegate('focusout', userNewEmailSelector, () => { // When the user leaves the email input during account creation, we check if this account looks correct. - // If not (e.g if its "bidou@gmail.coo" or "john@yahoo.rf") we attempt to suggest a fix for the invalid email. - const suggestion = suggest( - document.querySelector(user_new_email_selector).value - ); - if (suggestion.full) { - emailSuggestionSpan.innerHTML = suggestion.full; - show(suspectSuggestionsBox); + // If not (e.g if its "bidou@gmail.coo" or "john@yahoo.rf"), we attempt to suggest a fix for the invalid email. + const userEmailInput = document.querySelector(userNewEmailSelector); + const suggestedEmailSpan = document.querySelector(emailSuggestionSelector); + + const suggestion = suggest(userEmailInput.value); + if (suggestion && suggestion.full) { + suggestedEmailSpan.innerHTML = suggestion.full; + show(document.querySelector(suggestionsSelector)); } }); export function acceptEmailSuggestion() { - document.querySelector(user_new_email_selector).value = - emailSuggestionSpan.innerHTML; - hide(suspectSuggestionsBox); + const userEmailInput = document.querySelector(userNewEmailSelector); + const suggestedEmailSpan = document.querySelector(emailSuggestionSelector); + + userEmailInput.value = suggestedEmailSpan.innerHTML; + hide(document.querySelector(suggestionsSelector)); } export function discardEmailSuggestionBox() { - hide(suspectSuggestionsBox); + hide(document.querySelector(suggestionsSelector)); } diff --git a/spec/features/users/sign_up_spec.rb b/spec/features/users/sign_up_spec.rb index 3b89a14fe..6607a289a 100644 --- a/spec/features/users/sign_up_spec.rb +++ b/spec/features/users/sign_up_spec.rb @@ -17,25 +17,25 @@ feature 'Signing up:' do expect(page).to have_current_path commencer_path(path: procedure.path) end - context 'a new user can sign-up and be suggested a valid email when he makes a typo' do + context 'when the user makes a typo in their email address' do let(:procedure) { create :simple_procedure, :with_service } before do visit commencer_path(path: procedure.path) click_on 'Créer un compte demarches-simplifiees.fr' expect(page).to have_selector('.suspect-email', visible: false) - fill_in :user_email, with: 'bidou@yahoo.rf' - fill_in :user_password, with: '12345' + fill_in 'Email', with: 'bidou@yahoo.rf' + fill_in 'Mot de passe', with: '12345' end - scenario 'it can accept the suggestion' do + scenario 'they can accept the suggestion', js: true do expect(page).to have_selector('.suspect-email', visible: true) click_on 'Oui' - # expect(page).to have_field("Email", :with => 'bidou@yahoo.fr') + expect(page).to have_field("Email", :with => 'bidou@yahoo.fr') expect(page).to have_selector('.suspect-email', visible: false) end - scenario 'it can discard the suggestion' do + scenario 'they can discard the suggestion', js: true do expect(page).to have_selector('.suspect-email', visible: true) click_on 'Non' expect(page).to have_field("Email", :with => 'bidou@yahoo.rf') From fb3f82074d969125afb3d2a6bc9e8196940cb2c6 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 2 Dec 2019 17:16:42 +0100 Subject: [PATCH 12/23] Hide the suggestions when the user corrects the address --- app/javascript/new_design/user-sign_up.js | 2 ++ spec/features/users/sign_up_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/app/javascript/new_design/user-sign_up.js b/app/javascript/new_design/user-sign_up.js index de826f3b1..d18f4de0a 100644 --- a/app/javascript/new_design/user-sign_up.js +++ b/app/javascript/new_design/user-sign_up.js @@ -15,6 +15,8 @@ delegate('focusout', userNewEmailSelector, () => { if (suggestion && suggestion.full) { suggestedEmailSpan.innerHTML = suggestion.full; show(document.querySelector(suggestionsSelector)); + } else { + hide(document.querySelector(suggestionsSelector)); } }); diff --git a/spec/features/users/sign_up_spec.rb b/spec/features/users/sign_up_spec.rb index 6607a289a..ede736035 100644 --- a/spec/features/users/sign_up_spec.rb +++ b/spec/features/users/sign_up_spec.rb @@ -41,6 +41,13 @@ feature 'Signing up:' do expect(page).to have_field("Email", :with => 'bidou@yahoo.rf') expect(page).to have_selector('.suspect-email', visible: false) end + + scenario 'they can fix the typo themselves', js: true do + expect(page).to have_selector('.suspect-email', visible: true) + fill_in 'Email', with: 'bidou@yahoo.fr' + blur + expect(page).to have_selector('.suspect-email', visible: false) + end end scenario 'a new user can’t sign-up with too short password when visiting a procedure' do From fdec2e04c3cbb059f5cd749a8b00ac03a972d04b Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 3 Dec 2019 09:37:29 +0100 Subject: [PATCH 13/23] la boite de suggestion d'email est en dessous du champ email --- app/views/users/registrations/new.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index b95dc3e47..7ae781caf 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -5,6 +5,9 @@ = form_for resource, url: user_registration_path, html: { class: "form" } do |f| %h1 Créez-vous un compte demarches-simplifiees.fr + = f.label :email, "Email" + = f.text_field :email, autofocus: true, placeholder: "Votre adresse email" + .suspect-email.hidden .question Vouliez-vous dire blabla@gmail.com ? .answer @@ -13,9 +16,6 @@ = button_tag type: 'button', class:'button', onclick: "DS.discardEmailSuggestionBox()" do Non - = f.label :email, "Email" - = f.text_field :email, autofocus: true, placeholder: "Votre adresse email" - = f.label :password, "Mot de passe" = f.password_field :password, value: @user.password, placeholder: "8 caractères minimum" From 8cab6ae19f8f259f1fab0534fe3f3139dc865433 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 3 Dec 2019 10:04:54 +0100 Subject: [PATCH 14/23] retours divers --- app/javascript/new_design/user-sign_up.js | 2 +- app/views/users/registrations/new.html.haml | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/javascript/new_design/user-sign_up.js b/app/javascript/new_design/user-sign_up.js index d18f4de0a..bd737084d 100644 --- a/app/javascript/new_design/user-sign_up.js +++ b/app/javascript/new_design/user-sign_up.js @@ -3,7 +3,7 @@ import { suggest } from 'email-butler'; const userNewEmailSelector = '#new_user input#user_email'; const suggestionsSelector = '.suspect-email'; -const emailSuggestionSelector = '.suspect-email .suggested-email'; +const emailSuggestionSelector = '.suspect-email .email-suggestion-address'; delegate('focusout', userNewEmailSelector, () => { // When the user leaves the email input during account creation, we check if this account looks correct. diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index 7ae781caf..76d8ddf95 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -9,11 +9,14 @@ = f.text_field :email, autofocus: true, placeholder: "Votre adresse email" .suspect-email.hidden - .question Vouliez-vous dire blabla@gmail.com ? - .answer - = button_tag type: 'button', class:'button', onclick: "DS.acceptEmailSuggestion()" do + .email-suggestion-title + Vouliez-vous dire + %span.email-suggestion-address blabla@gmail.com +  ? + .email-suggestion-answer + = button_tag type: 'button', class: 'button', onclick: "DS.acceptEmailSuggestion()" do Oui - = button_tag type: 'button', class:'button', onclick: "DS.discardEmailSuggestionBox()" do + = button_tag type: 'button', class: 'button', onclick: "DS.discardEmailSuggestionBox()" do Non = f.label :password, "Mot de passe" From 841b00bafecab28788fc698ec78b592255cbefda Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 3 Dec 2019 10:05:26 +0100 Subject: [PATCH 15/23] focus sur le mot de passe lorsqu'on traite les suggestions --- app/javascript/new_design/user-sign_up.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/new_design/user-sign_up.js b/app/javascript/new_design/user-sign_up.js index bd737084d..c2a8c4d70 100644 --- a/app/javascript/new_design/user-sign_up.js +++ b/app/javascript/new_design/user-sign_up.js @@ -2,6 +2,7 @@ import { delegate, show, hide } from '@utils'; import { suggest } from 'email-butler'; const userNewEmailSelector = '#new_user input#user_email'; +const passwordFieldSelector = '#new_user input#user_password'; const suggestionsSelector = '.suspect-email'; const emailSuggestionSelector = '.suspect-email .email-suggestion-address'; @@ -26,6 +27,7 @@ export function acceptEmailSuggestion() { userEmailInput.value = suggestedEmailSpan.innerHTML; hide(document.querySelector(suggestionsSelector)); + document.querySelector(passwordFieldSelector).focus(); } export function discardEmailSuggestionBox() { From 5928a16b37b1f78154898ce49b72dfe5837bd22a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Dec 2019 11:27:39 +0000 Subject: [PATCH 16/23] =?UTF-8?q?Am=C3=A9lioration=20de=20la=20mise=20en?= =?UTF-8?q?=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stylesheets/new_design/user_signup.scss | 18 ++++++++++++++++-- app/views/users/registrations/new.html.haml | 8 ++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/new_design/user_signup.scss b/app/assets/stylesheets/new_design/user_signup.scss index 4592e34b0..fe0b174db 100644 --- a/app/assets/stylesheets/new_design/user_signup.scss +++ b/app/assets/stylesheets/new_design/user_signup.scss @@ -3,8 +3,22 @@ .suspect-email { background-color: $orange-bg; - font-weight: bold; text-align: center; - padding: $default-padding; + margin-top: -$default-padding * 2; + margin-bottom: $default-padding * 2; + padding: ($default-padding - 2) $default-padding $default-padding $default-padding; + border-radius: 0 0 5px 5px; } +.email-suggestion-address { + font-weight: bold; +} + +.email-suggestion-title { + margin-bottom: $default-spacer; +} + +.email-suggestion-answer button { + margin: 0 $default-spacer / 2; + min-width: 66px; +} diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index 76d8ddf95..37bcc2387 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -8,15 +8,15 @@ = f.label :email, "Email" = f.text_field :email, autofocus: true, placeholder: "Votre adresse email" - .suspect-email.hidden + .suspect-email .email-suggestion-title - Vouliez-vous dire + Voulez-vous dire %span.email-suggestion-address blabla@gmail.com  ? .email-suggestion-answer - = button_tag type: 'button', class: 'button', onclick: "DS.acceptEmailSuggestion()" do + = button_tag type: 'button', class: 'button small', onclick: "DS.acceptEmailSuggestion()" do Oui - = button_tag type: 'button', class: 'button', onclick: "DS.discardEmailSuggestionBox()" do + = button_tag type: 'button', class: 'button small', onclick: "DS.discardEmailSuggestionBox()" do Non = f.label :password, "Mot de passe" From 8b1535e462800ab5c341ded7c3b1e04e7bd626d1 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 3 Dec 2019 14:55:43 +0100 Subject: [PATCH 17/23] ajout de pagination au sommet de la liste des dossiers --- app/views/instructeurs/procedures/show.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index 229336345..0847097fd 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -64,6 +64,7 @@ %p.explication-onglet Les dossiers de cet onglet sont archivés : vous ne pouvez plus y répondre, et les demandeurs ne peuvent plus les modifier. - if @dossiers.present? || @current_filters.count > 0 + = paginate @dossiers %span.dropdown %button.button.dropdown-button Filtrer From 2ee8cab067d0ded88ff23b7011891cdb7dde872a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 28 Nov 2019 13:39:17 +0000 Subject: [PATCH 18/23] app: display a deprecation banner for IE 11 --- .browserslistrc | 4 +++- README.md | 2 +- config/initializers/browser.rb | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index be9bfee68..6ade378c9 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,8 +1,10 @@ > 1% Chrome >= 50 -IE >= 11 Edge >= 14 Firefox >= 50 Opera >= 40 Safari >= 8 iOS >= 8 +# Although IE 11 shows a deprecation banner, we still support the transpilation option. +# IE 11 support may be removed starting from 01 / 06 / 2020. +IE >= 11 diff --git a/README.md b/README.md index faf159341..94a643ecf 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ Pour les lister : `bin/rake -D support:`. ## Compatibilité navigateurs -L'application supporte les navigateurs récents : Firefox, Chrome, Safari, Edge et Internet Explorer 11 (voir `config/initializers/browser.rb`). +L'application gère les navigateurs récents, parmis lequels Firefox, Chrome, Safari et Edge (voir `config/initializers/browser.rb`). La compatibilité est testée par Browserstack.
[](https://www.browserstack.com/) diff --git a/config/initializers/browser.rb b/config/initializers/browser.rb index 0e88068ad..2526ab7df 100644 --- a/config/initializers/browser.rb +++ b/config/initializers/browser.rb @@ -1,7 +1,6 @@ # See .browserslistrc Browser.modern_rules.clear Browser.modern_rules << -> b { b.chrome? && b.version.to_i >= 50 } -Browser.modern_rules << -> b { b.ie? && b.version.to_i >= 11 && !b.compatibility_view? } Browser.modern_rules << -> b { b.edge? && b.version.to_i >= 14 && !b.compatibility_view? } Browser.modern_rules << -> b { b.firefox? && b.version.to_i >= 50 } Browser.modern_rules << -> b { b.opera? && b.version.to_i >= 40 } From 2b934610a026d0701474f2956f5bf1bd77b4b7b7 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 28 Nov 2019 14:29:31 +0000 Subject: [PATCH 19/23] app: improve the browser deprecation banner appearance --- .../new_design/outdated_browser_banner.scss | 15 ++++++------- .../stylesheets/outdated_browser_banner.scss | 21 ++++++++++++------- .../_outdated_browser_banner.html.haml | 18 ++++++++++------ 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/new_design/outdated_browser_banner.scss b/app/assets/stylesheets/new_design/outdated_browser_banner.scss index 3630c80b9..f7658c3c8 100644 --- a/app/assets/stylesheets/new_design/outdated_browser_banner.scss +++ b/app/assets/stylesheets/new_design/outdated_browser_banner.scss @@ -7,11 +7,12 @@ left: 0; margin: 0; padding: $default-padding; - color: #FFFFFF; - background-color: $medium-red; - - a { - color: $lighter-blue; - text-decoration: underline; - } + color: $black; + background-color: $yellow; +} + +.outdater-browser-icon { + margin-right: $default-padding; + font-size: 30px; + opacity: 0.7; } diff --git a/app/assets/stylesheets/outdated_browser_banner.scss b/app/assets/stylesheets/outdated_browser_banner.scss index 6ec1c0590..dd4722494 100644 --- a/app/assets/stylesheets/outdated_browser_banner.scss +++ b/app/assets/stylesheets/outdated_browser_banner.scss @@ -1,16 +1,23 @@ #outdated-browser-banner { - position: fixed; - text-align: center; - line-height: 2em; - color: #FFFFFF; - background-color: #990000; width: 100%; margin: 0; bottom: 0; left: 0; z-index: 1000; - a { - color: #C3D9FF; + color: #333333; + background-color: #FEF3B8; + + .container { + display: flex; + width: auto; + align-items: center; + padding: 8px 16px; } } + +.outdater-browser-icon { + margin-right: 16px; + font-size: 30px; + opacity: 0.7; +} diff --git a/app/views/layouts/_outdated_browser_banner.html.haml b/app/views/layouts/_outdated_browser_banner.html.haml index 3e36890a6..a00c7da4a 100644 --- a/app/views/layouts/_outdated_browser_banner.html.haml +++ b/app/views/layouts/_outdated_browser_banner.html.haml @@ -1,8 +1,14 @@ -/ See config/browser.rb +-# See config/browser.rb - if !browser.modern? #outdated-browser-banner - .container - Attention, votre navigateur (#{browser.name} #{browser.version}) est trop ancien pour utiliser demarches-simplifiees.fr : certaines parties du site ne fonctionneront pas correctement. Nous vous recommandons fortement de - %a{ href: "https://browser-update.org/fr/update.html", target: "_blank", rel: "noopener" }mettre à jour votre navigateur - %span<> - \. + .container.flex.align-center + .outdater-browser-icon + ⚠️ + .outdated-browser-test + %strong + #{browser.name} #{browser.version} est trop ancien pour utiliser demarches-simplifiees.fr. + %br + Certaines parties du site ne fonctionneront pas correctement. + .outdated-browser-buttons{ style: 'margin-left: auto' } + %a.button.primary{ href: "https://browser-update.org/fr/update.html", target: "_blank", rel: "noopener" } + Mettre à jour mon navigateur From 299f9df375255f3d5344c61909fe84edac6b15fd Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 28 Nov 2019 15:48:27 +0100 Subject: [PATCH 20/23] app: on the old design, move the deprecation banner to a better location Otherwise it hides the "Change role" controls. --- app/views/layouts/_main_container.html.haml | 2 ++ app/views/layouts/application_old.html.haml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_main_container.html.haml b/app/views/layouts/_main_container.html.haml index a1d728b3a..ff74bc38d 100644 --- a/app/views/layouts/_main_container.html.haml +++ b/app/views/layouts/_main_container.html.haml @@ -1,4 +1,6 @@ #main-container{ class: "col-xs-#{main_container_size}" } + .row + = render partial: 'layouts/outdated_browser_banner' .row = render partial: 'layouts/flash_messages' .row diff --git a/app/views/layouts/application_old.html.haml b/app/views/layouts/application_old.html.haml index ce233e5f3..80fd1109e 100644 --- a/app/views/layouts/application_old.html.haml +++ b/app/views/layouts/application_old.html.haml @@ -19,7 +19,6 @@ = Gon::Base.render_data(camel_case: true, init: true) %body{ class: browser.platform.ios? ? 'ios' : nil } - = render partial: 'layouts/outdated_browser_banner' = render partial: 'layouts/pre_maintenance' - if staging? #beta From 3212dfddca0e6c7a00e27b048b7bac07a0a1c219 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Dec 2019 15:02:08 +0000 Subject: [PATCH 21/23] app: allow hiding the browser banner for one week --- .../new_design/outdated_browser_banner.scss | 13 ++++++-- .../stylesheets/outdated_browser_banner.scss | 10 +++--- app/controllers/root_controller.rb | 11 +++++++ app/helpers/application_helper.rb | 11 +++++++ .../_outdated_browser_banner.html.haml | 9 +++--- config/routes.rb | 1 + spec/features/outdated_browser_spec.rb | 31 +++++++++++++++++++ 7 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 spec/features/outdated_browser_spec.rb diff --git a/app/assets/stylesheets/new_design/outdated_browser_banner.scss b/app/assets/stylesheets/new_design/outdated_browser_banner.scss index f7658c3c8..7b94f8a79 100644 --- a/app/assets/stylesheets/new_design/outdated_browser_banner.scss +++ b/app/assets/stylesheets/new_design/outdated_browser_banner.scss @@ -3,16 +3,23 @@ #outdated-browser-banner { width: 100%; - bottom: 0; - left: 0; margin: 0; padding: $default-padding; color: $black; background-color: $yellow; } -.outdater-browser-icon { +.outdated-browser-icon { margin-right: $default-padding; font-size: 30px; opacity: 0.7; } + +.outdated-browser-buttons { + display: flex; + margin-left: auto; + + .button { + margin-left: $default-spacer; + } +} diff --git a/app/assets/stylesheets/outdated_browser_banner.scss b/app/assets/stylesheets/outdated_browser_banner.scss index dd4722494..c4b2eb089 100644 --- a/app/assets/stylesheets/outdated_browser_banner.scss +++ b/app/assets/stylesheets/outdated_browser_banner.scss @@ -1,9 +1,6 @@ #outdated-browser-banner { width: 100%; margin: 0; - bottom: 0; - left: 0; - z-index: 1000; color: #333333; background-color: #FEF3B8; @@ -16,8 +13,13 @@ } } -.outdater-browser-icon { +.outdated-browser-icon { margin-right: 16px; font-size: 30px; opacity: 0.7; } + +.outdated-browser-buttons { + display: flex; + margin-left: auto; +} diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 0014c7766..bcf28f57d 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -1,4 +1,6 @@ class RootController < ApplicationController + include ApplicationHelper + def index if administrateur_signed_in? return redirect_to admin_procedures_path @@ -69,4 +71,13 @@ 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.js { render js: helpers.remove_element('#outdated-browser-banner') } + end + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0fd4c8bb2..9929ab7f6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -120,4 +120,15 @@ module ApplicationHelper def try_format_datetime(datetime) datetime.present? ? I18n.l(datetime) : '' 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 end diff --git a/app/views/layouts/_outdated_browser_banner.html.haml b/app/views/layouts/_outdated_browser_banner.html.haml index a00c7da4a..d60b38661 100644 --- a/app/views/layouts/_outdated_browser_banner.html.haml +++ b/app/views/layouts/_outdated_browser_banner.html.haml @@ -1,14 +1,15 @@ -# See config/browser.rb -- if !browser.modern? +- if !browser.modern? && !has_dismissed_outdated_browser_banner? #outdated-browser-banner .container.flex.align-center - .outdater-browser-icon + .outdated-browser-icon ⚠️ .outdated-browser-test %strong #{browser.name} #{browser.version} est trop ancien pour utiliser demarches-simplifiees.fr. %br Certaines parties du site ne fonctionneront pas correctement. - .outdated-browser-buttons{ style: 'margin-left: auto' } - %a.button.primary{ href: "https://browser-update.org/fr/update.html", target: "_blank", rel: "noopener" } + .outdated-browser-buttons + = button_to 'Ignorer', dismiss_outdated_browser_path, method: :post, remote: 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/config/routes.rb b/config/routes.rb index 47bca15b9..5d4908a9e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -125,6 +125,7 @@ Rails.application.routes.draw do get "patron" => "root#patron" get "accessibilite" => "root#accessibilite" get "suivi" => "root#suivi" + post "dismiss_outdated_browser" => "root#dismiss_outdated_browser" get "contact", to: "support#index" post "contact", to: "support#create" diff --git a/spec/features/outdated_browser_spec.rb b/spec/features/outdated_browser_spec.rb new file mode 100644 index 000000000..e6cb28efb --- /dev/null +++ b/spec/features/outdated_browser_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +feature 'Outdated browsers support:' do + context 'when the user browser is 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 'a banner is displayed' do + visit new_user_session_path + expect(page).to have_content('Internet Explorer 11 est trop ancien') + end + + scenario 'the banner can be dismissed' do + visit new_user_session_path + expect(page).to have_content('Internet Explorer 11 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 11 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 11 est trop ancien') + end + end +end From 97af50c700fede103d3f213def730b87f5fb8277 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 28 Nov 2019 16:30:57 +0000 Subject: [PATCH 22/23] app: fix detection of Chrome iOS and Firefox iOS as outdated browsers For instance, Firefox iOS is reported as `firefox? true, version 20`. As on iOS only the system-provided Webkit is allowed, we can instead safely assume that all browsers on a recent iOS device are modern. --- config/initializers/browser.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/initializers/browser.rb b/config/initializers/browser.rb index 2526ab7df..f9d22d40b 100644 --- a/config/initializers/browser.rb +++ b/config/initializers/browser.rb @@ -1,7 +1,8 @@ # See .browserslistrc Browser.modern_rules.clear -Browser.modern_rules << -> b { b.chrome? && b.version.to_i >= 50 } +Browser.modern_rules << -> b { b.chrome? && b.version.to_i >= 50 && !b.platform.ios? } Browser.modern_rules << -> b { b.edge? && b.version.to_i >= 14 && !b.compatibility_view? } -Browser.modern_rules << -> b { b.firefox? && b.version.to_i >= 50 } +Browser.modern_rules << -> b { b.firefox? && b.version.to_i >= 50 && !b.platform.ios? } Browser.modern_rules << -> b { b.opera? && b.version.to_i >= 40 } Browser.modern_rules << -> b { b.safari? && b.version.to_i >= 8 } +Browser.modern_rules << -> b { b.platform.ios? && b.platform.version.to_i >= 8 } From f351ade434ca0fc05fad4c54e90a404c51bd8c4a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 3 Dec 2019 15:13:20 +0000 Subject: [PATCH 23/23] javascript: expose Turbolinks globally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When calling `redirect_to` in a Rails controller that emits Javascript, Rails will emit `Turbolinks.replace(…)` commands. And for this, Turbolinks needs to be globally available. --- app/javascript/packs/application.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index fbe2ee237..a0e320c3a 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -65,19 +65,14 @@ Rails.start(); Turbolinks.start(); ActiveStorage.start(); -// If Turbolinks is imported via Webpacker (and thus not available globally), -// ReactRailsUJS will be unable to locate it. -// https://github.com/reactjs/react-rails#event-handling - -// eslint-disable-next-line no-undef -ReactRailsUJS.useContext(require.context('components', true)); -// Add Turbolinks to the global namespace: -window.Turbolinks = Turbolinks; -// Remove previous event handlers and add new ones: -ReactRailsUJS.detectEvents(); -// (Optional) Clean up global namespace: -delete window.Turbolinks; - // Expose globals window.DS = window.DS || DS; window.Chartkick = Chartkick; +// (Both Rails redirects and ReactRailsUJS expect Turbolinks to be globally available) +window.Turbolinks = Turbolinks; + +// Now that Turbolinks is globally exposed,configure ReactRailsUJS +// eslint-disable-next-line no-undef +ReactRailsUJS.useContext(require.context('components', true)); +// Remove previous event handlers and add new ones: +ReactRailsUJS.detectEvents();