Cleanup feature flags usage

This commit is contained in:
Paul Chavard 2021-03-03 18:20:34 +01:00
parent 46377fb7d9
commit 1c811083c0
9 changed files with 20 additions and 18 deletions

View file

@ -67,10 +67,6 @@ class ApplicationController < ActionController::Base
Flipper.enabled?(feature_name, current_user) Flipper.enabled?(feature_name, current_user)
end end
def feature_enabled_for?(feature_name, item)
Flipper.enabled?(feature_name, item)
end
def authenticate_logged_user! def authenticate_logged_user!
if instructeur_signed_in? if instructeur_signed_in?
authenticate_instructeur! authenticate_instructeur!

View file

@ -72,7 +72,7 @@ module Instructeurs
def create_avis def create_avis
@procedure = Procedure.find(params[:procedure_id]) @procedure = Procedure.find(params[:procedure_id])
if !feature_enabled_for?(:expert_not_allowed_to_invite, @procedure) if !@procedure.feature_enabled?(:expert_not_allowed_to_invite)
@new_avis = create_avis_from_params(avis.dossier, avis.confidentiel) @new_avis = create_avis_from_params(avis.dossier, avis.confidentiel)
if @new_avis.nil? if @new_avis.nil?

View file

@ -2,8 +2,4 @@ module FlipperHelper
def feature_enabled?(feature_name) def feature_enabled?(feature_name)
Flipper.enabled?(feature_name, current_user) Flipper.enabled?(feature_name, current_user)
end end
def feature_enabled_for?(feature_name, item)
Flipper.enabled?(feature_name, item)
end
end end

View file

@ -342,6 +342,10 @@ class Procedure < ApplicationRecord
end end
end end
def feature_enabled?(feature)
Flipper.enabled?(feature, self)
end
# Warning: dossier after_save build_default_champs must be removed # Warning: dossier after_save build_default_champs must be removed
# to save a dossier created from this method # to save a dossier created from this method
def new_dossier def new_dossier

View file

@ -41,7 +41,7 @@
= link_to 'Voir mes dossiers en cours', dossiers_path, class: ['button large expand primary'] = link_to 'Voir mes dossiers en cours', dossiers_path, class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand'] = link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']
- if feature_enabled_for?(:dossier_pdf_vide, @procedure) - if @procedure.feature_enabled?(:dossier_pdf_vide)
- pdf_link = commencer_dossier_vide_path(path: @procedure.path) - pdf_link = commencer_dossier_vide_path(path: @procedure.path)
- if @procedure.brouillon? - if @procedure.brouillon?
- pdf_link = commencer_dossier_vide_test_path(path: @procedure.path) - pdf_link = commencer_dossier_vide_test_path(path: @procedure.path)

View file

@ -31,7 +31,7 @@
.send-wrapper .send-wrapper
= f.submit 'Envoyer votre avis', class: 'button send' = f.submit 'Envoyer votre avis', class: 'button send'
- if !@dossier.termine? && !feature_enabled_for?(:expert_not_allowed_to_invite, @avis.procedure) - if !@dossier.termine? && !@avis.procedure.feature_enabled?(:expert_not_allowed_to_invite)
= render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } = render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis }
- if @dossier.avis_for(current_instructeur).present? - if @dossier.avis_for(current_instructeur).present?

View file

@ -5,10 +5,10 @@
-# only display the coronavirus to usagers (instructeurs know there are delays) when they are logged in, or on the public pages. -# only display the coronavirus to usagers (instructeurs know there are delays) when they are logged in, or on the public pages.
- if user_signed_in? - if user_signed_in?
- if dossier.present? && feature_enabled_for?(:coronavirus_banner, dossier.procedure) - if dossier.present? && dossier.procedure.feature_enabled?(:coronavirus_banner)
= render partial: 'layouts/coronavirus_banner' = render partial: 'layouts/coronavirus_banner'
- else - else
- if procedure.present? && feature_enabled_for?(:coronavirus_banner, procedure) - if procedure.present? && procedure.feature_enabled?(:coronavirus_banner)
= render partial: 'layouts/coronavirus_banner' = render partial: 'layouts/coronavirus_banner'
%header.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border", role: 'banner' } %header.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border", role: 'banner' }

View file

@ -10,7 +10,7 @@
%thead %thead
%tr %tr
%th Liste des experts %th Liste des experts
- if feature_enabled_for?(:make_experts_notifiable, @procedure) - if @procedure.feature_enabled?(:make_experts_notifiable)
%th Notifier des décisions sur les dossiers %th Notifier des décisions sur les dossiers
%tbody %tbody
- @experts_procedure.each do |expert_procedure| - @experts_procedure.each do |expert_procedure|
@ -18,7 +18,7 @@
%td %td
%span.icon.person %span.icon.person
= expert_procedure.expert.email = expert_procedure.expert.email
- if feature_enabled_for?(:make_experts_notifiable, @procedure) - if @procedure.feature_enabled?(:make_experts_notifiable)
%td %td
= form_for expert_procedure, = form_for expert_procedure,
url: admin_procedure_update_allow_decision_access_path(expert_procedure: expert_procedure), url: admin_procedure_update_allow_decision_access_path(expert_procedure: expert_procedure),

View file

@ -25,14 +25,20 @@ end
# A list of features to be deployed on first push # A list of features to be deployed on first push
features = [ features = [
:administrateur_routage,
:administrateur_web_hook, :administrateur_web_hook,
:carte_ign,
:coronavirus_banner,
:dossier_pdf_vide,
:expert_not_allowed_to_invite,
:hide_instructeur_email,
:insee_api_v3, :insee_api_v3,
:instructeur_bypass_email_login_token, :instructeur_bypass_email_login_token,
:localization,
:maintenance_mode, :maintenance_mode,
:make_experts_notifiable,
:mini_profiler, :mini_profiler,
:xray, :xray
:carte_ign,
:localization
] ]
def database_exists? def database_exists?