From 726019616f7f983007d6c2d4da4072c3c44fbe87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Thu, 18 Jan 2024 16:37:21 +0100 Subject: [PATCH] Extract configuration settings tab partial to a component --- .../configuration_tab_component.html.erb | 7 ++++ .../settings/configuration_tab_component.rb | 38 +++++++++++++++++++ .../_configuration_settings_tab.html.erb | 14 ------- app/views/admin/settings/index.html.erb | 2 +- 4 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 app/components/admin/settings/configuration_tab_component.html.erb create mode 100644 app/components/admin/settings/configuration_tab_component.rb delete mode 100644 app/views/admin/settings/_configuration_settings_tab.html.erb diff --git a/app/components/admin/settings/configuration_tab_component.html.erb b/app/components/admin/settings/configuration_tab_component.html.erb new file mode 100644 index 000000000..3ec85c6ad --- /dev/null +++ b/app/components/admin/settings/configuration_tab_component.html.erb @@ -0,0 +1,7 @@ +

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

+ +<%= render Admin::Settings::TableComponent.new(setting_name: "setting") do %> + <% settings.each do |key| %> + <%= render Admin::Settings::RowComponent.new(key, tab: "#tab-configuration") %> + <% end %> +<% end %> diff --git a/app/components/admin/settings/configuration_tab_component.rb b/app/components/admin/settings/configuration_tab_component.rb new file mode 100644 index 000000000..c62175090 --- /dev/null +++ b/app/components/admin/settings/configuration_tab_component.rb @@ -0,0 +1,38 @@ +class Admin::Settings::ConfigurationTabComponent < ApplicationComponent + def settings + %w[ + official_level_1_name + official_level_2_name + official_level_3_name + official_level_4_name + official_level_5_name + max_ratio_anon_votes_on_debates + max_votes_for_debate_edit + max_votes_for_proposal_edit + comments_body_max_length + proposal_code_prefix + votes_for_proposal_success + months_to_archive_proposals + email_domain_for_officials + facebook_handle + instagram_handle + telegram_handle + twitter_handle + twitter_hashtag + youtube_handle + org_name + meta_title + meta_description + meta_keywords + proposal_notification_minimum_interval_in_days + direct_message_max_per_day + mailer_from_name + mailer_from_address + min_age_to_participate + hot_score_period_in_days + related_content_score_threshold + featured_proposals_number + postal_codes + ] + end +end diff --git a/app/views/admin/settings/_configuration_settings_tab.html.erb b/app/views/admin/settings/_configuration_settings_tab.html.erb deleted file mode 100644 index 8c1db1bcb..000000000 --- a/app/views/admin/settings/_configuration_settings_tab.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -

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

- -<%= render Admin::Settings::TableComponent.new(setting_name: "setting") do %> - <% %w[official_level_1_name official_level_2_name official_level_3_name official_level_4_name - official_level_5_name max_ratio_anon_votes_on_debates max_votes_for_debate_edit - max_votes_for_proposal_edit comments_body_max_length proposal_code_prefix votes_for_proposal_success - months_to_archive_proposals email_domain_for_officials facebook_handle instagram_handle - telegram_handle twitter_handle twitter_hashtag youtube_handle org_name meta_title meta_description - meta_keywords proposal_notification_minimum_interval_in_days direct_message_max_per_day mailer_from_name - mailer_from_address min_age_to_participate hot_score_period_in_days related_content_score_threshold - featured_proposals_number feature.dashboard.notification_emails postal_codes].each do |key| %> - <%= render Admin::Settings::RowComponent.new(key, tab: "#tab-configuration") %> - <% end %> -<% end %> diff --git a/app/views/admin/settings/index.html.erb b/app/views/admin/settings/index.html.erb index f8397c9e5..0f22f76a0 100644 --- a/app/views/admin/settings/index.html.erb +++ b/app/views/admin/settings/index.html.erb @@ -3,7 +3,7 @@ <%= render "filter_subnav" %>
- <%= render "configuration_settings_tab" %> + <%= render Admin::Settings::ConfigurationTabComponent.new %>