discourse/app/serializers/theme_field_serializer.rb
Kris bc9a661378
UX: show SCSS files in theme admin "extra files" section (#35300)
We currently only show JS files in a theme's "extra files" section, but
we can show SCSS here too

Before:
<img width="385" height="114" alt="image"
src="https://github.com/user-attachments/assets/081e323b-f341-4dba-bff4-99367150a392"
/>

After:
<img width="424" height="185" alt="image"
src="https://github.com/user-attachments/assets/0c5a68d8-8b72-455b-9d1f-468f483084da"
/>
2025-10-09 16:18:03 -04:00

54 lines
857 B
Ruby

# frozen_string_literal: true
class ThemeFieldSerializer < ApplicationSerializer
attributes :name,
:target,
:value,
:error,
:type_id,
:upload_id,
:url,
:filename,
:migrated,
:file_path
def include_url?
object.upload
end
def include_upload_id?
object.upload
end
def include_filename?
object.upload
end
def url
object.upload&.url
end
def filename
object.upload&.original_filename
end
def include_value?
@options[:include_value] || false
end
def target
Theme.lookup_target(object.target_id)&.to_s
end
def include_error?
object.error.present?
end
def migrated
!!object.theme_settings_migration
end
def include_migrated?
target == "migrations"
end
end