Convert admin/config text fields with static options to dropdowns (#16094)
* Add validations and constants for feed_style and strategy * Convert text fields w/ static options to dropdowns * Convert Bootstrap selectpicker to native HTML select tag * Update test to use valid feed strategy
This commit is contained in:
parent
8469161995
commit
c812e5250f
3 changed files with 19 additions and 13 deletions
|
|
@ -4,12 +4,18 @@ module Settings
|
|||
self.table_name = :settings_user_experiences
|
||||
|
||||
HEX_COLOR_REGEX = /\A#(\h{6}|\h{3})\z/
|
||||
FEED_STRATEGIES = %w[basic large_forem_experimental].freeze
|
||||
FEED_STYLES = %w[basic rich compact].freeze
|
||||
|
||||
# The default font for all users that have not chosen a custom font yet
|
||||
setting :default_font, type: :string, default: "sans_serif"
|
||||
setting :feed_strategy, type: :string, default: "basic"
|
||||
setting :feed_strategy, type: :string, default: "basic", validates: {
|
||||
inclusion: { in: FEED_STRATEGIES }
|
||||
}
|
||||
# basic (current default), rich (cover image on all posts), compact (more minimal)
|
||||
setting :feed_style, type: :string, default: "basic"
|
||||
setting :feed_style, type: :string, default: "basic", validates: {
|
||||
inclusion: { in: FEED_STYLES }
|
||||
}
|
||||
setting :home_feed_minimum_score, type: :integer, default: 0
|
||||
setting :index_minimum_score, type: :integer, default: 0
|
||||
setting :primary_brand_color_hex, type: :string, default: "#3b49df", validates: {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,18 @@
|
|||
<div class="crayons-fieldx">
|
||||
<%= admin_config_label :feed_style, model: Settings::UserExperience %>
|
||||
<%= admin_config_description Constants::Settings::UserExperience::DETAILS[:feed_style][:description] %>
|
||||
<%= f.text_field :feed_style,
|
||||
class: "crayons-textfield",
|
||||
value: Settings::UserExperience.feed_style,
|
||||
placeholder: Constants::Settings::UserExperience::DETAILS[:feed_style][:placeholder] %>
|
||||
<%= select_tag "settings_user_experience[feed_style]",
|
||||
options_for_select(Settings::UserExperience::FEED_STYLES, Settings::UserExperience.feed_style),
|
||||
multiple: false,
|
||||
class: "crayons-select" %>
|
||||
</div>
|
||||
<div class="crayons-field">
|
||||
<%= admin_config_label :feed_strategy, model: Settings::UserExperience %>
|
||||
<%= admin_config_description Constants::Settings::UserExperience::DETAILS[:feed_strategy][:description] %>
|
||||
<%= f.text_field :feed_strategy,
|
||||
class: "crayons-textfield",
|
||||
value: Settings::UserExperience.feed_strategy,
|
||||
placeholder: Constants::Settings::UserExperience::DETAILS[:feed_strategy][:placeholder] %>
|
||||
<%= select_tag "settings_user_experience[feed_strategy]",
|
||||
options_for_select(Settings::UserExperience::FEED_STRATEGIES, Settings::UserExperience.feed_strategy),
|
||||
multiple: false,
|
||||
class: "crayons-select" %>
|
||||
</div>
|
||||
<div class="crayons-field">
|
||||
<%= admin_config_label :tag_feed_minimum_score, model: Settings::UserExperience %>
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
Settings::UserExperience.default_font,
|
||||
),
|
||||
multiple: false,
|
||||
class: "selectpicker" %>
|
||||
class: "crayons-select" %>
|
||||
</div>
|
||||
<div class="crayons-field">
|
||||
<%= admin_config_label :default_locale, model: Settings::UserExperience %>
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
Settings::UserExperience.default_locale,
|
||||
),
|
||||
multiple: false,
|
||||
class: "selectpicker" %>
|
||||
class: "crayons-select" %>
|
||||
</div>
|
||||
<div class="crayons-field">
|
||||
<%= admin_config_label :primary_brand_color_hex, model: Settings::UserExperience %>
|
||||
|
|
|
|||
|
|
@ -734,7 +734,7 @@ RSpec.describe "/admin/customization/config", type: :request do
|
|||
end
|
||||
|
||||
it "updates the feed_strategy" do
|
||||
feed_strategy = "optimized"
|
||||
feed_strategy = "large_forem_experimental"
|
||||
post admin_settings_user_experiences_path, params: {
|
||||
settings_user_experience: { feed_strategy: feed_strategy }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue