Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: add support for `upload` format in theme settings.

Vinoth Kannan884eea7a8346
diff --git a/app/models/theme_setting.rb b/app/models/theme_setting.rb
index b34fd5fbefa..86d8c0247c5 100644
--- a/app/models/theme_setting.rb
+++ b/app/models/theme_setting.rb
@@ -16,7 +16,7 @@ class ThemeSetting < ActiveRecord::Base
end
def self.types
- @types ||= Enum.new(integer: 0, float: 1, string: 2, bool: 3, list: 4, enum: 5)
+ @types ||= Enum.new(integer: 0, float: 1, string: 2, bool: 3, list: 4, enum: 5, upload: 6)
end
def self.acceptable_value_for_type?(value, type)
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index ffd392888e6..64ed44da9b7 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -96,7 +96,7 @@ en:
optimized_link: Optimized image links are ephemeral and should not be included in theme source code.
settings_errors:
invalid_yaml: "Provided YAML is invalid."
- data_type_not_a_number: "Setting `%{name}` type is unsupported. Supported types are `integer`, `bool`, `list` and `enum`"
+ data_type_not_a_number: "Setting `%{name}` type is unsupported. Supported types are `integer`, `bool`, `list`, `enum` and `upload`"
name_too_long: "There is a setting with a too long name. Maximum length is 255"
default_value_missing: "Setting `%{name}` has no default value"
default_not_match_type: "Setting `%{name}` default value's type doesn't match with the setting type."
diff --git a/lib/theme_settings_manager.rb b/lib/theme_settings_manager.rb
index cc69dee04e6..49ad6a6d612 100644
--- a/lib/theme_settings_manager.rb
+++ b/lib/theme_settings_manager.rb
@@ -167,4 +167,7 @@ class ThemeSettingsManager
@opts[:choices]
end
end
+
+ class Upload < self
+ end
end
diff --git a/spec/fixtures/theme_settings/valid_settings.yaml b/spec/fixtures/theme_settings/valid_settings.yaml
index 2885fba1b87..35a6973e663 100644
--- a/spec/fixtures/theme_settings/valid_settings.yaml
+++ b/spec/fixtures/theme_settings/valid_settings.yaml
@@ -68,3 +68,7 @@ enum_setting_03:
- 10
- 100
- 1000
+
+upload_setting:
+ type: upload
+ default: ""