From 0641069d0b6157cbbe08d7cf2d890b5249b81a92 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 28 Jul 2022 11:50:47 +0200 Subject: [PATCH 1/4] chore(bundle): update view_component, no need for use_global_output_buffer anymore This fix contact form and captcha invisibility due to buffer issues. Closes #7627 --- Gemfile.lock | 2 +- config/application.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 283f14923..bfffe1000 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -741,7 +741,7 @@ GEM activemodel (>= 3.0.0) public_suffix vcr (6.1.0) - view_component (2.53.0) + view_component (2.62.0) activesupport (>= 5.0.0, < 8.0) method_source (~> 1.0) virtus (2.0.0) diff --git a/config/application.rb b/config/application.rb index dcf4852e8..fd58bf731 100644 --- a/config/application.rb +++ b/config/application.rb @@ -88,8 +88,5 @@ module TPS config.view_component.show_previews_source = true config.view_component.default_preview_layout = 'component_preview' config.view_component.preview_paths << "#{Rails.root}/spec/components/previews" - - # see: https://viewcomponent.org/known_issues.html - config.view_component.use_global_output_buffer = true end end From bc7cdb6b8e9ed31a86fcd8af9671bbc8fc6fb28c Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 28 Jul 2022 12:31:55 +0200 Subject: [PATCH 2/4] fix(contact): translate captcha honeypot label --- app/controllers/support_controller.rb | 2 +- app/views/support/index.html.haml | 4 ++-- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- spec/controllers/support_controller_spec.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index b46d7183c..ccb738188 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -96,6 +96,6 @@ class SupportController < ApplicationController end def redirect_to_root - redirect_to root_path, alert: t('invisible_captcha.custom_message') + redirect_to root_path, alert: t('invisible_captcha.sentence_for_humans') end end diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml index 5c7eda7d2..f96fe14f7 100644 --- a/app/views/support/index.html.haml +++ b/app/views/support/index.html.haml @@ -26,8 +26,6 @@ = t('.your_question') = hidden_field_tag :type, params[:type] - = invisible_captcha - %dl - @options.each do |(question, question_type, link)| %dt @@ -71,5 +69,7 @@ = hidden_field_tag :tags, @tags&.join(',') + = invisible_captcha + .send-wrapper = button_tag t('send_mail', scope: [:utils]), type: :submit, class: 'button send primary' diff --git a/config/locales/en.yml b/config/locales/en.yml index d542d5b40..fc2089ce0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -31,7 +31,7 @@ en: invisible_captcha: - custom_message: 'If you are a human, ignore this field' + sentence_for_humans: 'If you are a human, ignore this field' help: 'Help' help_dropdown: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4b5310d64..3a7ddaaf4 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -21,7 +21,7 @@ fr: invisible_captcha: - custom_message: 'Si vous êtes un humain, veuillez ignorer ce champs' + sentence_for_humans: 'Si vous êtes un humain, laissez ce champ vide' help: 'Aide' help_dropdown: problem_title: Un problème avec le site ? diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index 1b7737469..ee1fbf312 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -122,7 +122,7 @@ describe SupportController, type: :controller do let(:params) { { subject: 'bonjour', text: 'un message', InvisibleCaptcha.honeypots.sample => 'boom' } } it 'does not create a conversation on HelpScout' do expect { subject }.not_to change(Commentaire, :count) - expect(flash[:alert]).to eq(I18n.t('invisible_captcha.custom_message')) + expect(flash[:alert]).to eq(I18n.t('invisible_captcha.sentence_for_humans')) end end end From 76150c4bf51639475b816b244ae302927ef3ab84 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 2 Aug 2022 18:26:00 +0200 Subject: [PATCH 3/4] chore(bundle): update again view_component for a nester helper fix --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bfffe1000..232979df5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -727,7 +727,7 @@ GEM rails (>= 6.0.0) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext @@ -741,7 +741,7 @@ GEM activemodel (>= 3.0.0) public_suffix vcr (6.1.0) - view_component (2.62.0) + view_component (2.63.0) activesupport (>= 5.0.0, < 8.0) method_source (~> 1.0) virtus (2.0.0) From 4a1325eadf322b0f6619dc302e20eb85b6ff3a5b Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 2 Aug 2022 18:26:26 +0200 Subject: [PATCH 4/4] fix(view_component): replace form_with with unaffected buffer form_tag helper form_with/form_for have buffer issues (at least with turbo). form_tag seems not affected. --- .../conditions_component/conditions_component.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/types_de_champ_editor/conditions_component/conditions_component.html.haml b/app/components/types_de_champ_editor/conditions_component/conditions_component.html.haml index ed2bbe0ba..bd71535d4 100644 --- a/app/components/types_de_champ_editor/conditions_component/conditions_component.html.haml +++ b/app/components/types_de_champ_editor/conditions_component/conditions_component.html.haml @@ -1,5 +1,5 @@ .flex.justify-start.section{ id: dom_id(@tdc.stable_self, :conditions) } - = form_with url: admin_procedure_condition_path(@procedure_id, @tdc.stable_id), method: :patch, class: 'form width-100' do |f| + = form_tag admin_procedure_condition_path(@procedure_id, @tdc.stable_id), method: :patch, class: 'form width-100' do .conditionnel.mt-2.width-100 .flex %p.mr-2 Logique conditionnelle