From ba1992b4074609adc6e1d8a0ef5d9588c7dcf945 Mon Sep 17 00:00:00 2001 From: icyleaf Date: Wed, 2 Aug 2023 14:09:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BA=94=E7=94=A8=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=94=99=E8=AF=AF=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/releases_controller.rb | 4 ++++ app/views/layouts/_messages.html.slim | 4 +++- app/views/releases/body/_metadata.html.slim | 9 +++++---- config/locales/zealot/en.yml | 1 + config/locales/zealot/zh-CN.yml | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/releases_controller.rb b/app/controllers/releases_controller.rb index c9a536ea5..42ea56fd4 100644 --- a/app/controllers/releases_controller.rb +++ b/app/controllers/releases_controller.rb @@ -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 diff --git a/app/views/layouts/_messages.html.slim b/app/views/layouts/_messages.html.slim index 0979a6a6a..c8a25ef92 100644 --- a/app/views/layouts/_messages.html.slim +++ b/app/views/layouts/_messages.html.slim @@ -4,6 +4,8 @@ color, icon = case name when 'notice', 'success' ['success', 'check'] + when 'warn', 'warning' + ['warning', 'bell'] else ['danger', 'exclamation-triangle'] end @@ -13,4 +15,4 @@ | × h4 i.icon.fas class="fa-#{icon}" - = content_tag(:span, msg, :id => "flash_#{name}") \ No newline at end of file + = content_tag(:span, msg, :id => "flash_#{name}") diff --git a/app/views/releases/body/_metadata.html.slim b/app/views/releases/body/_metadata.html.slim index 77f2bbb15..67b261d2b 100644 --- a/app/views/releases/body/_metadata.html.slim +++ b/app/views/releases/body/_metadata.html.slim @@ -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? diff --git a/config/locales/zealot/en.yml b/config/locales/zealot/en.yml index 4fe7ef516..dfbb736f1 100644 --- a/config/locales/zealot/en.yml +++ b/config/locales/zealot/en.yml @@ -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: diff --git a/config/locales/zealot/zh-CN.yml b/config/locales/zealot/zh-CN.yml index e26716a8c..c1c036e9a 100644 --- a/config/locales/zealot/zh-CN.yml +++ b/config/locales/zealot/zh-CN.yml @@ -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: