Skip to content

Commit

Permalink
FEATURE: add support for upload format in theme settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothkannans committed Apr 15, 2020
1 parent 8c58319 commit 884eea7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/theme_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def clear_settings_cache
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)
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
3 changes: 3 additions & 0 deletions lib/theme_settings_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@ def choices
@opts[:choices]
end
end

class Upload < self
end
end
4 changes: 4 additions & 0 deletions spec/fixtures/theme_settings/valid_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ enum_setting_03:
- 10
- 100
- 1000

upload_setting:
type: upload
default: ""

1 comment on commit 884eea7

@discoursereviewbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robin Ward posted:

@davidtaylorhq has some feedback on this one.

Please sign in to comment.