Merge pull request #5123 from betagouv/disable-turbolinks

Désactivation de Turbolinks
This commit is contained in:
Pierre de La Morinerie 2020-05-13 11:10:09 +02:00 committed by GitHub
commit 179a8b83b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 40 additions and 72 deletions

View file

@ -71,7 +71,6 @@ gem 'skylight'
gem 'smart_listing'
gem 'spreadsheet_architect'
gem 'sprockets', '< 4'
gem 'turbolinks' # Turbolinks makes following links in your web application faster
gem 'typhoeus'
gem 'warden'
gem 'webpacker'

View file

@ -663,9 +663,6 @@ GEM
tilt (2.0.10)
timecop (0.9.1)
ttfunk (1.5.1)
turbolinks (5.2.0)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
typhoeus (1.3.1)
ethon (>= 0.9.0)
tzinfo (1.2.7)
@ -823,7 +820,6 @@ DEPENDENCIES
spring-commands-rspec
sprockets (< 4)
timecop
turbolinks
typhoeus
vcr
warden

View file

@ -1,6 +1,6 @@
/* globals $ */
$(document).on('turbolinks:load', wysihtml5_active);
$(document).on('DOMContentLoaded', wysihtml5_active);
function wysihtml5_active() {
$('.wysihtml5').each(function (i, elem) {

View file

@ -1,6 +1,6 @@
/* globals $ */
$(document).on('turbolinks:load', init_default_data_block);
$(document).on('DOMContentLoaded', init_default_data_block);
function init_default_data_block() {
$('.default-data-block #dossier .body').toggle();

View file

@ -1,6 +1,6 @@
/* globals $ */
$(document).on('turbolinks:load', filters_init);
$(document).on('DOMContentLoaded', filters_init);
function filters_init() {
$('html').click(function (event) {

View file

@ -1,6 +1,6 @@
/* globals $ */
$(document).on('turbolinks:load', action_type_de_champs);
$(document).on('DOMContentLoaded', action_type_de_champs);
function action_type_de_champs() {
$("input[type='email']").on('change', function () {

View file

@ -1,6 +1,6 @@
/* globals $ */
$(document).on('turbolinks:load', modal_action);
$(document).on('DOMContentLoaded', modal_action);
function modal_action() {
$('#pj-modal').on('show.bs.modal', function (event) {

View file

@ -1,6 +1,6 @@
/* globals $ */
$(document).on('turbolinks:load', button_edit_procedure_init);
$(document).on('DOMContentLoaded', button_edit_procedure_init);
function button_edit_procedure_init() {
buttons_api_carto();

View file

@ -1,5 +0,0 @@
@import "constants";
.turbolinks-progress-bar {
background-color: $light-blue;
}

View file

@ -11,7 +11,6 @@
//
// = require _card
// = require _helpers
// = require _turbolinks
// = require admin_type_de_champ
// = require carte
// = require custom_mails

View file

@ -72,7 +72,7 @@ class Admin::ProceduresController < AdminController
@procedure.publish_or_reopen!(current_administrateur)
flash.notice = "Démarche publiée"
redirect_to admin_procedures_path
render js: "window.location='#{admin_procedures_path}'"
rescue ActiveRecord::RecordInvalid
render 'publish_validate', formats: :js
end

View file

@ -25,7 +25,7 @@ async function loadAndRedrawMap(element, data) {
redrawMap(element, data);
}
addEventListener('turbolinks:load', initialize);
addEventListener('DOMContentLoaded', initialize);
addEventListener('carte:update', ({ detail: { selector, data } }) => {
const element = document.querySelector(selector);

View file

@ -1,5 +1,4 @@
import '../shared/polyfills';
import Turbolinks from 'turbolinks';
import Rails from '@rails/ujs';
import * as ActiveStorage from '@rails/activestorage';
import jQuery from 'jquery';
@ -13,7 +12,6 @@ import '../shared/franceconnect';
// Start Rails helpers
Rails.start();
Turbolinks.start();
ActiveStorage.start();
// Disable jQuery-driven animations during tests

View file

@ -1,5 +1,4 @@
import '../shared/polyfills';
import Turbolinks from 'turbolinks';
import Rails from '@rails/ujs';
import * as ActiveStorage from '@rails/activestorage';
import '@rails/actiontext';
@ -57,13 +56,10 @@ const DS = {
// Start Rails helpers
Rails.start();
Turbolinks.start();
ActiveStorage.start();
// Expose globals
window.DS = window.DS || DS;
// (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

View file

@ -1,6 +1,6 @@
import { fire } from '@utils';
addEventListener('turbolinks:load', function () {
addEventListener('DOMContentLoaded', function () {
fire(document, 'ds:page:update');
});

View file

@ -1,6 +1,6 @@
import { ajax, delegate } from '@utils';
addEventListener('turbolinks:load', () => {
addEventListener('DOMContentLoaded', () => {
attachementPoller.deactivate();
exportPoller.deactivate();

View file

@ -25,23 +25,4 @@ if (enabled) {
script.async = true;
script.src = jsUrl;
firstScript.parentNode.insertBefore(script, firstScript);
// Send Matomo a new event when navigating to a new page using Turbolinks
// (see https://developer.matomo.org/guides/spa-tracking)
let previousPageUrl = null;
addEventListener('turbolinks:load', (event) => {
if (previousPageUrl) {
window._paq.push(['setReferrerUrl', previousPageUrl]);
window._paq.push(['setCustomUrl', window.location.href]);
window._paq.push(['setDocumentTitle', document.title]);
if (event.data && event.data.timing) {
window._paq.push([
'setGenerationTimeMs',
event.data.timing.visitEnd - event.data.timing.visitStart
]);
}
window._paq.push(['trackPageView']);
}
previousPageUrl = window.location.href;
});
}

View file

@ -27,7 +27,7 @@
target: "_blank"
:javascript
document.addEventListener("turbolinks:load", function() {
document.addEventListener("DOMContentLoaded", function() {
$crisp.push(["do", "trigger:run", ["admin-signup"]]);
});

View file

@ -11,7 +11,7 @@
%h1= procedure_libelle @procedure
= link_to 'gestion des notifications', email_notifications_instructeur_procedure_path(@procedure), class: 'header-link'
|
= link_to 'statistiques', stats_instructeur_procedure_path(@procedure), class: 'header-link', data: { turbolinks: false } # Turbolinks disabled for Chartkick. See Issue #350
= link_to 'statistiques', stats_instructeur_procedure_path(@procedure), class: 'header-link'
- if @procedure.routee?
|

View file

@ -11,7 +11,7 @@
%h1= procedure_libelle @procedure
= link_to 'gestion des notifications', email_notifications_instructeur_procedure_path(@procedure), class: 'header-link'
|
= link_to 'statistiques', stats_instructeur_procedure_path(@procedure), class: 'header-link', data: { turbolinks: false } # Turbolinks disabled for Chartkick. See Issue #350
= link_to 'statistiques', stats_instructeur_procedure_path(@procedure), class: 'header-link'
- if @procedure.routee?
|

View file

@ -5,7 +5,7 @@
\-
= link_to 'Nouveautés', 'https://doc.demarches-simplifiees.fr/nouveautes', target: '_blank'
\-
= link_to 'Statistiques', stats_path, data: { turbolinks: false } # Turbolinks disabled for Chartkick. See Issue #350
= link_to 'Statistiques', stats_path
\-
= link_to 'CGU / Mentions légales', CGU_URL, target: '_blank'
\-

View file

@ -3,7 +3,6 @@
%head
%meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" }
%meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
%meta{ name: "turbolinks-cache-control", content: "no-cache" }
%meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
= csrf_meta_tags
@ -15,9 +14,9 @@
= favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
- packs = ['application', 'track', administrateur_signed_in? ? 'track-admin' : nil].compact
= javascript_packs_with_chunks_tag *packs, defer: true, 'data-turbolinks-track': 'reload'
= stylesheet_link_tag 'new_design/new_application', media: 'all', 'data-turbolinks-track': 'reload'
= stylesheet_link_tag 'new_design/print', media: 'print', 'data-turbolinks-track': 'reload'
= javascript_packs_with_chunks_tag *packs, defer: true
= stylesheet_link_tag 'new_design/new_application', media: 'all'
= stylesheet_link_tag 'new_design/print', media: 'print'
= Gon::Base.render_data(camel_case: true, init: true, nonce: request.content_security_policy_nonce)

View file

@ -1,7 +1,6 @@
%html
%head
%meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }/
%meta{ name: "turbolinks-cache-control", content: "no-cache" }
%title
= t('dynamics.page_title')
%meta{ 'http-equiv' => "X-UA-Compatible", :content => "IE=edge" }
@ -10,11 +9,11 @@
= favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
= favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': "reload"
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
= stylesheet_link_tag 'application', media: 'all'
= stylesheet_link_tag 'print', media: 'print'
- packs = ['application-old', 'track', administrateur_signed_in? ? 'track-admin' : nil].compact
= javascript_packs_with_chunks_tag *packs, defer: true, 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
= javascript_packs_with_chunks_tag *packs, defer: true
= javascript_include_tag 'application', defer: true
= csrf_meta_tags
= Gon::Base.render_data(camel_case: true, init: true)

View file

@ -23,7 +23,7 @@
%li.footer-link
= link_to "Nouveautés", "https://github.com/betagouv/demarches-simplifiees.fr/releases", :class => "footer-link", :title => "Nos nouveautés"
%li.footer-link
= link_to "Statistiques", stats_path, :class => "footer-link", data: { turbolinks: false } # Turbolinks disabled for Chartkick. See Issue #350
= link_to "Statistiques", stats_path, :class => "footer-link"
%li.footer-link
= link_to "CGU", CGU_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer"
%li.footer-link

View file

@ -38,7 +38,6 @@
"react_ujs": "^2.6.1",
"select2": "^4.0.13",
"trix": "^1.2.3",
"turbolinks": "^5.2.0",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {

View file

@ -180,7 +180,11 @@ describe Admin::ProceduresController, type: :controller do
expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(path)
expect(procedure.lien_site_web).to eq(lien_site_web)
expect(response.status).to eq 302
end
it 'redirects to the procedures page' do
expect(response.status).to eq 200
expect(response.body).to include(admin_procedures_path)
expect(flash[:notice]).to have_content 'Démarche publiée'
end
end
@ -193,13 +197,17 @@ describe Admin::ProceduresController, type: :controller do
expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(path)
expect(procedure.lien_site_web).to eq(lien_site_web)
expect(response.status).to eq 302
expect(flash[:notice]).to have_content 'Démarche publiée'
end
it 'depubliee previous procedure' do
expect(procedure2.depubliee?).to be_truthy
end
it 'redirects to the procedures page' do
expect(response.status).to eq 200
expect(response.body).to include(admin_procedures_path)
expect(flash[:notice]).to have_content 'Démarche publiée'
end
end
context 'procedure path exists and is not owned by current administrator' do
@ -285,8 +293,12 @@ describe Admin::ProceduresController, type: :controller do
end
it { expect(procedure.publiee?).to be_truthy }
it { expect(response.status).to eq 302 }
it { expect(flash[:notice]).to have_content 'Démarche publiée' }
it 'redirects to the procedures page' do
expect(response.status).to eq 200
expect(response.body).to include(admin_procedures_path)
expect(flash[:notice]).to have_content 'Démarche publiée'
end
end
end

View file

@ -133,7 +133,7 @@ feature 'The routing', js: true do
click_on 'suivi'
click_on litteraire_user.email
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
expect(page).to have_text('Annotations privées') # ensure Turbolinks DID load the DOM content
expect(page).to have_text('Annotations privées')
expect(find('.tabs')).to have_css('span.notifications')
log_out

View file

@ -9397,11 +9397,6 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"
turbolinks@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/turbolinks/-/turbolinks-5.2.0.tgz#e6877a55ea5c1cb3bb225f0a4ae303d6d32ff77c"
integrity sha512-pMiez3tyBo6uRHFNNZoYMmrES/IaGgMhQQM+VFF36keryjb5ms0XkVpmKHkfW/4Vy96qiGW3K9bz0tF5sK9bBw==
turf-intersect@~3.0.12:
version "3.0.12"
resolved "https://registry.yarnpkg.com/turf-intersect/-/turf-intersect-3.0.12.tgz#c0d7fb305843a19275670057a39d268b17830d83"