mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-21 00:47:26 +00:00
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.
27 lines
1.0 KiB
Ruby
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
|