Skip to content

Commit

Permalink
fix: 应用上传的自定义字段格式错误的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed Aug 2, 2023
1 parent 9b86c19 commit ba1992b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/controllers/releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def index

def show
authorize @release

unless @release.custom_fields.is_a?(Array)
flash[:warn] = t('.custom_fields_invalid_json_format')
end
end

def new
Expand Down
4 changes: 3 additions & 1 deletion app/views/layouts/_messages.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
color, icon = case name
when 'notice', 'success'
['success', 'check']
when 'warn', 'warning'
['warning', 'bell']
else
['danger', 'exclamation-triangle']
end
Expand All @@ -13,4 +15,4 @@
| ×
h4
i.icon.fas class="fa-#{icon}"
= content_tag(:span, msg, :id => "flash_#{name}")
= content_tag(:span, msg, :id => "flash_#{name}")
9 changes: 5 additions & 4 deletions app/views/releases/body/_metadata.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
li title="#{t('releases.show.git_commit')}" data-toggle="tooltip"
i.fab.fa-git-alt
= git_commit_url(@release.channel.git_url, @release.git_commit)
- @release.custom_fields.each do |field|
li title="#{field['name']}" data-toggle="tooltip"
i class="#{field['icon'] || 'fas fa-hashtag'}"
= field['value']
- if @release.custom_fields.is_a?(Array)
- @release.custom_fields.each do |field|
li title="#{field['name']}" data-toggle="tooltip"
i class="#{field['icon'] || 'fas fa-hashtag'}"
= field['value']
li title="#{t('releases.show.source')}" data-toggle="tooltip"
i.fas.fa-compass
- if @release.ci_url.blank?
Expand Down
1 change: 1 addition & 0 deletions config/locales/zealot/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ en:
scan_qrcode_with_any_suppprted_app: Use your phone's camera to install it
major_versions: :channels.show.major_versions
view_detail: Manage channel
custom_fields_invalid_json_format: Can not render custom fields, use array type not string value of JSON.
new:
title: :channels.show.upload_release
install:
Expand Down
1 change: 1 addition & 0 deletions config/locales/zealot/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ zh-CN:
scan_qrcode_with_any_suppprted_app: 任何支持二维码识别的 App 均可
major_versions: :'channels.show.major_versions'
view_detail: 渠道详情
custom_fields_invalid_json_format: 自定义字段值无法正确显示,请使用 JSON 数组,不是字符串类型。
new:
title: :'channels.show.upload_release'
install:
Expand Down

0 comments on commit ba1992b

Please sign in to comment.