Skip to content

Commit

Permalink
refactor: Remove use_original_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Nov 27, 2024
1 parent c1832b4 commit 753a2c7
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 61 deletions.
27 changes: 13 additions & 14 deletions app/controllers/api/apps/upload_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ class Api::Apps::UploadController < Api::BaseController
#
# POST /api/apps/upload
#
# @param token [String] required user token
# @param file [String] required file of app
# @param channel_key [String] optional channel key of app
# @param name [String] optional name of app
# @param password [String] optional password to download app
# @param release_type [String] optional release type(debug, beta, adhoc, release, enterprise etc)
# @param source [String] optional upload source(api, cli, jenkins, gitlab-ci etc)
# @param changelog [String] optional changelog
# @param branch [String] optional git branch
# @param git_commit [String] optional git commit
# @param ci_url [String] optional ci url
# @param use_original_filename [Boolean] optional whether to use the original file name (true/false)
# @return [String] json formatted app info
# @param token [String] required user token
# @param file [String] required file of app
# @param channel_key [String] optional channel key of app
# @param name [String] optional name of app
# @param password [String] optional password to download app
# @param release_type [String] optional release type(debug, beta, adhoc, release, enterprise etc)
# @param source [String] optional upload source(api, cli, jenkins, gitlab-ci etc)
# @param changelog [String] optional changelog
# @param branch [String] optional git branch
# @param git_commit [String] optional git commit
# @param ci_url [String] optional ci url
# @return [String] json formatted app info
def create
create_or_update_release
perform_teardown_job
Expand Down Expand Up @@ -124,7 +123,7 @@ def parse_scheme_name
def release_params
params.permit(
:file, :release_type, :source, :branch, :git_commit,
:ci_url, :changelog, :devices, :custom_fields, :use_original_filename
:ci_url, :changelog, :devices, :custom_fields
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def set_release
def release_params
params.permit(
:release_version, :build_version, :release_type, :source, :branch, :git_commit,
:ci_url, :custom_fields, :changelog, :use_original_filename
:ci_url, :custom_fields, :changelog
)
end
end
3 changes: 1 addition & 2 deletions app/controllers/releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def set_channel

def release_params
params.require(:release).permit(
:file, :changelog, :release_version, :build_version, :release_type, :branch, :git_commit,
:ci_url, :use_original_filename
:file, :changelog, :release_version, :build_version, :release_type, :branch, :git_commit, :ci_url
)
end

Expand Down
3 changes: 1 addition & 2 deletions app/jobs/app_web_hook_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ def build_example_release
bundle_id: 'im.ews.zealot.example.app',
release_version: '1.0.0',
build_version: '5',
git_commit: '31dbb8497b81e103ecadcab0ca724c3fd87b3ab9',
use_original_filename: false
git_commit: '31dbb8497b81e103ecadcab0ca724c3fd87b3ab9'
)
end
end
1 change: 0 additions & 1 deletion app/models/concerns/release_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def build_metadata(parser, default_source)
self.release_version = parser.release_version
self.build_version = parser.build_version
self.release_type ||= parser.release_type if parser.respond_to?(:release_type)
self.original_filename = File.basename(file.path) if parser.use_original_filename

icon_file = fetch_icon(parser)
self.icon = icon_file if icon_file
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/api/upload_app_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Api::UploadAppSerializer < ApplicationSerializer
attributes :id, :version, :app_name, :bundle_id, :release_version, :build_version,
:source, :branch, :git_commit, :ci_url, :size, :platform, :device_type,
:icon_url, :release_url, :install_url, :qrcode_url, :changelog, :text_changelog,
:custom_fields, :created_at, :use_original_filename
:custom_fields, :created_at

belongs_to :app
belongs_to :scheme
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/release_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ReleaseSerializer < ApplicationSerializer
attributes :id, :version, :app_name, :bundle_id, :release_version, :build_version,
:source, :branch, :git_commit, :ci_url, :size, :platform, :device_type,
:icon_url, :install_url, :changelog, :text_changelog, :custom_fields,
:created_at, :use_original_filename
:created_at


def changelog
Expand Down
3 changes: 1 addition & 2 deletions app/services/create_sample_data_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,7 @@ def generate_release(channel, app_bundle_id, release_type, changelog, build_vers
branch: 'develop',
device_type: device_type || channel.device_type,
git_commit: SecureRandom.hex,
changelog: changelog,
use_original_filename: false
changelog: changelog
).save(validate: false)
end

Expand Down
1 change: 0 additions & 1 deletion app/views/releases/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
= f.input :branch
= f.input :git_commit
= f.input :ci_url
= f.input :use_original_filename, as: :radio_buttons, collection: [[true, '启用'], [false, '禁用']], checked: @use_original_filename
= f.input :changelog, input_html: { rows: 10, cols: 10 }

= f.button :submit
2 changes: 0 additions & 2 deletions config/locales/simple_form/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ en:
branch: Git branch
git_commit: Git commit SHA
ci_url: CI URL
use_original_filename: Use original file name
web_hook:
url: URL
body: Body
Expand Down Expand Up @@ -118,7 +117,6 @@ en:
branch: Git branch. In general either main or develop.
git_commit: 40 bit length SHA value of git commit
ci_url: The CI URL specific like Jenkins, Gitlab CI etc
use_original_filename: When this option is enabled, the name of the downloaded file will remain the same as the name of the uploaded file.
web_hook:
body: Custom JSON struct body to apply the third party notification services. Use <a href="https://zealot.ews.im/docs/user-guide/webhooks">default structure</a> by leave it empty.
debug_file:
Expand Down
2 changes: 0 additions & 2 deletions config/locales/simple_form/simple_form.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ zh-CN:
branch: Git 分支名称
git_commit: Git 最后提交 SHA
ci_url: CI URL
use_original_filename: 使用原文件名
web_hook:
url: URL
body: 自定义消息体
Expand Down Expand Up @@ -119,7 +118,6 @@ zh-CN:
branch: 通常情况是 main 或 develop
git_commit: 通常是 40 位长度的哈希值
ci_url: Jenkins、Gitlab CI 具体构建的地址
use_original_filename: 启用此选项后,下载文件的名称将与上传文件的名称保持一致
web_hook:
body: 自定义的 JSON 消息体以满足不同第三方服务消息体的要求,不填写会使用<a href="https://zealot.ews.im/zh-Hans/docs/user-guide/webhooks">默认结构</a>
debug_file:
Expand Down
1 change: 0 additions & 1 deletion config/locales/zealot/api.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ en:
branch: a branch name from source control tool
git_commit: Git Commit SHA value
ci_url: the build url of a CI service
use_original_filename: When this option is enabled, the name of the downloaded file will be the same as the name of the uploaded file. The default value is `false`
custom_fields: JSON formatted custom fields, icon only accepts fontawesome.
app_options:
description: App form data
Expand Down
2 changes: 0 additions & 2 deletions config/locales/zealot/api.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ zh-CN:
branch: 代码控制软件的分支名
git_commit: 代码控制软件提交哈希值
ci_url: 持续构建系统构建 URL
use_original_filename: 启用此选项后,下载文件的名称将与上传文件的名称保持一致,默认是 `false`
custom_fields: 这是一个用 JSON 字符串定义的自定义字段,图标可接受 fontawesome
app_options:
description: 应用表单字段结构
Expand Down Expand Up @@ -132,7 +131,6 @@ zh-CN:
branch: 代码控制软件的分支名
git_commit: 代码控制软件提交哈希值
ci_url: 持续构建系统构建 URL
use_original_filename: 启用此选项后,下载文件的名称将与上传文件的名称保持一致,默认是 `false`
custom_fields: 这是一个用 JSON 字符串定义的自定义字段,图标可接受 fontawesome
collaborator_options:
description: 应用成员表单字段结构
Expand Down
1 change: 0 additions & 1 deletion db/migrate/20150210090223_create_releases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def change
t.jsonb :changelog, null: false
t.string :file, null: true
t.jsonb :devices, null: false, default: []
t.boolean :use_original_filename, default: false

t.timestamps
end
Expand Down
1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
t.jsonb "custom_fields", default: [], null: false
t.string "name"
t.string "device_type"
t.boolean "use_original_filename", default: false
t.index ["build_version"], name: "index_releases_on_build_version"
t.index ["bundle_id"], name: "index_releases_on_bundle_id"
t.index ["channel_id", "version"], name: "index_releases_on_channel_id_and_version", unique: true
Expand Down
3 changes: 0 additions & 3 deletions spec/swagger_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
text_changelog: { type: :string, example: '- bump 1.1\n-n fixes bugs' },
custom_fields: { type: :array, items: { '$ref': '#/components/schemas/ReleaseCustomField' }},
created_at: { type: :date, example: '2024-03-01 12:00:00 +0800' },
use_original_filename: { type: :boolean, example: true },
}
},
ReleaseChangelog: {
Expand Down Expand Up @@ -306,7 +305,6 @@
branch: { type: :string, description: I18n.t('api.definitions.upload_options.properties.branch') },
git_commit: { type: :string, description: I18n.t('api.definitions.upload_options.properties.git_commit') },
ci_url: { type: :string, description: I18n.t('api.definitions.upload_options.properties.ci_url') },
use_original_filename: { type: :boolean, description: I18n.t('api.definitions.upload_options.properties.use_original_filename') },
custom_fields: { type: :array, items: { '$ref': '#/components/schemas/ReleaseCustomField' }, description: I18n.t('api.definitions.upload_options.properties.custom_fields')},
}
},
Expand Down Expand Up @@ -353,7 +351,6 @@
branch: { type: :string, description: I18n.t('api.definitions.release_options.properties.branch') },
git_commit: { type: :string, description: I18n.t('api.definitions.release_options.properties.git_commit') },
ci_url: { type: :string, description: I18n.t('api.definitions.release_options.properties.ci_url') },
use_original_filename: { type: :boolean, description: I18n.t('api.definitions.release_options.properties.use_original_filename') },
custom_fields: { type: :array, items: { '$ref': '#/components/schemas/ReleaseCustomField' }, description: I18n.t('api.definitions.release_options.properties.custom_fields')},
}
},
Expand Down
12 changes: 0 additions & 12 deletions swagger/v1/swagger_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2393,10 +2393,6 @@
"created_at": {
"type": "date",
"example": "2024-03-01 12:00:00 +0800"
},
"use_original_filename": {
"type": "boolean",
"example": true
}
}
},
Expand Down Expand Up @@ -2875,10 +2871,6 @@
"type": "string",
"description": "the build url of a CI service"
},
"use_original_filename": {
"type": "boolean",
"example": true
},
"custom_fields": {
"type": "array",
"items": {
Expand Down Expand Up @@ -3006,10 +2998,6 @@
"type": "string",
"description": "the build url of a CI service"
},
"use_original_filename": {
"type": "boolean",
"example": true
},
"custom_fields": {
"type": "array",
"items": {
Expand Down
12 changes: 0 additions & 12 deletions swagger/v1/swagger_zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2393,10 +2393,6 @@
"created_at": {
"type": "date",
"example": "2024-03-01 12:00:00 +0800"
},
"use_original_filename": {
"type": "boolean",
"example": true
}
}
},
Expand Down Expand Up @@ -2875,10 +2871,6 @@
"type": "string",
"description": "持续构建系统构建 URL"
},
"use_original_filename": {
"type": "boolean",
"example": true
},
"custom_fields": {
"type": "array",
"items": {
Expand Down Expand Up @@ -3006,10 +2998,6 @@
"type": "string",
"description": "持续构建系统构建 URL"
},
"use_original_filename": {
"type": "boolean",
"example": true
},
"custom_fields": {
"type": "array",
"items": {
Expand Down

0 comments on commit 753a2c7

Please sign in to comment.