From 7f1dd49bdcda0b7eba67f00efd721f0f5b3ae4f7 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 12 Oct 2022 11:48:50 +0200 Subject: [PATCH] chore(flipper): always use feature_enabled? helper --- app/components/types_de_champ_editor/champ_component.rb | 6 +++--- .../champ_component/champ_component.html.haml | 2 +- app/models/commentaire.rb | 2 +- app/models/procedure.rb | 2 +- .../administrateurs/procedures/_informations.html.haml | 2 +- app/views/administrateurs/procedures/show.html.haml | 2 +- app/views/administrateurs/procedures/zones.html.haml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/components/types_de_champ_editor/champ_component.rb b/app/components/types_de_champ_editor/champ_component.rb index e3ddab62b..a901d459d 100644 --- a/app/components/types_de_champ_editor/champ_component.rb +++ b/app/components/types_de_champ_editor/champ_component.rb @@ -56,7 +56,7 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent end def types_of_type_de_champ - if Flipper.enabled?(:categories_type_de_champ, controller.current_user) + if feature_enabled?(:categories_type_de_champ) cat_scope = "activerecord.attributes.type_de_champ.categorie" tdc_scope = "activerecord.attributes.type_de_champ.type_champs" @@ -105,7 +105,7 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent def filter_featured_type_champ(type_champ) feature_name = TypeDeChamp::FEATURE_FLAGS[type_champ] - feature_name.blank? || Flipper.enabled?(feature_name, helpers.current_user) + feature_name.blank? || feature_enabled?(feature_name) end def filter_type_champ(type_champ) @@ -133,7 +133,7 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent if type_de_champ.private? || coordinate.child? false else - procedure.feature_enabled?(:procedure_conditional) || Flipper.enabled?(:conditional, controller.current_user) + procedure.feature_enabled?(:procedure_conditional) end end end diff --git a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml index 828434a87..104a92eee 100644 --- a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml +++ b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml @@ -19,7 +19,7 @@ %span.sr-only Déplacer le champ vers le bas .cell.flex.justify-start.column.flex-grow = form.label :type_champ, "Type de champ", for: dom_id(type_de_champ, :type_champ) - - if Flipper.enabled?(:categories_type_de_champ, controller.current_user) + - if feature_enabled?(:categories_type_de_champ) = form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ) - else = form.select :type_champ, types_of_type_de_champ, {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ) diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index 05103e367..ac6eeb24e 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -53,7 +53,7 @@ class Commentaire < ApplicationRecord def redacted_email if sent_by_instructeur? - if Flipper.enabled?(:hide_instructeur_email, dossier.procedure) + if dossier.procedure.feature_enabled?(:hide_instructeur_email) "Instructeur n° #{instructeur.id}" else instructeur.email.split('@').first diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 98d47d10b..c8beda2e3 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -666,7 +666,7 @@ class Procedure < ApplicationRecord end def missing_zones? - if Flipper.enabled?(:zonage) + if feature_enabled?(:zonage) zones.empty? else false diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index dea314f0c..072f3befc 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -62,7 +62,7 @@ = f.label :lien_dpo, 'Lien ou email pour contacter le Délégué à la Protection des Données (DPO)' = f.text_field :lien_dpo, class: 'form-control' -- if Flipper.enabled? :opendata, @procedure +- if @procedure.feature_enabled?(:opendata) %h3.header-subsection= t(:opendata_header, scope: [:administrateurs, :informations]) %p.notice= t(:opendata_notice_html, scope: [:administrateurs, :informations]) %p.notice= t(:opendata, scope: [:administrateurs, :informations]) diff --git a/app/views/administrateurs/procedures/show.html.haml b/app/views/administrateurs/procedures/show.html.haml index 5df800982..4e443df92 100644 --- a/app/views/administrateurs/procedures/show.html.haml +++ b/app/views/administrateurs/procedures/show.html.haml @@ -58,7 +58,7 @@ %h2.procedure-admin-explanation Indispensable avant publication .procedure-grid = render Procedure::Card::PresentationComponent.new(procedure: @procedure) - = render Procedure::Card::ZonesComponent.new(procedure: @procedure) if Flipper.enabled? :zonage + = render Procedure::Card::ZonesComponent.new(procedure: @procedure) if @procedure.feature_enabled?(:zonage) = render Procedure::Card::ChampsComponent.new(procedure: @procedure) = render Procedure::Card::ServiceComponent.new(procedure: @procedure, administrateur: current_administrateur) = render Procedure::Card::AdministrateursComponent.new(procedure: @procedure) diff --git a/app/views/administrateurs/procedures/zones.html.haml b/app/views/administrateurs/procedures/zones.html.haml index 393753149..dbafefc63 100644 --- a/app/views/administrateurs/procedures/zones.html.haml +++ b/app/views/administrateurs/procedures/zones.html.haml @@ -14,7 +14,7 @@ = f.label :zone do = t('zone', scope: 'activerecord.attributes.procedure') - - if Flipper.enabled? :zonage + - if @procedure.feature_enabled?(:zonage) = f.collection_check_boxes :zone_ids, Zone.available_at(@procedure.published_or_created_at), :id, :label do |b| .editable-champ.editable-champ-checkbox = b.check_box