docbrown/app/controllers/admin/extensions_controller.rb
Ridhwana 74a16beacb
Introduce "extensions" (#16840)
* feat: add the feature flag route and controller

* feat: add a ff page

* feat: update to a post with a success banner

* feat: test the feature

* feat: update the styling

* feat: change feature flag to extension witha  few more improvements like adding a model not backed by a table

* feat: update the text

* refactor: if you enable a FF, it gets added under the hood as well

* feat: accessibility name for label

* use keyword args

* use locales

* Update app/views/admin/extensions/index.html.erb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update app/views/admin/extensions/index.html.erb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update app/views/admin/extensions/index.html.erb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update config/locales/controllers/admin/fr.yml

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update app/controllers/admin/extensions_controller.rb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* fix: rubucop

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-03-18 11:22:17 +02:00

32 lines
916 B
Ruby

module Admin
class ExtensionsController < Admin::ApplicationController
layout "admin"
EXTENSIONS = [
Extension.new(
name: "Listings",
description: "Once turned on, Listings can be accessed via /listings and members " \
"will be able to add listings. " \
"<a href='https://admin.forem.com/docs/advanced-customization/listings'>" \
"Learn more about Listings</a>.",
feature_flag_name: :listing_feature,
),
].freeze
def index
@extensions = EXTENSIONS
end
def toggle
EXTENSIONS.each do |extension|
if params[extension.feature_flag_name].to_i == 1
extension.enable
else
extension.disable
end
end
flash[:success] = I18n.t("admin.extensions_controller.update_success")
redirect_to admin_extensions_path
end
end
end