From d44df9cc2a97a413ccd4c866cc6da5c6fde3dd03 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 14 May 2020 13:36:25 +0200 Subject: [PATCH 01/10] Fix map apercu --- app/javascript/components/MapEditor/index.js | 15 +++++++++------ .../dossiers/editable_champs/_carte.html.haml | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/javascript/components/MapEditor/index.js b/app/javascript/components/MapEditor/index.js index 2f2e0d2b3..aa329b524 100644 --- a/app/javascript/components/MapEditor/index.js +++ b/app/javascript/components/MapEditor/index.js @@ -23,7 +23,9 @@ function filterFeatureCollection(featureCollection, source) { }; } -const MapEditor = ({ featureCollection, url }) => { +function noop() {} + +function MapEditor({ featureCollection, url, preview }) { const drawControl = useRef(null); const [style, setStyle] = useState('ortho'); const [coords, setCoords] = useState([1.7, 46.9]); @@ -174,9 +176,9 @@ const MapEditor = ({ featureCollection, url }) => { /> { ); -}; +} MapEditor.propTypes = { featureCollection: PropTypes.shape({ @@ -210,7 +212,8 @@ MapEditor.propTypes = { features: PropTypes.array, id: PropTypes.number }), - url: PropTypes.string + url: PropTypes.string, + preview: PropTypes.bool }; export default MapEditor; diff --git a/app/views/shared/dossiers/editable_champs/_carte.html.haml b/app/views/shared/dossiers/editable_champs/_carte.html.haml index 4464306f9..73e511e40 100644 --- a/app/views/shared/dossiers/editable_champs/_carte.html.haml +++ b/app/views/shared/dossiers/editable_champs/_carte.html.haml @@ -1,5 +1,6 @@ - if feature_enabled?(:new_map_editor) - = react_component("MapEditor", { featureCollection: champ.to_feature_collection, url: champs_carte_features_path(champ) }, class: "carte-#{champ.id}") + - preview = !champ.persisted? + = react_component("MapEditor", { featureCollection: champ.to_feature_collection, url: champs_carte_features_path(preview ? 'preview' : champ), preview: preview }, class: "carte-#{champ.id}") - else .toolbar %button.button.primary.new-area Ajouter une zone From b1fbc785acc0dc5ddeb9b181cd46163c93118ee4 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 14 May 2020 14:35:05 +0200 Subject: [PATCH 02/10] update graphql gem --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3f1773f27..a8828c385 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -253,7 +253,7 @@ GEM i18n (>= 0.7) multi_json request_store (>= 1.0) - graphql (1.10.6) + graphql (1.10.9) graphql-batch (0.4.2) graphql (>= 1.3, < 2) promise.rb (~> 0.7.2) From f6ef7944c105f6eaf05ce900b8534d6b495788d1 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 24 Mar 2020 15:16:27 +0100 Subject: [PATCH 03/10] add new logo --- .../images/republique-francaise-logo.svg | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 app/assets/images/republique-francaise-logo.svg diff --git a/app/assets/images/republique-francaise-logo.svg b/app/assets/images/republique-francaise-logo.svg new file mode 100644 index 000000000..d0c76d92a --- /dev/null +++ b/app/assets/images/republique-francaise-logo.svg @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3c751ac69681adee0bdca80899f881923dcaad05 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 20 Apr 2020 16:27:40 +0200 Subject: [PATCH 04/10] small logo for procedures --- app/assets/stylesheets/left_panel.scss | 4 ++++ app/models/procedure.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/left_panel.scss b/app/assets/stylesheets/left_panel.scss index e35b6494f..99898800f 100644 --- a/app/assets/stylesheets/left_panel.scss +++ b/app/assets/stylesheets/left_panel.scss @@ -81,6 +81,10 @@ margin: 5px auto 0 20px; width: 150px; } + + img { + background-color: #FFFFFF; + } } #action-block { diff --git a/app/models/procedure.rb b/app/models/procedure.rb index e42bb4954..5da6426ad 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -506,7 +506,7 @@ class Procedure < ApplicationRecord if logo.attached? Rails.application.routes.url_helpers.url_for(logo) else - ActionController::Base.helpers.image_url("marianne.svg") + ActionController::Base.helpers.image_url("republique-francaise-logo.svg") end end From c5d2b4abd8e6a2b642ee13a2aafd8914c6e4bcf6 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 14 May 2020 11:14:35 +0200 Subject: [PATCH 05/10] new logo in footer on home --- app/assets/stylesheets/new_design/new_footer.scss | 7 +++++++ app/views/root/_footer.html.haml | 1 + 2 files changed, 8 insertions(+) diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index 1c39e723d..c64c24d50 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -84,6 +84,13 @@ footer { height: 25px; } +.footer-logo-france { + @include ie-compatible-background-image("republique-francaise-logo.svg"); + + width: 105px; + height: 90px; +} + .footer-link a, .footer-text a { color: $black; diff --git a/app/views/root/_footer.html.haml b/app/views/root/_footer.html.haml index 038e565a6..6e41eb4aa 100644 --- a/app/views/root/_footer.html.haml +++ b/app/views/root/_footer.html.haml @@ -15,6 +15,7 @@ %span.footer-logo.footer-logo-dinum{ role: 'img', 'aria-label': 'DINUM' } = link_to "https://beta.gouv.fr", title: "le site de Beta.gouv.fr" do %span.footer-logo.footer-logo-beta-gouv-fr{ role: 'img', 'aria-label': 'beta.gouv.fr' } + %span.footer-logo.footer-logo-france{ role: 'img', 'aria-label': 'République Française' } %li.footer-column %ul.footer-links From 1702903ffd76bc9e9e479bdd307e75476f606749 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 14 May 2020 11:17:52 +0200 Subject: [PATCH 06/10] ajout d'une alternative sur la marianne en header --- app/views/layouts/_new_header.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index aba320f21..67eaa3a02 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -19,7 +19,7 @@ = link_to 'Revenir en arrière', url_for(:back), class: "button", title: "Revenir sur le site de mon administration" - else = link_to root_path_for_profile(nav_bar_profile), class: 'header-logo', title: "Aller à la page d'accueil de demarches-simplifiees.fr" do - = image_tag 'marianne.svg', alt: '', width: 65 + = image_tag 'marianne.svg', alt: 'Liberté, égalité, fraternité', width: 65 %span.big.site-title> demarches-simplifiees.fr %span.small.site-title> d-s.fr From 46940ec2a71b5972a63f03a14e20ba76f0e9d4ce Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 14 May 2020 14:20:36 +0200 Subject: [PATCH 07/10] compression du nouveau logo via svgo --- .../images/republique-francaise-logo.svg | 179 +----------------- 1 file changed, 1 insertion(+), 178 deletions(-) diff --git a/app/assets/images/republique-francaise-logo.svg b/app/assets/images/republique-francaise-logo.svg index d0c76d92a..0f1cd3d4c 100644 --- a/app/assets/images/republique-francaise-logo.svg +++ b/app/assets/images/republique-francaise-logo.svg @@ -1,178 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file From a49581cbe99060036c11ff804f4b950a403ee485 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 14 May 2020 14:50:14 +0200 Subject: [PATCH 08/10] replaced marianne logo for homepage --- app/assets/images/marianne.svg | 2 +- app/views/layouts/_new_header.haml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/images/marianne.svg b/app/assets/images/marianne.svg index 8ed835709..9690583ea 100644 --- a/app/assets/images/marianne.svg +++ b/app/assets/images/marianne.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 67eaa3a02..7967eca97 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -14,12 +14,13 @@ %header.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border", role: 'banner' } .header-inner-content - .flex.align-center + .flex.align-center.justify-center - if params[:controller] == 'users/commencer' = link_to 'Revenir en arrière', url_for(:back), class: "button", title: "Revenir sur le site de mon administration" - else - = link_to root_path_for_profile(nav_bar_profile), class: 'header-logo', title: "Aller à la page d'accueil de demarches-simplifiees.fr" do - = image_tag 'marianne.svg', alt: 'Liberté, égalité, fraternité', width: 65 + = link_to root_path_for_profile(nav_bar_profile), class: 'header-logo justify-center', title: "Aller à la page d'accueil de demarches-simplifiees.fr" do + = image_tag 'marianne.svg', alt: 'Liberté, égalité, fraternité', width: '65px' + = link_to root_path_for_profile(nav_bar_profile), class: 'header-logo justify-center', title: "Aller à la page d'accueil de demarches-simplifiees.fr" do %span.big.site-title> demarches-simplifiees.fr %span.small.site-title> d-s.fr From 93bb5283ffa9663a95cd40c7850f2bb296635185 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 14 May 2020 17:39:07 +0200 Subject: [PATCH 09/10] app: remove the feature flag for pieces justificatives auto-upload The feature works as intended: we can remove the feature flag. --- app/helpers/champ_helper.rb | 2 +- config/initializers/flipper.rb | 1 - spec/features/users/brouillon_spec.rb | 151 ++++++++++---------------- 3 files changed, 58 insertions(+), 96 deletions(-) diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb index 36416f759..da0d45927 100644 --- a/app/helpers/champ_helper.rb +++ b/app/helpers/champ_helper.rb @@ -33,7 +33,7 @@ module ChampHelper end def auto_attach_url(form, object) - if feature_enabled?(:autoupload_dossier_attachments) && object.is_a?(Champ) && object.persisted? && object.public? + if object.is_a?(Champ) && object.persisted? && object.public? champs_piece_justificative_url(object.id) end end diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb index 14bb0105a..f7408c231 100644 --- a/config/initializers/flipper.rb +++ b/config/initializers/flipper.rb @@ -31,7 +31,6 @@ features = [ :insee_api_v3, :instructeur_bypass_email_login_token, :autosave_dossier_draft, - :autoupload_dossier_attachments, :new_map_editor, :maintenance_mode, :mini_profiler, diff --git a/spec/features/users/brouillon_spec.rb b/spec/features/users/brouillon_spec.rb index cd992974f..8b6a02d2d 100644 --- a/spec/features/users/brouillon_spec.rb +++ b/spec/features/users/brouillon_spec.rb @@ -165,114 +165,77 @@ feature 'The user' do create(:procedure, :published, :for_individual, types_de_champ: tdcs) end - scenario 'adding, replacing and removing attachments', js: true do - log_in(user, procedure_with_pj) + scenario 'add an attachment', js: true do + log_in(user, procedure_with_pjs) fill_individual - # Add an attachment - find_field('Pièce justificative').attach_file(Rails.root + 'spec/fixtures/files/file.pdf') - click_on 'Enregistrer le brouillon' - expect(page).to have_content('Votre brouillon a bien été sauvegardé') + # Add attachments + find_field('Pièce justificative 1').attach_file(Rails.root + 'spec/fixtures/files/file.pdf') + find_field('Pièce justificative 2').attach_file(Rails.root + 'spec/fixtures/files/RIB.pdf') + + # Expect the files to be uploaded immediately + expect(page).to have_text('analyse antivirus en cours', count: 2) expect(page).to have_text('file.pdf') - expect(page).to have_text('analyse antivirus en cours') - - # Mark file as scanned and clean - attachment = ActiveStorage::Attachment.last - attachment.blob.update(metadata: attachment.blob.metadata.merge(scanned_at: Time.zone.now, virus_scan_result: ActiveStorage::VirusScanner::SAFE)) - within('.attachment') { click_on 'rafraichir' } - expect(page).to have_link('file.pdf') - expect(page).to have_no_content('analyse antivirus en cours') - - # Replace the attachment - within('.attachment') { click_on 'Remplacer' } - find_field('Pièce justificative').attach_file(Rails.root + 'spec/fixtures/files/RIB.pdf') - click_on 'Enregistrer le brouillon' - expect(page).to have_no_text('file.pdf') expect(page).to have_text('RIB.pdf') - # Remove the attachment - within('.attachment') { click_on 'Supprimer' } - expect(page).to have_content('La pièce jointe a bien été supprimée') - expect(page).to have_no_text('RIB.pdf') + # Expect the submit buttons to be enabled + expect(page).to have_button('Enregistrer le brouillon', disabled: false) + expect(page).to have_button('Déposer le dossier', disabled: false) + + # Reload the current page + visit current_path + + # Expect the files to have been saved on the dossier + expect(page).to have_text('file.pdf') + expect(page).to have_text('RIB.pdf') end - context 'when the auto-uploads of attachments is enabled' do - before do - Flipper.enable_actor(:autoupload_dossier_attachments, user) - end + # TODO: once we're running on Rails 6, re-enable the validator on PieceJustificativeChamp, + # and unmark this spec as pending. + # + # See piece_justificative_champ.rb + # See https://github.com/betagouv/demarches-simplifiees.fr/issues/4926 + scenario 'add an invalid attachment', js: true, pending: true do + log_in(user, procedure_with_pjs) + fill_individual - scenario 'add an attachment', js: true do - log_in(user, procedure_with_pjs) - fill_individual + # Test invalid file type + attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/invalid_file_format.json') + expect(page).to have_text('La pièce justificative n’est pas d’un type accepté') + expect(page).to have_no_button('Ré-essayer', visible: true) - # Add attachments - find_field('Pièce justificative 1').attach_file(Rails.root + 'spec/fixtures/files/file.pdf') - find_field('Pièce justificative 2').attach_file(Rails.root + 'spec/fixtures/files/RIB.pdf') + # Replace the file by another with a valid type + attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/piece_justificative_0.pdf') + expect(page).to have_no_text('La pièce justificative n’est pas d’un type accepté') + expect(page).to have_text('analyse antivirus en cours') + expect(page).to have_text('piece_justificative_0.pdf') + end - # Expect the files to be uploaded immediately - expect(page).to have_text('analyse antivirus en cours', count: 2) - expect(page).to have_text('file.pdf') - expect(page).to have_text('RIB.pdf') + scenario 'retry on transcient upload error', js: true do + log_in(user, procedure_with_pjs) + fill_individual - # Expect the submit buttons to be enabled - expect(page).to have_button('Enregistrer le brouillon', disabled: false) - expect(page).to have_button('Déposer le dossier', disabled: false) + # Test auto-upload failure + logout(:user) # Make the subsequent auto-upload request fail + attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/file.pdf') + expect(page).to have_text('Une erreur s’est produite pendant l’envoi du fichier') + expect(page).to have_button('Ré-essayer', visible: true) + expect(page).to have_button('Enregistrer le brouillon', disabled: false) + expect(page).to have_button('Déposer le dossier', disabled: false) - # Reload the current page - visit current_path + # Test that retrying after a failure works + login_as(user, scope: :user) # Make the auto-upload request work again + click_on('Ré-essayer', visible: true) + expect(page).to have_text('analyse antivirus en cours') + expect(page).to have_text('file.pdf') + expect(page).to have_button('Enregistrer le brouillon', disabled: false) + expect(page).to have_button('Déposer le dossier', disabled: false) - # Expect the files to have been saved on the dossier - expect(page).to have_text('file.pdf') - expect(page).to have_text('RIB.pdf') - end + # Reload the current page + visit current_path - # TODO: once we're running on Rails 6, re-enable the validator on PieceJustificativeChamp, - # and unmark this spec as pending. - # - # See piece_justificative_champ.rb - # See https://github.com/betagouv/demarches-simplifiees.fr/issues/4926 - scenario 'add an invalid attachment', js: true, pending: true do - log_in(user, procedure_with_pjs) - fill_individual - - # Test invalid file type - attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/invalid_file_format.json') - expect(page).to have_text('La pièce justificative n’est pas d’un type accepté') - expect(page).to have_no_button('Ré-essayer', visible: true) - - # Replace the file by another with a valid type - attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/piece_justificative_0.pdf') - expect(page).to have_no_text('La pièce justificative n’est pas d’un type accepté') - expect(page).to have_text('analyse antivirus en cours') - expect(page).to have_text('piece_justificative_0.pdf') - end - - scenario 'retry on transcient upload error', js: true do - log_in(user, procedure_with_pjs) - fill_individual - - # Test auto-upload failure - logout(:user) # Make the subsequent auto-upload request fail - attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/file.pdf') - expect(page).to have_text('Une erreur s’est produite pendant l’envoi du fichier') - expect(page).to have_button('Ré-essayer', visible: true) - expect(page).to have_button('Enregistrer le brouillon', disabled: false) - expect(page).to have_button('Déposer le dossier', disabled: false) - - # Test that retrying after a failure works - login_as(user, scope: :user) # Make the auto-upload request work again - click_on('Ré-essayer', visible: true) - expect(page).to have_text('analyse antivirus en cours') - expect(page).to have_text('file.pdf') - expect(page).to have_button('Enregistrer le brouillon', disabled: false) - expect(page).to have_button('Déposer le dossier', disabled: false) - - # Reload the current page - visit current_path - - # Expect the file to have been saved on the dossier - expect(page).to have_text('file.pdf') - end + # Expect the file to have been saved on the dossier + expect(page).to have_text('file.pdf') end context 'when the draft autosave is enabled' do From db5fd9bd0f414cd8fb6022eafa95ab9c94e70828 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Fri, 15 May 2020 13:44:50 +0200 Subject: [PATCH 10/10] fix bug on mandatory carto champ for the new map editor --- app/models/champ.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/champ.rb b/app/models/champ.rb index 7f2974db0..eae3ac82b 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -44,7 +44,7 @@ class Champ < ApplicationRecord def blank? case type_de_champ.type_champ when TypeDeChamp.type_champs.fetch(:carte) - value.blank? || value == '[]' + geo_areas.blank? || value == '[]' else value.blank? end