From 11d9726a44690ed8693b32aa22692d6b151ac314 Mon Sep 17 00:00:00 2001 From: icyleaf Date: Tue, 28 May 2024 05:33:20 +0000 Subject: [PATCH 1/4] bump 5.3.0 --- Dockerfile | 2 +- config/locales/zealot/api.en.yml | 2 +- config/locales/zealot/api.zh-CN.yml | 2 +- package.json | 2 +- swagger/v1/swagger_en.json | 4 ++-- swagger/v1/swagger_zh-CN.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25e1a889f..b515f56f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,7 +64,7 @@ ARG BUILD_DATE ARG VCS_REF ARG TAG -ARG ZEALOT_VERSION="5.2.3" +ARG ZEALOT_VERSION="5.3.0" ARG REPLACE_CHINA_MIRROR="true" ARG ORIGINAL_REPO_URL="dl-cdn.alpinelinux.org" ARG MIRROR_REPO_URL="mirrors.ustc.edu.cn" diff --git a/config/locales/zealot/api.en.yml b/config/locales/zealot/api.en.yml index f76e91fb0..e7e8d70d7 100644 --- a/config/locales/zealot/api.en.yml +++ b/config/locales/zealot/api.en.yml @@ -13,7 +13,7 @@ en: ```json { - "version": "5.2.3", + "version": "5.3.0", "vcs_ref": "effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d", "build_date": "2024-05-23T06:04:48.989Z" } diff --git a/config/locales/zealot/api.zh-CN.yml b/config/locales/zealot/api.zh-CN.yml index c5003ad71..13dda43d6 100644 --- a/config/locales/zealot/api.zh-CN.yml +++ b/config/locales/zealot/api.zh-CN.yml @@ -13,7 +13,7 @@ zh-CN: ```json { - "version": "5.2.3", + "version": "5.3.0", "vcs_ref": "effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d", "build_date": "2024-05-23T06:04:48.989Z" } diff --git a/package.json b/package.json index 424bdcdbf..0922697b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zealot", - "version": "5.2.3", + "version": "5.3.0", "private": true, "license": "MIT", "dependencies": { diff --git a/swagger/v1/swagger_en.json b/swagger/v1/swagger_en.json index 29c9aa47f..cc4fa72e3 100644 --- a/swagger/v1/swagger_en.json +++ b/swagger/v1/swagger_en.json @@ -3,7 +3,7 @@ "info": { "title": "Zealot API", "version": "v1.3", - "description": "This documentation doesn't provide a way to test our API. In order to facilitate testing, we recommend the following tools:\n\n- [cURL](https://curl.se/) (recommended, command-line)\n- [Bruno](https://www.usebruno.com/)\n- [Postman](https://www.postman.com/downloads/)\n- Your web browser, if you don't need to send headers or a request body\n\nOnce you have a working client, you can test that it works by making a GET request to {host}/version:\n\n```json\n{\n \"version\": \"5.2.3\",\n \"vcs_ref\": \"effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d\",\n \"build_date\": \"2024-05-23T06:04:48.989Z\"\n}\n```\n\n## Authentication\n\nThis API only accepts one options for authentication: Personal access tokens.\nAll tokens are tied to a Zealot user and use the `token` query of the request.\n\nExample:\n\n```\nhttps://tryzealot.ews.im/api/users?token={token}\n```\n\n### Personal access tokens\n\nPersonal access tokens (PATs) can be found in from the [user settings](/docs/user-guide/user_settings).\n" + "description": "This documentation doesn't provide a way to test our API. In order to facilitate testing, we recommend the following tools:\n\n- [cURL](https://curl.se/) (recommended, command-line)\n- [Bruno](https://www.usebruno.com/)\n- [Postman](https://www.postman.com/downloads/)\n- Your web browser, if you don't need to send headers or a request body\n\nOnce you have a working client, you can test that it works by making a GET request to {host}/version:\n\n```json\n{\n \"version\": \"5.3.0\",\n \"vcs_ref\": \"effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d\",\n \"build_date\": \"2024-05-23T06:04:48.989Z\"\n}\n```\n\n## Authentication\n\nThis API only accepts one options for authentication: Personal access tokens.\nAll tokens are tied to a Zealot user and use the `token` query of the request.\n\nExample:\n\n```\nhttps://tryzealot.ews.im/api/users?token={token}\n```\n\n### Personal access tokens\n\nPersonal access tokens (PATs) can be found in from the [user settings](/docs/user-guide/user_settings).\n" }, "servers": [ { @@ -3015,4 +3015,4 @@ } } } -} \ No newline at end of file +} diff --git a/swagger/v1/swagger_zh-CN.json b/swagger/v1/swagger_zh-CN.json index 44172acd4..c059a178d 100644 --- a/swagger/v1/swagger_zh-CN.json +++ b/swagger/v1/swagger_zh-CN.json @@ -3,7 +3,7 @@ "info": { "title": "Zealot API", "version": "v1.3", - "description": "文档可能提供或没有提供测试接口的工具,便于快速测试,你还可以使用如下工具:\n\n- [cURL](https://curl.se/) (推荐,命令行工具)\n- [Bruno](https://www.usebruno.com/)\n- [Postman](https://www.postman.com/downloads/)\n- 任意浏览器,如果你不需要设置 headers 或请求主体\n\n准备好工具,你可以通过 `GET` 请求 {host}/version 可看到 Zealot 版本信息:\n\n```json\n{\n \"version\": \"5.2.3\",\n \"vcs_ref\": \"effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d\",\n \"build_date\": \"2024-05-23T06:04:48.989Z\"\n}\n```\n\n## 接口认证\n\n接口目前仅提供在用户密钥认证方式,参数是 `token`,请求接口时可在接口 query 或表单字段中传递此字段。\n\n```\nhttps://tryzealot.ews.im/api/users?token={token}\n```\n\n### 用户密钥\n\n用户密钥在[用户详情](/docs/user-guide/user_settings)最底部找到。\n" + "description": "文档可能提供或没有提供测试接口的工具,便于快速测试,你还可以使用如下工具:\n\n- [cURL](https://curl.se/) (推荐,命令行工具)\n- [Bruno](https://www.usebruno.com/)\n- [Postman](https://www.postman.com/downloads/)\n- 任意浏览器,如果你不需要设置 headers 或请求主体\n\n准备好工具,你可以通过 `GET` 请求 {host}/version 可看到 Zealot 版本信息:\n\n```json\n{\n \"version\": \"5.3.0\",\n \"vcs_ref\": \"effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d\",\n \"build_date\": \"2024-05-23T06:04:48.989Z\"\n}\n```\n\n## 接口认证\n\n接口目前仅提供在用户密钥认证方式,参数是 `token`,请求接口时可在接口 query 或表单字段中传递此字段。\n\n```\nhttps://tryzealot.ews.im/api/users?token={token}\n```\n\n### 用户密钥\n\n用户密钥在[用户详情](/docs/user-guide/user_settings)最底部找到。\n" }, "servers": [ { From ce3827f57ce62e28d51d2515535aa1d81ff29f09 Mon Sep 17 00:00:00 2001 From: icyleaf Date: Tue, 28 May 2024 06:29:10 +0000 Subject: [PATCH 2/4] chore: cleanup --- .codeclimate.yml | 11 ++++++++--- .rubocop.yml | 1 + spec/factories/user.rb | 2 ++ spec/spec_helper.rb | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 2eda42abe..000b39c46 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,9 +1,14 @@ -version: "2" +version: '2' plugins: + bundler-audit: + enabled: true + rubocop: + enabled: true eslint: enabled: true csslint: enabled: true - rubocop: + markdownlint: + enabled: true + fixme: enabled: true - channel: "rubocop-1-31-0" \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 8fe3d736d..08424f221 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -38,6 +38,7 @@ Layout/LineLength: Max: 120 Exclude: - 'config/**/*.rb' + - 'spec/**/*.rb' - 'lib/zealot/backup/manager.rb' Metrics/MethodLength: diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 81559e443..feacbf52c 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :user do token { Digest::MD5.hexdigest(SecureRandom.uuid) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 327b58ea1..d7a7fadce 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause From d08bcc9d4d5a3df65400c0a0c0a5b6f1a9dc1642 Mon Sep 17 00:00:00 2001 From: icyleaf Date: Tue, 28 May 2024 07:09:55 +0000 Subject: [PATCH 3/4] chore: update devcontainer readme --- .devcontainer/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index eba46c57a..70fd99169 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -9,11 +9,12 @@ 文件名 | 说明 ---|--- -`devcontainer.json` | VSCode devcontainer 配置文件 -`Dockerfile.base` | 镜像核心,变更会自动推送到不同 registry 仓库 -`Dockerfile` | 间接镜像,主要是节省编译时间 +`devcontainer.json` | vscode devcontainer 配置文件 +`Dockerfile.base` | 基础镜像 +`Dockerfile` | 运行时镜像,主要是节省编译时间 `docker-compose.yml` | 项目服务依赖 `create-db-user.sql` | 用于初始化 Postgres 默认用户及权限 +`extensions` | vscode 扩展相关服务 ## 镜像 From 961ae83ed6c21d678f0752c7a173bd387222ee07 Mon Sep 17 00:00:00 2001 From: icyleaf Date: Tue, 28 May 2024 07:52:59 +0000 Subject: [PATCH 4/4] refactor: extract delete all button out of bulk operation form --- app/controllers/channels_controller.rb | 16 ++++++++-------- app/views/channels/filters/_list.html.slim | 3 --- app/views/channels/filters/index.html.slim | 6 ++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index 3ad657d34..2dbde88a1 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -48,14 +48,14 @@ def destroy def destroy_releases channel = Channel.friendly.find(params[:name] || params[:id]) - # authorize channel - - # if params[:channel].blank? - # channel.releases.destroy_all - # else - # delete_params = params.require(:channel).permit(release_ids: []) - # channel.releases.where(id: delete_params[:release_ids]).destroy_all - # end + authorize channel + + if params[:channel].blank? + channel.releases.destroy_all + else + delete_params = params.require(:channel).permit(release_ids: []) + channel.releases.where(id: delete_params[:release_ids]).destroy_all + end redirect_to friendly_channel_versions_path(channel), status: :see_other end diff --git a/app/views/channels/filters/_list.html.slim b/app/views/channels/filters/_list.html.slim index 5f26d9fc4..3310d356b 100644 --- a/app/views/channels/filters/_list.html.slim +++ b/app/views/channels/filters/_list.html.slim @@ -46,9 +46,6 @@ - if current_user&.manage?(app: channel.app) .actions - .float-right - = button_to t('.delete_all'), bulk_delete_url(channel), class: 'btn btn-danger', \ - method: :delete, data: { turbo_confirm: t('channels.messages.confirm.destroy') } .buttons = f.submit t('.delete'), class: 'btn btn-danger', \ data: { bulk_operation_target: 'destroyButton', turbo_confirm: t('channels.messages.confirm.destroy') } diff --git a/app/views/channels/filters/index.html.slim b/app/views/channels/filters/index.html.slim index 28f2adb50..1f356ae45 100644 --- a/app/views/channels/filters/index.html.slim +++ b/app/views/channels/filters/index.html.slim @@ -15,3 +15,9 @@ = t('links.back_to_list') == render 'channels/filters/list', releases: @releases, channel: @channel + + - if @releases.present? && current_user&.manage?(app: @channel.app) + .card + .card-body + = button_to t('channels.filters.list.delete_all'), bulk_delete_url(@channel), class: 'btn btn-danger', \ + method: :delete, data: { turbo_confirm: t('channels.messages.confirm.destroy') }