From 7d7a741a1ae09b31632be6e52a9c2cb826a6c677 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 28 Aug 2023 14:31:12 +0200 Subject: [PATCH] amelioration(procedure.chorus): ajoute la tuile chorus quand cette fonction est active sur la procedure --- .../procedure/card/chorus_component.rb | 13 ++++++++++ .../chorus_component.html.haml | 20 ++++++++++++++++ .../administrateurs/procedures/show.html.haml | 1 + .../procedures/card/chorus_component_spec.rb | 24 +++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 app/components/procedure/card/chorus_component.rb create mode 100644 app/components/procedure/card/chorus_component/chorus_component.html.haml create mode 100644 spec/components/procedures/card/chorus_component_spec.rb diff --git a/app/components/procedure/card/chorus_component.rb b/app/components/procedure/card/chorus_component.rb new file mode 100644 index 000000000..e4830ce70 --- /dev/null +++ b/app/components/procedure/card/chorus_component.rb @@ -0,0 +1,13 @@ +class Procedure::Card::ChorusComponent < ApplicationComponent + def initialize(procedure:) + @procedure = procedure + end + + def render? + @procedure.chorusable? + end + + def error_messages + [] + end +end diff --git a/app/components/procedure/card/chorus_component/chorus_component.html.haml b/app/components/procedure/card/chorus_component/chorus_component.html.haml new file mode 100644 index 000000000..7f85ec850 --- /dev/null +++ b/app/components/procedure/card/chorus_component/chorus_component.html.haml @@ -0,0 +1,20 @@ +.fr-col-6.fr-col-md-4.fr-col-lg-3.chorus-component + = link_to edit_admin_procedure_chorus_path(@procedure), class: 'fr-tile fr-enlarge-link', title: error_messages do + .fr-tile__body.flex.column.align-center.justify-between + - if error_messages.present? + %div + %span.icon.refuse + %p.fr-tile-status-error À modifier + - elsif @count == 0 + %div + %span.icon.clock + %p.fr-tile-status-todo À compléter + - else + %div + %span.icon.accept + %p.fr-tile-status-accept Configuré + %div + %h3.fr-h6.fr-mt-10v + Connecteur Chorus + %p.fr-tile-subtitle Vous traitez des données de subvention d'état ? + %p.fr-btn.fr-btn--tertiary Configurer diff --git a/app/views/administrateurs/procedures/show.html.haml b/app/views/administrateurs/procedures/show.html.haml index bb4ad9d22..0df9bb013 100644 --- a/app/views/administrateurs/procedures/show.html.haml +++ b/app/views/administrateurs/procedures/show.html.haml @@ -66,3 +66,4 @@ = render Procedure::Card::SVASVRComponent.new(procedure: @procedure) if @procedure.sva_svr_enabled? || @procedure.feature_enabled?(:sva) = render Procedure::Card::MonAvisComponent.new(procedure: @procedure) = render Procedure::Card::DossierSubmittedMessageComponent.new(procedure: @procedure) + = render Procedure::Card::ChorusComponent.new(procedure: @procedure) diff --git a/spec/components/procedures/card/chorus_component_spec.rb b/spec/components/procedures/card/chorus_component_spec.rb new file mode 100644 index 000000000..b5148c376 --- /dev/null +++ b/spec/components/procedures/card/chorus_component_spec.rb @@ -0,0 +1,24 @@ +describe Procedure::Card::ChorusComponent, type: :component do + describe 'render' do + let(:procedure) { create(:procedure) } + + subject do + render_inline(described_class.new(procedure: procedure)) + end + + context 'feature flag not active' do + it 'does not render' do + subject + expect(page).not_to have_text('Connecteur Chorus') + end + end + context 'feature flag active' do + before { Flipper.enable_actor :chorus, procedure } + + it 'render the template' do + subject + expect(page).to have_text('Connecteur Chorus') + end + end + end +end