Remove support for `theme_var` and `theme_color_var` fields

These are remnants of the old 'customization' system, and have been superseded by theme settings
This commit is contained in:
David Taylor 2019-01-18 12:03:55 +00:00
parent b520d0efad
commit f40c97c367
3 changed files with 4 additions and 53 deletions

View File

@ -112,25 +112,6 @@ class RemoteTheme < ActiveRecord::Base
end
end
theme_info["fields"]&.each do |name, info|
unless Hash === info
info = {
"target" => :common,
"type" => :theme_var,
"value" => info
}
end
if info["type"] == "color"
info["type"] = :theme_color_var
end
theme.set_field(target: info["target"] || :common,
name: name,
value: info["value"],
type: info["type"] || :theme_var)
end
Theme.targets.keys.each do |target|
next if target == :settings || target == :translations
ALLOWED_FIELDS.each do |field|

View File

@ -41,13 +41,13 @@ class ThemeField < ActiveRecord::Base
@types ||= Enum.new(html: 0,
scss: 1,
theme_upload_var: 2,
theme_color_var: 3,
theme_var: 4,
theme_color_var: 3, # No longer used
theme_var: 4, # No longer used
yaml: 5)
end
def self.theme_var_type_ids
@theme_var_type_ids ||= [2, 3, 4]
@theme_var_type_ids ||= [2]
end
def self.force_recompilation!

View File

@ -239,37 +239,7 @@ HTML
end
end
context 'theme vars' do
it 'works in parent theme' do
theme.set_field(target: :common, name: :scss, value: 'body {color: $magic; }')
theme.set_field(target: :common, name: :magic, value: 'red', type: :theme_var)
theme.set_field(target: :common, name: :not_red, value: 'red', type: :theme_var)
theme.component = true
theme.save
parent_theme = Fabricate(:theme)
parent_theme.set_field(target: :common, name: :scss, value: 'body {background-color: $not_red; }')
parent_theme.set_field(target: :common, name: :not_red, value: 'blue', type: :theme_var)
parent_theme.save
parent_theme.add_child_theme!(theme)
scss, _map = Stylesheet::Compiler.compile('@import "theme_variables"; @import "desktop_theme"; ', "theme.scss", theme_id: parent_theme.id)
expect(scss).to include("color:red")
expect(scss).to include("background-color:blue")
end
it 'can generate scss based off theme vars' do
theme.set_field(target: :common, name: :scss, value: 'body {color: $magic; content: quote($content)}')
theme.set_field(target: :common, name: :magic, value: 'red', type: :theme_var)
theme.set_field(target: :common, name: :content, value: 'Sam\'s Test', type: :theme_var)
theme.save
scss, _map = Stylesheet::Compiler.compile('@import "theme_variables"; @import "desktop_theme"; ', "theme.scss", theme_id: theme.id)
expect(scss).to include("red")
expect(scss).to include('"Sam\'s Test"')
end
context 'theme upload vars' do
let :image do
file_from_fixtures("logo.png")
end