Files
openfoodnetwork/config/initializers/flipper.rb
Maikel Linke 9a1b1498bf Add all feature toggles with descriptions at boot
So you can easily inspect and activate new features without trying to
use them first. It brings more visibility and will enable us to easily
remove retired features as well.
2023-03-22 15:36:08 +11:00

27 lines
1.0 KiB
Ruby

require "flipper"
require "flipper/adapters/active_record"
require "open_food_network/feature_toggle"
if Rails.env.production?
Flipper::UI.configure do |config|
config.banner_text = '⚠️ Production environment: be aware that the changes have an impact on the application. Please, read the how-to before: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Feature-toggle-with-Flipper'
config.banner_class = 'danger'
end
end
Flipper.register(:admins) { |actor| actor.respond_to?(:admin?) && actor.admin? }
Flipper::UI.configure do |config|
config.descriptions_source = ->(_keys) do
# return has to be hash of {String key => String description}
OpenFoodNetwork::FeatureToggle::CURRENT_FEATURES
end
# Defaults to false. Set to true to show feature descriptions on the list
# page as well as the view page.
# config.show_feature_description_in_list = true
end
# Add known feature toggles. This may fail if the database isn't setup yet.
OpenFoodNetwork::FeatureToggle.setup! rescue ActiveRecord::StatementInvalid