From fe0b3c2215abeec7728d675810fac9b8c39bb244 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Tue, 7 Apr 2020 18:11:11 +0200 Subject: [PATCH 1/8] Revert "Revert "feat/4893 - migrate the mapReader to mapbox-gl with react"" This reverts commit 3e21b781421467fce62c43bc4102b4a0356012f2. --- app/javascript/components/MapReader.js | 114 +++++++ app/javascript/loaders/MapReader.js | 3 + app/views/shared/champs/carte/_show.html.haml | 5 +- config/initializers/assets.rb | 1 + .../initializers/content_security_policy.rb | 2 +- config/webpack/environment.js | 3 + package.json | 2 + yarn.lock | 278 +++++++++++++++++- 8 files changed, 402 insertions(+), 6 deletions(-) create mode 100644 app/javascript/components/MapReader.js create mode 100644 app/javascript/loaders/MapReader.js diff --git a/app/javascript/components/MapReader.js b/app/javascript/components/MapReader.js new file mode 100644 index 000000000..3f2eaa681 --- /dev/null +++ b/app/javascript/components/MapReader.js @@ -0,0 +1,114 @@ +import React from 'react'; +import ReactMapboxGl, { ZoomControl, GeoJSONLayer } from 'react-mapbox-gl'; +import { LngLatBounds } from 'mapbox-gl'; +import PropTypes from 'prop-types'; + +const Map = ReactMapboxGl({}); + +const MapReader = ({ geoData }) => { + let [selectionCollection, cadastresCollection] = [[], []]; + + for (let selection of geoData.selection.coordinates) { + selectionCollection.push({ + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: selection + } + }); + } + + for (let cadastre of geoData.cadastres) { + cadastresCollection.push({ + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: cadastre.geometry.coordinates[0] + } + }); + } + + const selectionData = { + type: 'geojson', + data: { + type: 'FeatureCollection', + features: selectionCollection + } + }; + + const cadastresData = { + type: 'geojson', + data: { + type: 'FeatureCollection', + features: cadastresCollection + } + }; + + const polygonSelectionFill = { + 'fill-color': '#EC3323', + 'fill-opacity': 0.5 + }; + + const polygonSelectionLine = { + 'line-color': 'rgba(255, 0, 0, 1)', + 'line-width': 4 + }; + + const polygonCadastresFill = { + 'fill-color': '#9CA090', + 'fill-opacity': 0.5 + }; + + const polygonCadastresLine = { + 'line-color': 'rgba(156, 160, 144, 255)', + 'line-width': 2, + 'line-dasharray': [1, 1] + }; + + let bounds = new LngLatBounds(); + + for (let selection of selectionCollection) { + for (let coordinate of selection.geometry.coordinates[0]) { + bounds.extend(coordinate); + } + } + let [swCoords, neCoords] = [ + Object.values(bounds._sw), + Object.values(bounds._ne) + ]; + const boundData = [swCoords, neCoords]; + + return ( + + + + + + ); +}; + +MapReader.propTypes = { + geoData: PropTypes.shape({ + position: PropTypes.object, + selection: PropTypes.object, + cadastres: PropTypes.array + }) +}; + +export default MapReader; diff --git a/app/javascript/loaders/MapReader.js b/app/javascript/loaders/MapReader.js new file mode 100644 index 000000000..adb90193f --- /dev/null +++ b/app/javascript/loaders/MapReader.js @@ -0,0 +1,3 @@ +import Loadable from '../components/Loadable'; + +export default Loadable(() => import('../components/MapReader')); diff --git a/app/views/shared/champs/carte/_show.html.haml b/app/views/shared/champs/carte/_show.html.haml index 224d79cb0..8aa9b4dbf 100644 --- a/app/views/shared/champs/carte/_show.html.haml +++ b/app/views/shared/champs/carte/_show.html.haml @@ -1,4 +1,7 @@ - if champ.to_s.present? - .carte{ data: { geo: geo_data(champ) } } + - if supported_browser? + = react_component("MapReader", { geoData: champ.to_render_data } ) + - else + %p La carte n'est pas compatible avec votre navigateur. Afin de l'afficher, nous vous conseillons d'utiliser Chrome, Firefox ou Safari .geo-areas = render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, error: false } diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 1535e55ba..82025de9c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -6,6 +6,7 @@ Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path Rails.application.config.assets.paths << Rails.root.join('node_modules', 'trix', 'dist') Rails.application.config.assets.paths << Rails.root.join('node_modules', 'select2', 'dist', 'css') +Rails.application.config.assets.paths << Rails.root.join('node_modules', 'mapbox-gl', 'dist') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 63eaa7b7a..0f48a942b 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -8,7 +8,7 @@ Rails.application.config.content_security_policy do |policy| # c'est trop compliqué pour être rectifié immédiatement (et sans valeur ajoutée: # c'est hardcodé dans les vues, donc pas injectable). policy.style_src :self, "*.crisp.chat", "crisp.chat", :unsafe_inline - policy.connect_src :self, "wss://*.crisp.chat", "*.crisp.chat", "*.demarches-simplifiees.fr", "in-automate.sendinblue.com", "app.franceconnect.gouv.fr", "sentry.io", "geo.api.gouv.fr", "api-adresse.data.gouv.fr" + policy.connect_src :self, "wss://*.crisp.chat", "*.crisp.chat", "*.demarches-simplifiees.fr", "in-automate.sendinblue.com", "app.franceconnect.gouv.fr", "sentry.io", "geo.api.gouv.fr", "api-adresse.data.gouv.fr", "openmaptiles.geo.data.gouv.fr", "openmaptiles.github.io" # Pour tout le reste, par défaut on accepte uniquement ce qui vient de chez nous # et dans la notification on inclue la source de l'erreur policy.default_src :self, :data, :report_sample, "fonts.gstatic.com", "in-automate.sendinblue.com", "player.vimeo.com", "app.franceconnect.gouv.fr", "sentry.io", "static.demarches-simplifiees.fr", "*.crisp.chat", "crisp.chat", "*.crisp.help", "*.sibautomation.com", "sibautomation.com", "data" diff --git a/config/webpack/environment.js b/config/webpack/environment.js index 97e4aa14c..971d33c08 100644 --- a/config/webpack/environment.js +++ b/config/webpack/environment.js @@ -9,6 +9,9 @@ const resolve = { environment.splitChunks(); environment.config.merge({ resolve }); +environment.loaders.get( + 'nodeModules' +).exclude = /(?:@?babel(?:\/|\\{1,2}|-).+)|regenerator-runtime|core-js|^webpack$|^webpack-assets-manifest$|^webpack-cli$|^webpack-sources$|^@rails\/webpacker$|^mapbox-gl$|/; // Uncoment next lines to run webpack-bundle-analyzer // const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); diff --git a/package.json b/package.json index 3c5f81061..5cfd2b229 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,13 @@ "jquery": "^3.4.1", "leaflet": "^1.6.0", "leaflet-freedraw": "^2.12.0", + "mapbox-gl": "^1.9.0", "prop-types": "^15.7.2", "react": "^16.12.0", "react-dom": "^16.12.0", "react-intersection-observer": "^8.25.2", "react-loadable": "^5.5.0", + "react-mapbox-gl": "^4.8.3", "react-scroll-to-component": "^1.0.2", "react-sortable-hoc": "^1.11.0", "react_ujs": "^2.6.1", diff --git a/yarn.lock b/yarn.lock index cf106e02f..bddc579ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -895,6 +895,65 @@ dependencies: prop-types "^15.5.10" +"@mapbox/geojson-area@0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz#18d7814aa36bf23fbbcc379f8e26a22927debf10" + integrity sha1-GNeBSqNr8j+7zDefjiaiKSfevxA= + dependencies: + wgs84 "0.0.0" + +"@mapbox/geojson-rewind@^0.4.0": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@mapbox/geojson-rewind/-/geojson-rewind-0.4.1.tgz#357d79300adb7fec7c1f091512988bca6458f068" + integrity sha512-mxo2MEr7izA1uOXcDsw99Kgg6xW3P4H2j4n1lmldsgviIelpssvP+jQDivFKOHrOVJDpTTi5oZJvRcHtU9Uufw== + dependencies: + "@mapbox/geojson-area" "0.2.2" + concat-stream "~1.6.0" + minimist "^1.2.5" + sharkdown "^0.1.0" + +"@mapbox/geojson-types@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@mapbox/geojson-types/-/geojson-types-1.0.2.tgz#9aecf642cb00eab1080a57c4f949a65b4a5846d6" + integrity sha512-e9EBqHHv3EORHrSfbR9DqecPNn+AmuAoQxV6aL8Xu30bJMJR1o8PZLZzpk1Wq7/NfCbuhmakHTPYRhoqLsXRnw== + +"@mapbox/jsonlint-lines-primitives@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz#ce56e539f83552b58d10d672ea4d6fc9adc7b234" + integrity sha1-zlblOfg1UrWNENZy6k1vya3HsjQ= + +"@mapbox/mapbox-gl-supported@^1.4.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@mapbox/mapbox-gl-supported/-/mapbox-gl-supported-1.5.0.tgz#f60b6a55a5d8e5ee908347d2ce4250b15103dc8e" + integrity sha512-/PT1P6DNf7vjEEiPkVIRJkvibbqWtqnyGaBz3nfRdcxclNSnSdaLU5tfAgcD7I8Yt5i+L19s406YLl1koLnLbg== + +"@mapbox/point-geometry@0.1.0", "@mapbox/point-geometry@^0.1.0", "@mapbox/point-geometry@~0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz#8a83f9335c7860effa2eeeca254332aa0aeed8f2" + integrity sha1-ioP5M1x4YO/6Lu7KJUMyqgru2PI= + +"@mapbox/tiny-sdf@^1.1.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@mapbox/tiny-sdf/-/tiny-sdf-1.1.1.tgz#16a20c470741bfe9191deb336f46e194da4a91ff" + integrity sha512-Ihn1nZcGIswJ5XGbgFAvVumOgWpvIjBX9jiRlIl46uQG9vJOF51ViBYHF95rEZupuyQbEmhLaDPLQlU7fUTsBg== + +"@mapbox/unitbezier@^0.0.0": + version "0.0.0" + resolved "https://registry.yarnpkg.com/@mapbox/unitbezier/-/unitbezier-0.0.0.tgz#15651bd553a67b8581fb398810c98ad86a34524e" + integrity sha1-FWUb1VOme4WB+zmIEMmK2Go0Uk4= + +"@mapbox/vector-tile@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz#d3a74c90402d06e89ec66de49ec817ff53409666" + integrity sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw== + dependencies: + "@mapbox/point-geometry" "~0.1.0" + +"@mapbox/whoots-js@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe" + integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q== + "@rails/actiontext@^6.0.2-1": version "6.0.2-1" resolved "https://registry.yarnpkg.com/@rails/actiontext/-/actiontext-6.0.2-1.tgz#6ca7750f98b5321ea6ec0cd81c1a3d3c2c9046e5" @@ -1025,6 +1084,18 @@ "@turf/helpers" "6.x" "@turf/meta" "6.x" +"@turf/bbox@4.7.3": + version "4.7.3" + resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-4.7.3.tgz#e3ad4f10a7e9b41b522880d33083198199059067" + integrity sha1-461PEKfptBtSKIDTMIMZgZkFkGc= + dependencies: + "@turf/meta" "^4.7.3" + +"@turf/helpers@4.7.3": + version "4.7.3" + resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.7.3.tgz#bc312ac43cab3c532a483151c4c382c5649429e9" + integrity sha1-vDEqxDyrPFMqSDFRxMOCxWSUKek= + "@turf/helpers@6.x": version "6.1.4" resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-6.1.4.tgz#d6fd7ebe6782dd9c87dca5559bda5c48ae4c3836" @@ -1037,6 +1108,11 @@ dependencies: "@turf/helpers" "6.x" +"@turf/meta@^4.7.3": + version "4.7.4" + resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.7.4.tgz#6de2f1e9890b8f64b669e4b47c09b20893063977" + integrity sha1-beLx6YkLj2S2aeS0fAmyCJMGOXc= + "@types/color-name@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" @@ -1047,6 +1123,11 @@ resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== +"@types/geojson@*": + version "7946.0.7" + resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.7.tgz#c8fa532b60a0042219cdf173ca21a975ef0666ad" + integrity sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ== + "@types/glob@^7.1.1": version "7.1.1" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" @@ -1076,6 +1157,13 @@ resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8" integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw== +"@types/supercluster@^5.0.1": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@types/supercluster/-/supercluster-5.0.2.tgz#6d01faed39b5381a1c696f8133a26418a68abde4" + integrity sha512-5PONNyiZXHS6oiW0H1rsNQ+Apkg+cqp3jP4HRhCAcgASIj3ifrFsdj1QB5TvArqT5N8RetK6UH7873COgRZwoQ== + dependencies: + "@types/geojson" "*" + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" @@ -1431,6 +1519,11 @@ ansi-wrap@0.1.0, ansi-wrap@^0.1.0: resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= +ansicolors@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.2.1.tgz#be089599097b74a5c9c4a84a0cdbcdb62bd87aef" + integrity sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8= + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -2131,6 +2224,14 @@ caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001012, caniuse-lite@^1.0.300010 resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001019.tgz#857e3fccaad2b2feb3f1f6d8a8f62d747ea648e1" integrity sha512-6ljkLtF1KM5fQ+5ZN0wuyVvvebJxgJPTmScOMaFuQN2QuOzvRJnWSKfzQskQU5IOU4Gap3zasYPIinzwUjoj/g== +cardinal@~0.4.2: + version "0.4.4" + resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-0.4.4.tgz#ca5bb68a5b511b90fe93b9acea49bdee5c32bfe2" + integrity sha1-ylu2iltRG5D+k7ms6km97lwyv+I= + dependencies: + ansicolors "~0.2.1" + redeyed "~0.4.0" + case-sensitive-paths-webpack-plugin@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.2.0.tgz#3371ef6365ef9c25fa4b81c16ace0e9c7dc58c3e" @@ -2527,7 +2628,7 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@^1.5.0: +concat-stream@^1.5.0, concat-stream@~1.6.0: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== @@ -2849,6 +2950,11 @@ css-what@^2.1.2: resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2" integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg== +csscolorparser@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/csscolorparser/-/csscolorparser-1.0.3.tgz#b34f391eea4da8f3e98231e2ccd8df9c041f171b" + integrity sha1-s085HupNqPPpgjHizNjfnAQfFxs= + cssdb@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/cssdb/-/cssdb-4.4.0.tgz#3bf2f2a68c10f5c6a08abd92378331ee803cddb0" @@ -3011,7 +3117,7 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -deep-equal@^1.0.1: +deep-equal@1.0.1, deep-equal@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU= @@ -3215,6 +3321,11 @@ duplexify@^3.4.2, duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" +earcut@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/earcut/-/earcut-2.2.2.tgz#41b0bc35f63e0fe80da7cddff28511e7e2e80d11" + integrity sha512-eZoZPPJcUHnfRZ0PjLvx2qBordSiO8ofC3vt+qACLM95u+4DovnbYNpQtJh0DNsWj8RnxrQytD4WA8gj5cRIaQ== + ease-component@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/ease-component/-/ease-component-1.0.0.tgz#b375726db0b5b04595b77440396fec7daa5d77c9" @@ -3559,6 +3670,11 @@ esprima@^4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== +esprima@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.4.tgz#9f557e08fc3b4d26ece9dd34f8fbf476b62585ad" + integrity sha1-n1V+CPw7TSbs6d00+Pv0drYlha0= + esquery@^1.0.1: version "1.2.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.2.0.tgz#a010a519c0288f2530b3404124bfb5f02e9797fe" @@ -4122,6 +4238,11 @@ gaze@^1.0.0: dependencies: globule "^1.0.0" +geojson-vt@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/geojson-vt/-/geojson-vt-3.2.1.tgz#f8adb614d2c1d3f6ee7c4265cad4bbf3ad60c8b7" + integrity sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg== + get-caller-file@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" @@ -4166,6 +4287,11 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +gl-matrix@^3.0.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/gl-matrix/-/gl-matrix-3.2.1.tgz#2d8e35125bf854f49abded8a0c8350b1a4907a26" + integrity sha512-YYVO8jUSf6+SakL4AJmx9Jc7zAZhkJQ+WhdtX3VQe5PJdCOX6/ybY4x1vk+h94ePnjRn6uml68+QxTAJneUpvA== + glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -4311,6 +4437,11 @@ graceful-fs@^4.2.2: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== +grid-index@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/grid-index/-/grid-index-1.1.0.tgz#97f8221edec1026c8377b86446a7c71e79522ea7" + integrity sha512-HZRwumpOGUrHyxO5bqKZL0B0GlUpwtCAzZ42sgxUPniu33R1LSFH5yrIcBCHjkctCAh3mtWKcKd9J4vDDdeVHA== + gulp-exclude-gitignore@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/gulp-exclude-gitignore/-/gulp-exclude-gitignore-1.2.0.tgz#341aeb62faab428af5550da9359ceff99388f1d0" @@ -4649,7 +4780,7 @@ icss-utils@^4.0.0, icss-utils@^4.1.1: dependencies: postcss "^7.0.14" -ieee754@^1.1.4: +ieee754@^1.1.12, ieee754@^1.1.4: version "1.1.13" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== @@ -5322,6 +5453,11 @@ junit-report-builder@^1.3.1: mkdirp "^0.5.0" xmlbuilder "^10.0.0" +kdbush@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/kdbush/-/kdbush-3.0.0.tgz#f8484794d47004cc2d85ed3a79353dbe0abc2bf0" + integrity sha512-hRkd6/XW4HTsA9vjVpY9tuXJYLSlelnkTmVFu4M9/7MIYQtFcHpbugAU7UbOfjOiVSVYl2fqgBuJ32JUmRo5Ew== + killable@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892" @@ -5605,6 +5741,35 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +mapbox-gl@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/mapbox-gl/-/mapbox-gl-1.9.0.tgz#53e3e13c99483f362b07a8a763f2d61d580255a5" + integrity sha512-PKpoiB2pPUMrqFfBJpt/oA8On3zcp0adEoDS2YIC2RA6o4EZ9Sq2NPZocb64y7ra3mLUvEb7ps1pLVlPMh6y7w== + dependencies: + "@mapbox/geojson-rewind" "^0.4.0" + "@mapbox/geojson-types" "^1.0.2" + "@mapbox/jsonlint-lines-primitives" "^2.0.2" + "@mapbox/mapbox-gl-supported" "^1.4.0" + "@mapbox/point-geometry" "^0.1.0" + "@mapbox/tiny-sdf" "^1.1.0" + "@mapbox/unitbezier" "^0.0.0" + "@mapbox/vector-tile" "^1.3.1" + "@mapbox/whoots-js" "^3.1.0" + csscolorparser "~1.0.2" + earcut "^2.2.2" + geojson-vt "^3.2.1" + gl-matrix "^3.0.0" + grid-index "^1.1.0" + minimist "0.0.8" + murmurhash-js "^1.0.0" + pbf "^3.2.1" + potpack "^1.0.1" + quickselect "^2.0.0" + rw "^1.3.3" + supercluster "^7.0.0" + tinyqueue "^2.0.0" + vt-pbf "^3.1.1" + md5.js@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" @@ -5766,6 +5931,11 @@ minimatch@^3.0.0, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2: dependencies: brace-expansion "^1.1.7" +minimist@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.5.tgz#d7aa327bcecf518f9106ac6b8f003fa3bcea8566" + integrity sha1-16oye87PUY+RBqxrjwA/o7zqhWY= + minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -5912,6 +6082,11 @@ multimatch@^2.0.0: arrify "^1.0.0" minimatch "^3.0.0" +murmurhash-js@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/murmurhash-js/-/murmurhash-js-1.0.0.tgz#b06278e21fc6c37fa5313732b0412bcb6ae15f51" + integrity sha1-sGJ44h/Gw3+lMTcysEEry2rhX1E= + mute-stream@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" @@ -6644,6 +6819,14 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== +pbf@^3.0.5, pbf@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/pbf/-/pbf-3.2.1.tgz#b4c1b9e72af966cd82c6531691115cc0409ffe2a" + integrity sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ== + dependencies: + ieee754 "^1.1.12" + resolve-protobuf-schema "^2.1.0" + pbkdf2@^3.0.3: version "3.0.17" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6" @@ -7392,6 +7575,11 @@ postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.23: source-map "^0.6.1" supports-color "^6.1.0" +potpack@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/potpack/-/potpack-1.0.1.tgz#d1b1afd89e4c8f7762865ec30bd112ab767e2ebf" + integrity sha512-15vItUAbViaYrmaB/Pbw7z6qX2xENbFSTA7Ii4tgbPtasxm5v6ryKhKtL91tpWovDJzTiZqdwzhcFBCwiMVdVw== + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -7448,6 +7636,11 @@ prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.7, prop-types@^15.6.2, object-assign "^4.1.1" react-is "^16.8.1" +protocol-buffers-schema@^3.3.1: + version "3.4.0" + resolved "https://registry.yarnpkg.com/protocol-buffers-schema/-/protocol-buffers-schema-3.4.0.tgz#2f0ea31ca96627d680bf2fefae7ebfa2b6453eae" + integrity sha512-G/2kcamPF2S49W5yaMGdIpkG6+5wZF0fzBteLKgEHjbNzqjZQ85aAs1iJGto31EJaSTkNvHs5IXuHSaTLWBAiA== + proxy-addr@~2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.5.tgz#34cbd64a2d81f4b1fd21e76f9f06c8a45299ee34" @@ -7561,6 +7754,11 @@ querystringify@^2.0.0: resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e" integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA== +quickselect@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018" + integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw== + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -7630,6 +7828,17 @@ react-loadable@^5.5.0: dependencies: prop-types "^15.5.0" +react-mapbox-gl@^4.8.3: + version "4.8.3" + resolved "https://registry.yarnpkg.com/react-mapbox-gl/-/react-mapbox-gl-4.8.3.tgz#11f5901fe26a4c704a6a22e797bd69404c320e47" + integrity sha512-o5PrNjIyvF04G77/pWfHJI5G9yM4/IUEsNfGhyC5DTm+Ye/b61jJMAt1A6WLClpWeBXnDY5W7eVC6A2INMbgVA== + dependencies: + "@turf/bbox" "4.7.3" + "@turf/helpers" "4.7.3" + "@types/supercluster" "^5.0.1" + deep-equal "1.0.1" + supercluster "^7.0.0" + react-scroll-to-component@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/react-scroll-to-component/-/react-scroll-to-component-1.0.2.tgz#f260dc936c62a53e772786d7832fe0884e195354" @@ -7732,6 +7941,13 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" +redeyed@~0.4.0: + version "0.4.4" + resolved "https://registry.yarnpkg.com/redeyed/-/redeyed-0.4.4.tgz#37e990a6f2b21b2a11c2e6a48fd4135698cba97f" + integrity sha1-N+mQpvKyGyoRwuakj9QTVpjLqX8= + dependencies: + esprima "~1.0.4" + regenerate-unicode-properties@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" @@ -7925,6 +8141,13 @@ resolve-options@^1.1.0: dependencies: value-or-function "^3.0.0" +resolve-protobuf-schema@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz#9ca9a9e69cf192bbdaf1006ec1973948aa4a3758" + integrity sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ== + dependencies: + protocol-buffers-schema "^3.3.1" + resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -8015,6 +8238,11 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" +rw@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" + integrity sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q= + rxjs@^6.5.3: version "6.5.4" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c" @@ -8250,6 +8478,15 @@ shallow-clone@^3.0.0: dependencies: kind-of "^6.0.2" +sharkdown@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/sharkdown/-/sharkdown-0.1.1.tgz#64484bd0f08f347f8319e9ff947a670f6b48b1b2" + integrity sha512-exwooSpmo5s45lrexgz6Q0rFQM574wYIX3iDZ7RLLqOb7IAoQZu9nxlZODU972g19sR69OIpKP2cpHTzU+PHIg== + dependencies: + cardinal "~0.4.2" + minimist "0.0.5" + split "~0.2.10" + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -8464,6 +8701,13 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" +split@~0.2.10: + version "0.2.10" + resolved "https://registry.yarnpkg.com/split/-/split-0.2.10.tgz#67097c601d697ce1368f418f06cd201cf0521a57" + integrity sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc= + dependencies: + through "2" + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -8707,6 +8951,13 @@ stylehacks@^4.0.0: postcss "^7.0.0" postcss-selector-parser "^3.0.0" +supercluster@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/supercluster/-/supercluster-7.0.0.tgz#75d474fafb0a055db552ed7bd7bbda583f6ab321" + integrity sha512-8VuHI8ynylYQj7Qf6PBMWy1PdgsnBiIxujOgc9Z83QvJ8ualIYWNx2iMKyKeC4DZI5ntD9tz/CIwwZvIelixsA== + dependencies: + kdbush "^3.0.0" + supports-color@6.1.0, supports-color@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" @@ -8863,7 +9114,7 @@ through2@^3.0.0: dependencies: readable-stream "2 || 3" -through@^2.3.6: +through@2, through@^2.3.6: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= @@ -8895,6 +9146,11 @@ tiny-invariant@^1.0.6: resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.0.6.tgz#b3f9b38835e36a41c843a3b0907a5a7b3755de73" integrity sha512-FOyLWWVjG+aC0UqG76V53yAWdXfH8bO6FNmyZOuUrzDzK8DI3/JRY25UD7+g49JWM1LXwymsKERB+DzI0dTEQA== +tinyqueue@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08" + integrity sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA== + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -9341,6 +9597,15 @@ vm-browserify@^1.0.1: resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== +vt-pbf@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/vt-pbf/-/vt-pbf-3.1.1.tgz#b0f627e39a10ce91d943b898ed2363d21899fb82" + integrity sha512-pHjWdrIoxurpmTcbfBWXaPwSmtPAHS105253P1qyEfSTV2HJddqjM+kIHquaT/L6lVJIk9ltTGc0IxR/G47hYA== + dependencies: + "@mapbox/point-geometry" "0.1.0" + "@mapbox/vector-tile" "^1.3.1" + pbf "^3.0.5" + watchpack@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00" @@ -9522,6 +9787,11 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== +wgs84@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/wgs84/-/wgs84-0.0.0.tgz#34fdc555917b6e57cf2a282ed043710c049cdc76" + integrity sha1-NP3FVZF7blfPKigu0ENxDASc3HY= + whatwg-fetch@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" From 473ed00b6c28036bff0cd270da382bbd4a83de72 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Tue, 7 Apr 2020 18:14:07 +0200 Subject: [PATCH 2/8] Revert "Revert "Revert "feat/4893 - migrate the mapReader to mapbox-gl with react""" This reverts commit fe0b3c2215abeec7728d675810fac9b8c39bb244. --- app/javascript/components/MapReader.js | 114 ------- app/javascript/loaders/MapReader.js | 3 - app/views/shared/champs/carte/_show.html.haml | 5 +- config/initializers/assets.rb | 1 - .../initializers/content_security_policy.rb | 2 +- config/webpack/environment.js | 3 - package.json | 2 - yarn.lock | 278 +----------------- 8 files changed, 6 insertions(+), 402 deletions(-) delete mode 100644 app/javascript/components/MapReader.js delete mode 100644 app/javascript/loaders/MapReader.js diff --git a/app/javascript/components/MapReader.js b/app/javascript/components/MapReader.js deleted file mode 100644 index 3f2eaa681..000000000 --- a/app/javascript/components/MapReader.js +++ /dev/null @@ -1,114 +0,0 @@ -import React from 'react'; -import ReactMapboxGl, { ZoomControl, GeoJSONLayer } from 'react-mapbox-gl'; -import { LngLatBounds } from 'mapbox-gl'; -import PropTypes from 'prop-types'; - -const Map = ReactMapboxGl({}); - -const MapReader = ({ geoData }) => { - let [selectionCollection, cadastresCollection] = [[], []]; - - for (let selection of geoData.selection.coordinates) { - selectionCollection.push({ - type: 'Feature', - geometry: { - type: 'Polygon', - coordinates: selection - } - }); - } - - for (let cadastre of geoData.cadastres) { - cadastresCollection.push({ - type: 'Feature', - geometry: { - type: 'Polygon', - coordinates: cadastre.geometry.coordinates[0] - } - }); - } - - const selectionData = { - type: 'geojson', - data: { - type: 'FeatureCollection', - features: selectionCollection - } - }; - - const cadastresData = { - type: 'geojson', - data: { - type: 'FeatureCollection', - features: cadastresCollection - } - }; - - const polygonSelectionFill = { - 'fill-color': '#EC3323', - 'fill-opacity': 0.5 - }; - - const polygonSelectionLine = { - 'line-color': 'rgba(255, 0, 0, 1)', - 'line-width': 4 - }; - - const polygonCadastresFill = { - 'fill-color': '#9CA090', - 'fill-opacity': 0.5 - }; - - const polygonCadastresLine = { - 'line-color': 'rgba(156, 160, 144, 255)', - 'line-width': 2, - 'line-dasharray': [1, 1] - }; - - let bounds = new LngLatBounds(); - - for (let selection of selectionCollection) { - for (let coordinate of selection.geometry.coordinates[0]) { - bounds.extend(coordinate); - } - } - let [swCoords, neCoords] = [ - Object.values(bounds._sw), - Object.values(bounds._ne) - ]; - const boundData = [swCoords, neCoords]; - - return ( - - - - - - ); -}; - -MapReader.propTypes = { - geoData: PropTypes.shape({ - position: PropTypes.object, - selection: PropTypes.object, - cadastres: PropTypes.array - }) -}; - -export default MapReader; diff --git a/app/javascript/loaders/MapReader.js b/app/javascript/loaders/MapReader.js deleted file mode 100644 index adb90193f..000000000 --- a/app/javascript/loaders/MapReader.js +++ /dev/null @@ -1,3 +0,0 @@ -import Loadable from '../components/Loadable'; - -export default Loadable(() => import('../components/MapReader')); diff --git a/app/views/shared/champs/carte/_show.html.haml b/app/views/shared/champs/carte/_show.html.haml index 8aa9b4dbf..224d79cb0 100644 --- a/app/views/shared/champs/carte/_show.html.haml +++ b/app/views/shared/champs/carte/_show.html.haml @@ -1,7 +1,4 @@ - if champ.to_s.present? - - if supported_browser? - = react_component("MapReader", { geoData: champ.to_render_data } ) - - else - %p La carte n'est pas compatible avec votre navigateur. Afin de l'afficher, nous vous conseillons d'utiliser Chrome, Firefox ou Safari + .carte{ data: { geo: geo_data(champ) } } .geo-areas = render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, error: false } diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 82025de9c..1535e55ba 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -6,7 +6,6 @@ Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path Rails.application.config.assets.paths << Rails.root.join('node_modules', 'trix', 'dist') Rails.application.config.assets.paths << Rails.root.join('node_modules', 'select2', 'dist', 'css') -Rails.application.config.assets.paths << Rails.root.join('node_modules', 'mapbox-gl', 'dist') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 0f48a942b..63eaa7b7a 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -8,7 +8,7 @@ Rails.application.config.content_security_policy do |policy| # c'est trop compliqué pour être rectifié immédiatement (et sans valeur ajoutée: # c'est hardcodé dans les vues, donc pas injectable). policy.style_src :self, "*.crisp.chat", "crisp.chat", :unsafe_inline - policy.connect_src :self, "wss://*.crisp.chat", "*.crisp.chat", "*.demarches-simplifiees.fr", "in-automate.sendinblue.com", "app.franceconnect.gouv.fr", "sentry.io", "geo.api.gouv.fr", "api-adresse.data.gouv.fr", "openmaptiles.geo.data.gouv.fr", "openmaptiles.github.io" + policy.connect_src :self, "wss://*.crisp.chat", "*.crisp.chat", "*.demarches-simplifiees.fr", "in-automate.sendinblue.com", "app.franceconnect.gouv.fr", "sentry.io", "geo.api.gouv.fr", "api-adresse.data.gouv.fr" # Pour tout le reste, par défaut on accepte uniquement ce qui vient de chez nous # et dans la notification on inclue la source de l'erreur policy.default_src :self, :data, :report_sample, "fonts.gstatic.com", "in-automate.sendinblue.com", "player.vimeo.com", "app.franceconnect.gouv.fr", "sentry.io", "static.demarches-simplifiees.fr", "*.crisp.chat", "crisp.chat", "*.crisp.help", "*.sibautomation.com", "sibautomation.com", "data" diff --git a/config/webpack/environment.js b/config/webpack/environment.js index 971d33c08..97e4aa14c 100644 --- a/config/webpack/environment.js +++ b/config/webpack/environment.js @@ -9,9 +9,6 @@ const resolve = { environment.splitChunks(); environment.config.merge({ resolve }); -environment.loaders.get( - 'nodeModules' -).exclude = /(?:@?babel(?:\/|\\{1,2}|-).+)|regenerator-runtime|core-js|^webpack$|^webpack-assets-manifest$|^webpack-cli$|^webpack-sources$|^@rails\/webpacker$|^mapbox-gl$|/; // Uncoment next lines to run webpack-bundle-analyzer // const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); diff --git a/package.json b/package.json index 5cfd2b229..3c5f81061 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,11 @@ "jquery": "^3.4.1", "leaflet": "^1.6.0", "leaflet-freedraw": "^2.12.0", - "mapbox-gl": "^1.9.0", "prop-types": "^15.7.2", "react": "^16.12.0", "react-dom": "^16.12.0", "react-intersection-observer": "^8.25.2", "react-loadable": "^5.5.0", - "react-mapbox-gl": "^4.8.3", "react-scroll-to-component": "^1.0.2", "react-sortable-hoc": "^1.11.0", "react_ujs": "^2.6.1", diff --git a/yarn.lock b/yarn.lock index bddc579ad..cf106e02f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -895,65 +895,6 @@ dependencies: prop-types "^15.5.10" -"@mapbox/geojson-area@0.2.2": - version "0.2.2" - resolved "https://registry.yarnpkg.com/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz#18d7814aa36bf23fbbcc379f8e26a22927debf10" - integrity sha1-GNeBSqNr8j+7zDefjiaiKSfevxA= - dependencies: - wgs84 "0.0.0" - -"@mapbox/geojson-rewind@^0.4.0": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@mapbox/geojson-rewind/-/geojson-rewind-0.4.1.tgz#357d79300adb7fec7c1f091512988bca6458f068" - integrity sha512-mxo2MEr7izA1uOXcDsw99Kgg6xW3P4H2j4n1lmldsgviIelpssvP+jQDivFKOHrOVJDpTTi5oZJvRcHtU9Uufw== - dependencies: - "@mapbox/geojson-area" "0.2.2" - concat-stream "~1.6.0" - minimist "^1.2.5" - sharkdown "^0.1.0" - -"@mapbox/geojson-types@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@mapbox/geojson-types/-/geojson-types-1.0.2.tgz#9aecf642cb00eab1080a57c4f949a65b4a5846d6" - integrity sha512-e9EBqHHv3EORHrSfbR9DqecPNn+AmuAoQxV6aL8Xu30bJMJR1o8PZLZzpk1Wq7/NfCbuhmakHTPYRhoqLsXRnw== - -"@mapbox/jsonlint-lines-primitives@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz#ce56e539f83552b58d10d672ea4d6fc9adc7b234" - integrity sha1-zlblOfg1UrWNENZy6k1vya3HsjQ= - -"@mapbox/mapbox-gl-supported@^1.4.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@mapbox/mapbox-gl-supported/-/mapbox-gl-supported-1.5.0.tgz#f60b6a55a5d8e5ee908347d2ce4250b15103dc8e" - integrity sha512-/PT1P6DNf7vjEEiPkVIRJkvibbqWtqnyGaBz3nfRdcxclNSnSdaLU5tfAgcD7I8Yt5i+L19s406YLl1koLnLbg== - -"@mapbox/point-geometry@0.1.0", "@mapbox/point-geometry@^0.1.0", "@mapbox/point-geometry@~0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz#8a83f9335c7860effa2eeeca254332aa0aeed8f2" - integrity sha1-ioP5M1x4YO/6Lu7KJUMyqgru2PI= - -"@mapbox/tiny-sdf@^1.1.0": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@mapbox/tiny-sdf/-/tiny-sdf-1.1.1.tgz#16a20c470741bfe9191deb336f46e194da4a91ff" - integrity sha512-Ihn1nZcGIswJ5XGbgFAvVumOgWpvIjBX9jiRlIl46uQG9vJOF51ViBYHF95rEZupuyQbEmhLaDPLQlU7fUTsBg== - -"@mapbox/unitbezier@^0.0.0": - version "0.0.0" - resolved "https://registry.yarnpkg.com/@mapbox/unitbezier/-/unitbezier-0.0.0.tgz#15651bd553a67b8581fb398810c98ad86a34524e" - integrity sha1-FWUb1VOme4WB+zmIEMmK2Go0Uk4= - -"@mapbox/vector-tile@^1.3.1": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz#d3a74c90402d06e89ec66de49ec817ff53409666" - integrity sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw== - dependencies: - "@mapbox/point-geometry" "~0.1.0" - -"@mapbox/whoots-js@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe" - integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q== - "@rails/actiontext@^6.0.2-1": version "6.0.2-1" resolved "https://registry.yarnpkg.com/@rails/actiontext/-/actiontext-6.0.2-1.tgz#6ca7750f98b5321ea6ec0cd81c1a3d3c2c9046e5" @@ -1084,18 +1025,6 @@ "@turf/helpers" "6.x" "@turf/meta" "6.x" -"@turf/bbox@4.7.3": - version "4.7.3" - resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-4.7.3.tgz#e3ad4f10a7e9b41b522880d33083198199059067" - integrity sha1-461PEKfptBtSKIDTMIMZgZkFkGc= - dependencies: - "@turf/meta" "^4.7.3" - -"@turf/helpers@4.7.3": - version "4.7.3" - resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.7.3.tgz#bc312ac43cab3c532a483151c4c382c5649429e9" - integrity sha1-vDEqxDyrPFMqSDFRxMOCxWSUKek= - "@turf/helpers@6.x": version "6.1.4" resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-6.1.4.tgz#d6fd7ebe6782dd9c87dca5559bda5c48ae4c3836" @@ -1108,11 +1037,6 @@ dependencies: "@turf/helpers" "6.x" -"@turf/meta@^4.7.3": - version "4.7.4" - resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.7.4.tgz#6de2f1e9890b8f64b669e4b47c09b20893063977" - integrity sha1-beLx6YkLj2S2aeS0fAmyCJMGOXc= - "@types/color-name@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" @@ -1123,11 +1047,6 @@ resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== -"@types/geojson@*": - version "7946.0.7" - resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.7.tgz#c8fa532b60a0042219cdf173ca21a975ef0666ad" - integrity sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ== - "@types/glob@^7.1.1": version "7.1.1" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" @@ -1157,13 +1076,6 @@ resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8" integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw== -"@types/supercluster@^5.0.1": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@types/supercluster/-/supercluster-5.0.2.tgz#6d01faed39b5381a1c696f8133a26418a68abde4" - integrity sha512-5PONNyiZXHS6oiW0H1rsNQ+Apkg+cqp3jP4HRhCAcgASIj3ifrFsdj1QB5TvArqT5N8RetK6UH7873COgRZwoQ== - dependencies: - "@types/geojson" "*" - "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" @@ -1519,11 +1431,6 @@ ansi-wrap@0.1.0, ansi-wrap@^0.1.0: resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= -ansicolors@~0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.2.1.tgz#be089599097b74a5c9c4a84a0cdbcdb62bd87aef" - integrity sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8= - anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -2224,14 +2131,6 @@ caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001012, caniuse-lite@^1.0.300010 resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001019.tgz#857e3fccaad2b2feb3f1f6d8a8f62d747ea648e1" integrity sha512-6ljkLtF1KM5fQ+5ZN0wuyVvvebJxgJPTmScOMaFuQN2QuOzvRJnWSKfzQskQU5IOU4Gap3zasYPIinzwUjoj/g== -cardinal@~0.4.2: - version "0.4.4" - resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-0.4.4.tgz#ca5bb68a5b511b90fe93b9acea49bdee5c32bfe2" - integrity sha1-ylu2iltRG5D+k7ms6km97lwyv+I= - dependencies: - ansicolors "~0.2.1" - redeyed "~0.4.0" - case-sensitive-paths-webpack-plugin@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.2.0.tgz#3371ef6365ef9c25fa4b81c16ace0e9c7dc58c3e" @@ -2628,7 +2527,7 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@^1.5.0, concat-stream@~1.6.0: +concat-stream@^1.5.0: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== @@ -2950,11 +2849,6 @@ css-what@^2.1.2: resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2" integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg== -csscolorparser@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/csscolorparser/-/csscolorparser-1.0.3.tgz#b34f391eea4da8f3e98231e2ccd8df9c041f171b" - integrity sha1-s085HupNqPPpgjHizNjfnAQfFxs= - cssdb@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/cssdb/-/cssdb-4.4.0.tgz#3bf2f2a68c10f5c6a08abd92378331ee803cddb0" @@ -3117,7 +3011,7 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -deep-equal@1.0.1, deep-equal@^1.0.1: +deep-equal@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU= @@ -3321,11 +3215,6 @@ duplexify@^3.4.2, duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" -earcut@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/earcut/-/earcut-2.2.2.tgz#41b0bc35f63e0fe80da7cddff28511e7e2e80d11" - integrity sha512-eZoZPPJcUHnfRZ0PjLvx2qBordSiO8ofC3vt+qACLM95u+4DovnbYNpQtJh0DNsWj8RnxrQytD4WA8gj5cRIaQ== - ease-component@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/ease-component/-/ease-component-1.0.0.tgz#b375726db0b5b04595b77440396fec7daa5d77c9" @@ -3670,11 +3559,6 @@ esprima@^4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esprima@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.4.tgz#9f557e08fc3b4d26ece9dd34f8fbf476b62585ad" - integrity sha1-n1V+CPw7TSbs6d00+Pv0drYlha0= - esquery@^1.0.1: version "1.2.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.2.0.tgz#a010a519c0288f2530b3404124bfb5f02e9797fe" @@ -4238,11 +4122,6 @@ gaze@^1.0.0: dependencies: globule "^1.0.0" -geojson-vt@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/geojson-vt/-/geojson-vt-3.2.1.tgz#f8adb614d2c1d3f6ee7c4265cad4bbf3ad60c8b7" - integrity sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg== - get-caller-file@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" @@ -4287,11 +4166,6 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -gl-matrix@^3.0.0: - version "3.2.1" - resolved "https://registry.yarnpkg.com/gl-matrix/-/gl-matrix-3.2.1.tgz#2d8e35125bf854f49abded8a0c8350b1a4907a26" - integrity sha512-YYVO8jUSf6+SakL4AJmx9Jc7zAZhkJQ+WhdtX3VQe5PJdCOX6/ybY4x1vk+h94ePnjRn6uml68+QxTAJneUpvA== - glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -4437,11 +4311,6 @@ graceful-fs@^4.2.2: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== -grid-index@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/grid-index/-/grid-index-1.1.0.tgz#97f8221edec1026c8377b86446a7c71e79522ea7" - integrity sha512-HZRwumpOGUrHyxO5bqKZL0B0GlUpwtCAzZ42sgxUPniu33R1LSFH5yrIcBCHjkctCAh3mtWKcKd9J4vDDdeVHA== - gulp-exclude-gitignore@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/gulp-exclude-gitignore/-/gulp-exclude-gitignore-1.2.0.tgz#341aeb62faab428af5550da9359ceff99388f1d0" @@ -4780,7 +4649,7 @@ icss-utils@^4.0.0, icss-utils@^4.1.1: dependencies: postcss "^7.0.14" -ieee754@^1.1.12, ieee754@^1.1.4: +ieee754@^1.1.4: version "1.1.13" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== @@ -5453,11 +5322,6 @@ junit-report-builder@^1.3.1: mkdirp "^0.5.0" xmlbuilder "^10.0.0" -kdbush@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/kdbush/-/kdbush-3.0.0.tgz#f8484794d47004cc2d85ed3a79353dbe0abc2bf0" - integrity sha512-hRkd6/XW4HTsA9vjVpY9tuXJYLSlelnkTmVFu4M9/7MIYQtFcHpbugAU7UbOfjOiVSVYl2fqgBuJ32JUmRo5Ew== - killable@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892" @@ -5741,35 +5605,6 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -mapbox-gl@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/mapbox-gl/-/mapbox-gl-1.9.0.tgz#53e3e13c99483f362b07a8a763f2d61d580255a5" - integrity sha512-PKpoiB2pPUMrqFfBJpt/oA8On3zcp0adEoDS2YIC2RA6o4EZ9Sq2NPZocb64y7ra3mLUvEb7ps1pLVlPMh6y7w== - dependencies: - "@mapbox/geojson-rewind" "^0.4.0" - "@mapbox/geojson-types" "^1.0.2" - "@mapbox/jsonlint-lines-primitives" "^2.0.2" - "@mapbox/mapbox-gl-supported" "^1.4.0" - "@mapbox/point-geometry" "^0.1.0" - "@mapbox/tiny-sdf" "^1.1.0" - "@mapbox/unitbezier" "^0.0.0" - "@mapbox/vector-tile" "^1.3.1" - "@mapbox/whoots-js" "^3.1.0" - csscolorparser "~1.0.2" - earcut "^2.2.2" - geojson-vt "^3.2.1" - gl-matrix "^3.0.0" - grid-index "^1.1.0" - minimist "0.0.8" - murmurhash-js "^1.0.0" - pbf "^3.2.1" - potpack "^1.0.1" - quickselect "^2.0.0" - rw "^1.3.3" - supercluster "^7.0.0" - tinyqueue "^2.0.0" - vt-pbf "^3.1.1" - md5.js@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" @@ -5931,11 +5766,6 @@ minimatch@^3.0.0, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2: dependencies: brace-expansion "^1.1.7" -minimist@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.5.tgz#d7aa327bcecf518f9106ac6b8f003fa3bcea8566" - integrity sha1-16oye87PUY+RBqxrjwA/o7zqhWY= - minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -6082,11 +5912,6 @@ multimatch@^2.0.0: arrify "^1.0.0" minimatch "^3.0.0" -murmurhash-js@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/murmurhash-js/-/murmurhash-js-1.0.0.tgz#b06278e21fc6c37fa5313732b0412bcb6ae15f51" - integrity sha1-sGJ44h/Gw3+lMTcysEEry2rhX1E= - mute-stream@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" @@ -6819,14 +6644,6 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -pbf@^3.0.5, pbf@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/pbf/-/pbf-3.2.1.tgz#b4c1b9e72af966cd82c6531691115cc0409ffe2a" - integrity sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ== - dependencies: - ieee754 "^1.1.12" - resolve-protobuf-schema "^2.1.0" - pbkdf2@^3.0.3: version "3.0.17" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6" @@ -7575,11 +7392,6 @@ postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.23: source-map "^0.6.1" supports-color "^6.1.0" -potpack@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/potpack/-/potpack-1.0.1.tgz#d1b1afd89e4c8f7762865ec30bd112ab767e2ebf" - integrity sha512-15vItUAbViaYrmaB/Pbw7z6qX2xENbFSTA7Ii4tgbPtasxm5v6ryKhKtL91tpWovDJzTiZqdwzhcFBCwiMVdVw== - prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -7636,11 +7448,6 @@ prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.7, prop-types@^15.6.2, object-assign "^4.1.1" react-is "^16.8.1" -protocol-buffers-schema@^3.3.1: - version "3.4.0" - resolved "https://registry.yarnpkg.com/protocol-buffers-schema/-/protocol-buffers-schema-3.4.0.tgz#2f0ea31ca96627d680bf2fefae7ebfa2b6453eae" - integrity sha512-G/2kcamPF2S49W5yaMGdIpkG6+5wZF0fzBteLKgEHjbNzqjZQ85aAs1iJGto31EJaSTkNvHs5IXuHSaTLWBAiA== - proxy-addr@~2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.5.tgz#34cbd64a2d81f4b1fd21e76f9f06c8a45299ee34" @@ -7754,11 +7561,6 @@ querystringify@^2.0.0: resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e" integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA== -quickselect@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018" - integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw== - randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -7828,17 +7630,6 @@ react-loadable@^5.5.0: dependencies: prop-types "^15.5.0" -react-mapbox-gl@^4.8.3: - version "4.8.3" - resolved "https://registry.yarnpkg.com/react-mapbox-gl/-/react-mapbox-gl-4.8.3.tgz#11f5901fe26a4c704a6a22e797bd69404c320e47" - integrity sha512-o5PrNjIyvF04G77/pWfHJI5G9yM4/IUEsNfGhyC5DTm+Ye/b61jJMAt1A6WLClpWeBXnDY5W7eVC6A2INMbgVA== - dependencies: - "@turf/bbox" "4.7.3" - "@turf/helpers" "4.7.3" - "@types/supercluster" "^5.0.1" - deep-equal "1.0.1" - supercluster "^7.0.0" - react-scroll-to-component@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/react-scroll-to-component/-/react-scroll-to-component-1.0.2.tgz#f260dc936c62a53e772786d7832fe0884e195354" @@ -7941,13 +7732,6 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" -redeyed@~0.4.0: - version "0.4.4" - resolved "https://registry.yarnpkg.com/redeyed/-/redeyed-0.4.4.tgz#37e990a6f2b21b2a11c2e6a48fd4135698cba97f" - integrity sha1-N+mQpvKyGyoRwuakj9QTVpjLqX8= - dependencies: - esprima "~1.0.4" - regenerate-unicode-properties@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" @@ -8141,13 +7925,6 @@ resolve-options@^1.1.0: dependencies: value-or-function "^3.0.0" -resolve-protobuf-schema@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz#9ca9a9e69cf192bbdaf1006ec1973948aa4a3758" - integrity sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ== - dependencies: - protocol-buffers-schema "^3.3.1" - resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -8238,11 +8015,6 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -rw@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" - integrity sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q= - rxjs@^6.5.3: version "6.5.4" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c" @@ -8478,15 +8250,6 @@ shallow-clone@^3.0.0: dependencies: kind-of "^6.0.2" -sharkdown@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/sharkdown/-/sharkdown-0.1.1.tgz#64484bd0f08f347f8319e9ff947a670f6b48b1b2" - integrity sha512-exwooSpmo5s45lrexgz6Q0rFQM574wYIX3iDZ7RLLqOb7IAoQZu9nxlZODU972g19sR69OIpKP2cpHTzU+PHIg== - dependencies: - cardinal "~0.4.2" - minimist "0.0.5" - split "~0.2.10" - shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -8701,13 +8464,6 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" -split@~0.2.10: - version "0.2.10" - resolved "https://registry.yarnpkg.com/split/-/split-0.2.10.tgz#67097c601d697ce1368f418f06cd201cf0521a57" - integrity sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc= - dependencies: - through "2" - sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -8951,13 +8707,6 @@ stylehacks@^4.0.0: postcss "^7.0.0" postcss-selector-parser "^3.0.0" -supercluster@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/supercluster/-/supercluster-7.0.0.tgz#75d474fafb0a055db552ed7bd7bbda583f6ab321" - integrity sha512-8VuHI8ynylYQj7Qf6PBMWy1PdgsnBiIxujOgc9Z83QvJ8ualIYWNx2iMKyKeC4DZI5ntD9tz/CIwwZvIelixsA== - dependencies: - kdbush "^3.0.0" - supports-color@6.1.0, supports-color@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" @@ -9114,7 +8863,7 @@ through2@^3.0.0: dependencies: readable-stream "2 || 3" -through@2, through@^2.3.6: +through@^2.3.6: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= @@ -9146,11 +8895,6 @@ tiny-invariant@^1.0.6: resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.0.6.tgz#b3f9b38835e36a41c843a3b0907a5a7b3755de73" integrity sha512-FOyLWWVjG+aC0UqG76V53yAWdXfH8bO6FNmyZOuUrzDzK8DI3/JRY25UD7+g49JWM1LXwymsKERB+DzI0dTEQA== -tinyqueue@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08" - integrity sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA== - tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -9597,15 +9341,6 @@ vm-browserify@^1.0.1: resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== -vt-pbf@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/vt-pbf/-/vt-pbf-3.1.1.tgz#b0f627e39a10ce91d943b898ed2363d21899fb82" - integrity sha512-pHjWdrIoxurpmTcbfBWXaPwSmtPAHS105253P1qyEfSTV2HJddqjM+kIHquaT/L6lVJIk9ltTGc0IxR/G47hYA== - dependencies: - "@mapbox/point-geometry" "0.1.0" - "@mapbox/vector-tile" "^1.3.1" - pbf "^3.0.5" - watchpack@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00" @@ -9787,11 +9522,6 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== -wgs84@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/wgs84/-/wgs84-0.0.0.tgz#34fdc555917b6e57cf2a282ed043710c049cdc76" - integrity sha1-NP3FVZF7blfPKigu0ENxDASc3HY= - whatwg-fetch@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" From 8ceb55594124092518352d407ed7a15b35fe32e7 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Apr 2020 11:57:06 +0200 Subject: [PATCH 3/8] routes: cleanup attachment routes --- config/routes.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 4081570cb..be2d334e4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -124,8 +124,7 @@ Rails.application.routes.draw do put 'piece_justificative/:champ_id', to: 'piece_justificative#update', as: :piece_justificative end - get 'attachments/:id', to: 'attachments#show', as: :attachment - delete 'attachments/:id', to: 'attachments#destroy' + resources :attachments, only: [:show, :destroy] get "patron" => "root#patron" get "accessibilite" => "root#accessibilite" From 0077ff4b756b68f223daf6f69d3fe5e766b33554 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Apr 2020 12:05:55 +0200 Subject: [PATCH 4/8] attachments: refactor the controller specs --- .../attachments_controller_spec.rb | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/spec/controllers/attachments_controller_spec.rb b/spec/controllers/attachments_controller_spec.rb index 706912383..0f1d71184 100644 --- a/spec/controllers/attachments_controller_spec.rb +++ b/spec/controllers/attachments_controller_spec.rb @@ -1,5 +1,39 @@ describe AttachmentsController, type: :controller do let(:user) { create(:user) } + let(:attachment) { champ.piece_justificative_file.attachment } + let(:dossier) { create(:dossier, user: user) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) } + let(:signed_id) { attachment.blob.signed_id } + + describe '#show' do + render_views + + let(:format) { :js } + + subject do + get :show, params: { id: attachment.id, signed_id: signed_id }, format: format + end + + context 'when authenticated' do + before { sign_in(user) } + + context 'when requesting Javascript' do + let(:format) { :js } + + it { is_expected.to have_http_status(200) } + + it 'renders JS that replaces the attachment HTML' do + subject + expect(response.body).to have_text(".attachment-link[data-attachment-id=\"#{attachment.id}\"]") + end + end + + end + + context 'when not authenticated' do + it { is_expected.to have_http_status(401) } + end + end describe '#destroy' do render_views @@ -19,7 +53,7 @@ describe AttachmentsController, type: :controller do context 'and dossier is owned by user' do it { is_expected.to have_http_status(200) } - it do + it 'removes the attachment' do subject expect(champ.reload.piece_justificative_file.attached?).to be(false) end @@ -30,7 +64,7 @@ describe AttachmentsController, type: :controller do it { is_expected.to have_http_status(404) } - it do + it 'doesn’t remove the attachment' do subject expect(champ.reload.piece_justificative_file.attached?).to be(true) end @@ -40,7 +74,7 @@ describe AttachmentsController, type: :controller do context 'when not authenticated' do it { is_expected.to have_http_status(401) } - it do + it 'doesn’t remove the attachment' do subject expect(champ.reload.piece_justificative_file.attached?).to be(true) end From b748e9773f9a2b888430ac6658666435373ceb26 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Apr 2020 10:16:22 +0000 Subject: [PATCH 5/8] attachments: fix opening the delete link directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When cliking on the "Delete attachment" link, and opening the URL in a new tab, the `DELETE /attachements/:id` will become `GET /attachments/:id` – which will cause the `show` action to be routed with an html format (instead of JS). In that case, we don't want to throw an error at the user face. Instead simply re-render the dossier page (if any). Fix a long-standing error in Sentry. --- app/controllers/attachments_controller.rb | 5 +++++ spec/controllers/attachments_controller_spec.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 93f86f718..b187eda83 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -5,6 +5,11 @@ class AttachmentsController < ApplicationController def show @attachment = @blob.attachments.find(params[:id]) @user_can_upload = params[:user_can_upload] + + respond_to do |format| + format.js + format.html { redirect_back(fallback_location: @attachment.record&.dossier || root_path) } + end end def destroy diff --git a/spec/controllers/attachments_controller_spec.rb b/spec/controllers/attachments_controller_spec.rb index 0f1d71184..e460ca34b 100644 --- a/spec/controllers/attachments_controller_spec.rb +++ b/spec/controllers/attachments_controller_spec.rb @@ -28,6 +28,12 @@ describe AttachmentsController, type: :controller do end end + context 'when the user opens the delete link in a new tab' do + let(:format) { :html } + + it { is_expected.to have_http_status(302) } + it { is_expected.to redirect_to(dossier_path(dossier)) } + end end context 'when not authenticated' do From 38b0bd645c4999db6188d6046933ea7676e54dd5 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Apr 2020 12:41:02 +0200 Subject: [PATCH 6/8] javascript: fix clicking on the icon of the auto-upload Retry button When clicking on the icon, `event target` would be the icon, not the button. However delegates configures `this` to be the requested event target. --- app/javascript/new_design/dossiers/auto-upload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/new_design/dossiers/auto-upload.js b/app/javascript/new_design/dossiers/auto-upload.js index 627a61000..784fdd314 100644 --- a/app/javascript/new_design/dossiers/auto-upload.js +++ b/app/javascript/new_design/dossiers/auto-upload.js @@ -16,8 +16,8 @@ delegate('change', fileInputSelector, event => { }); const retryButtonSelector = `button.attachment-error-retry`; -delegate('click', retryButtonSelector, event => { - const inputSelector = event.target.dataset.inputTarget; +delegate('click', retryButtonSelector, function() { + const inputSelector = this.dataset.inputTarget; const input = document.querySelector(inputSelector); startUpload(input); }); From 444732b1173b64acdfdd03b7dc28c1a08f5dbd82 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Apr 2020 12:44:31 +0200 Subject: [PATCH 7/8] javascript: don't allow to retry on direct upload 422 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the authenticity token is invalid, the creation of the blob before the direct upload returns a 422. In that case, the token will never become valid again, and it is useless to try again. Don’t show the "Retry" button in this case. NB: of course the real fix is to understand why the authenticity token is so often invalid – but this will be for later. --- .../new_design/dossiers/auto-upload-controller.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/javascript/new_design/dossiers/auto-upload-controller.js b/app/javascript/new_design/dossiers/auto-upload-controller.js index b26601468..ad4eec39c 100644 --- a/app/javascript/new_design/dossiers/auto-upload-controller.js +++ b/app/javascript/new_design/dossiers/auto-upload-controller.js @@ -93,7 +93,18 @@ export default class AutoUploadController { this.input.disabled = false; } + _isError422(error) { + // Ajax errors have an xhr attribute + if (error && error.xhr && error.xhr.status == 422) return true; + // Rails DirectUpload errors are returned as a String, e.g. 'Error creating Blob for "Demain.txt". Status: 422' + if (error && error.toString().includes('422')) return true; + + return false; + } + _messageFromError(error) { + let allowRetry = !this._isError422(error); + if ( error.xhr && error.xhr.status == 422 && @@ -104,13 +115,13 @@ export default class AutoUploadController { return { title: error.response.errors[0], description: '', - retry: false + retry: allowRetry }; } else { return { title: 'Une erreur s’est produite pendant l’envoi du fichier.', description: error.message || error.toString(), - retry: true + retry: allowRetry }; } } From 72d003b62c89d5ddf5a829ce6e28075bbeadd375 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Apr 2020 16:53:46 +0200 Subject: [PATCH 8/8] javascript: fix missign argument to catch Some browers complain about this. --- app/views/users/feedbacks/create.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/feedbacks/create.js.erb b/app/views/users/feedbacks/create.js.erb index 3923caada..3e7422464 100644 --- a/app/views/users/feedbacks/create.js.erb +++ b/app/views/users/feedbacks/create.js.erb @@ -1,6 +1,6 @@ try { window.scroll({ top: 0, left: 0, behavior: 'smooth' }); -} catch { +} catch(e) { window.scroll(0, 0); } <%= remove_element('#user-satisfaction') %>