From 6876f080a28a6b07742b237682d445ff6f41b935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Thu, 18 Jan 2024 16:40:26 +0100 Subject: [PATCH] Extract features tab partial to a component --- .../settings/features_tab_component.html.erb | 7 +++++ .../admin/settings/features_tab_component.rb | 31 +++++++++++++++++++ .../admin/settings/_features_tab.html.erb | 13 -------- app/views/admin/settings/index.html.erb | 2 +- 4 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 app/components/admin/settings/features_tab_component.html.erb create mode 100644 app/components/admin/settings/features_tab_component.rb delete mode 100644 app/views/admin/settings/_features_tab.html.erb diff --git a/app/components/admin/settings/features_tab_component.html.erb b/app/components/admin/settings/features_tab_component.html.erb new file mode 100644 index 000000000..9cfb5f2b4 --- /dev/null +++ b/app/components/admin/settings/features_tab_component.html.erb @@ -0,0 +1,7 @@ +

<%= t("admin.settings.index.feature_flags") %>

+ +<%= render Admin::Settings::TableComponent.new(setting_name: "feature", table_class: "featured-settings-table") do %> + <% settings.each do |key| %> + <%= render Admin::Settings::RowComponent.new(key, type: :feature, tab: "#tab-feature-flags") %> + <% end %> +<% end %> diff --git a/app/components/admin/settings/features_tab_component.rb b/app/components/admin/settings/features_tab_component.rb new file mode 100644 index 000000000..64e0ffce2 --- /dev/null +++ b/app/components/admin/settings/features_tab_component.rb @@ -0,0 +1,31 @@ +class Admin::Settings::FeaturesTabComponent < ApplicationComponent + def settings + %w[ + feature.featured_proposals + feature.facebook_login + feature.google_login + feature.twitter_login + feature.wordpress_login + feature.public_stats + feature.signature_sheets + feature.user.recommendations + feature.user.recommendations_on_debates + feature.user.recommendations_on_proposals + feature.user.skip_verification + feature.community + feature.map + feature.allow_attached_documents + feature.allow_images + feature.help_page + feature.remote_translations + feature.translation_interface + feature.remote_census + feature.valuation_comment_notification + feature.graphql_api + feature.sdg + feature.machine_learning + feature.remove_investments_supports + feature.dashboard.notification_emails + ] + end +end diff --git a/app/views/admin/settings/_features_tab.html.erb b/app/views/admin/settings/_features_tab.html.erb deleted file mode 100644 index f85a08226..000000000 --- a/app/views/admin/settings/_features_tab.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -

<%= t("admin.settings.index.feature_flags") %>

- -<%= render Admin::Settings::TableComponent.new(setting_name: "feature", table_class: "featured-settings-table") do %> - <% %w[feature.featured_proposals feature.facebook_login feature.google_login feature.twitter_login - feature.wordpress_login feature.public_stats feature.signature_sheets feature.user.recommendations - feature.user.recommendations_on_debates feature.user.recommendations_on_proposals - feature.user.skip_verification feature.community feature.map feature.allow_attached_documents - feature.allow_images feature.help_page feature.remote_translations feature.translation_interface - feature.remote_census feature.valuation_comment_notification feature.graphql_api feature.sdg - feature.machine_learning feature.remove_investments_supports].each do |key| %> - <%= render Admin::Settings::RowComponent.new(key, type: :feature, tab: "#tab-feature-flags") %> - <% end %> -<% end %> diff --git a/app/views/admin/settings/index.html.erb b/app/views/admin/settings/index.html.erb index 0f22f76a0..8caea8827 100644 --- a/app/views/admin/settings/index.html.erb +++ b/app/views/admin/settings/index.html.erb @@ -11,7 +11,7 @@
- <%= render "features_tab" %> + <%= render Admin::Settings::FeaturesTabComponent.new %>