Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed Jun 24, 2024
2 parents 4160c3a + bf673c2 commit c89a645
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 61 deletions.
2 changes: 0 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# See .devcontainer/Dockerfile.base and .github/workflows/publish_codespace.yml files.
FROM ghcr.io/tryzealot/codespace:latest

ENV RAILS_ENV=development

COPY . /workspace

USER root
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ARG BUILD_DATE
ARG VCS_REF
ARG TAG

ARG ZEALOT_VERSION="5.3.2"
ARG ZEALOT_VERSION="5.3.3"
ARG REPLACE_CHINA_MIRROR="true"
ARG ORIGINAL_REPO_URL="dl-cdn.alpinelinux.org"
ARG MIRROR_REPO_URL="mirrors.ustc.edu.cn"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
method_source (1.0.0)
method_source (1.1.0)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
Expand Down Expand Up @@ -387,8 +387,8 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
pry-rails (0.3.11)
pry (>= 0.13.0)
pry-rescue (1.6.0)
interception (>= 0.5)
pry (>= 0.12.0)
Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/apps/upload_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Api::Apps::UploadController < Api::BaseController
# @param branch [String] optional git branch
# @param git_commit [String] optional git commit
# @param ci_url [String] optional ci url
# @param allow_duplice [Boolean] optional allow duplice upload, default is false (true, false)
# @return [String] json formatted app info
def create
create_or_update_release
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/apps_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def release_type_url_builder(release)
return if release_type.blank?

title = release_type_name(release_type)
if params[:name] == release_type
title
else
if params[:name] != release_type && user_signed_in_or_guest_mode?
link_to(title, friendly_channel_release_types_path(release.channel, name: release_type))
else
title
end
end

Expand Down
1 change: 0 additions & 1 deletion app/helpers/collaborators_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def same_user?(collaborator)
end

def edit_role_user?(collaborator)
target_role = collaborator.role
return true if current_user.admin?
return true if current_user.app_roles?(collaborator.app, :admin)

Expand Down
2 changes: 1 addition & 1 deletion app/models/collaborator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Collaborator < ApplicationRecord
belongs_to :user
belongs_to :app

enum role: %i[user developer admin]
enum role: %i[member developer admin]

validates :owner, inclusion: [ true, false ]
validates :role, presence: true, exclusion: { in: Collaborator.roles.values }
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/setting_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def builtin_schemes

def builtin_roles
{
user: I18n.t('settings.preset_role.user', default: 'User'),
member: I18n.t('settings.preset_role.member', default: 'Member'),
developer: I18n.t('settings.preset_role.developer', default: 'Developer'),
admin: I18n.t('settings.preset_role.admin', default: 'Admin')
}
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/user_roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module UserRoles
included do
scope :admins, -> { where(role: :admin) }
scope :developers, -> { where(role: :developer) }
scope :users, -> { where(role: :user) }
scope :members, -> { where(role: :member) }
end

def manage?(app: nil)
Expand All @@ -18,15 +18,15 @@ def grant_admin!
end

def revoke_admin!
update!(role: :user)
update!(role: :member)
end

def grant_developer!
update!(role: :developer)
end

def revoke_developer!
update!(role: :user)
update!(role: :member)
end

def roles?(value)
Expand All @@ -44,7 +44,7 @@ def role_name
elsif developer?
:developer
else
:user
:member
end

Setting.builtin_roles[key]
Expand Down
16 changes: 10 additions & 6 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Setting < RailsSettings::Base
scope :presets do
field :preset_schemes, default: builtin_schemes, type: :array, display: true,
validates: { json: { format: :array } }
field :preset_role, default: 'user', type: :string, display: true,
field :preset_role, default: 'member', type: :string, display: true,
validates: { presence: true, inclusion: { in: builtin_roles.keys.map(&:to_s) } }
field :per_page, default: ENV.fetch('ZEALOT_PER_PAGE', '25').to_i, type: :integer, display: true,
validates: { presence: true, numericality: { only_integer: true } }
Expand Down Expand Up @@ -116,12 +116,16 @@ class Setting < RailsSettings::Base
type: :string, readonly: true
end

UMAMI_SCRIPT_URL = 'https://analytics.us.umami.is/script.js'
scope :analytics do
field :umami_script_url, default: (ENV['UMAMI_SCRIPT_URL'] || 'https://analytics.us.umami.is/script.js'),
type: :string, display: Setting.demo_mode
field :umami_website_id, default: ENV['UMAMI_WEBSITE_ID'], type: :string, display: Setting.demo_mode
field :clarity_analytics_id, default: ENV['CLARITY_ANALYTICS_ID'], type: :string, display: Setting.demo_mode
field :google_analytics_id, default: ENV['GOOGLE_ANALYTICS_ID'], type: :string, display: Setting.demo_mode
field :umami_script_url, default: (ENV['UMAMI_SCRIPT_URL'] || UMAMI_SCRIPT_URL), type: :string, readonly: true,
display: (value = ENV['UMAMI_SCRIPT_URL']) && value.present? && value != UMAMI_SCRIPT_URL
field :umami_website_id, default: ENV['UMAMI_WEBSITE_ID'], type: :string, readonly: true,
display: (value = ENV['UMAMI_WEBSITE_ID']) && value.present?
field :clarity_analytics_id, default: ENV['CLARITY_ANALYTICS_ID'], type: :string, readonly: true,
display: (value = ENV['CLARITY_ANALYTICS_ID']) && value.present?
field :google_analytics_id, default: ENV['GOOGLE_ANALYTICS_ID'], type: :string, readonly: true,
display: (value = ENV['GOOGLE_ANALYTICS_ID']) && value.present?
end

# Backup settings
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class User < ApplicationRecord
:rememberable, :trackable, :validatable, :recoverable, :lockable,
:omniauthable, omniauth_providers: %i[feishu gitlab google_oauth2 ldap openid_connect]

enum role: %i[user developer admin]
enum role: %i[member developer admin]
enum locale: enum_roles
enum appearance: enum_appearances
enum timezone: enum_timezones
Expand All @@ -31,7 +31,7 @@ class User < ApplicationRecord
private

def set_default_role
self.role ||= Setting.preset_role || :user
self.role ||= Setting.preset_role || :member
end

def set_user_default_settings
Expand Down
2 changes: 1 addition & 1 deletion app/policies/application_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def scope
Pundit.policy_scope!(user, record.class)
end

delegate :admin?, :developer?, :manage?, :user?, to: :user, allow_nil: true
delegate :admin?, :developer?, :manage?, :member?, to: :user, allow_nil: true

class Scope
attr_reader :user, :scope
Expand Down
4 changes: 1 addition & 3 deletions app/policies/release_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
class ReleasePolicy < ApplicationPolicy

def show?
return true if enabled_auth?

app_user?
true
end

def new?
Expand Down
2 changes: 1 addition & 1 deletion app/views/apps/_collaborators.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
span.badge.badge-primary.ml-1 = t('apps.show.collaborator_owner')
- if same_user?(collaborator)
span.badge.badge-secondary.ml-1 = t('apps.show.it_is_you')
td = collaborator.role
td = t(collaborator.role, scope: 'settings.preset_role')
td style="width: 120px"
- if collaborator.owner?
- if same_user?(collaborator) || current_user.admin?
Expand Down
9 changes: 3 additions & 6 deletions app/views/releases/body/_metadata.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
- if @release.name.present?
li title="#{t('releases.show.name')}" data-toggle="tooltip"
i.fas.fa-list-ul
- if user_signed_in_or_guest_mode?
= link_to @release.app_name, friendly_channel_overview_path(@release.channel)
- else
= @release.app_name
= link_to_if user_signed_in_or_guest_mode?, @release.app_name, friendly_channel_overview_path(@release.channel)
li title="#{t('releases.show.version')}" data-toggle="tooltip"
i.fab.fa-gg
= @release.version
Expand Down Expand Up @@ -56,14 +53,14 @@
- if @release.ci_url.blank?
= t("releases.sources.#{@release.source.downcase}", default: @release.source)
- else
= link_to @release.source, @release.ci_url
= link_to_if user_signed_in_or_guest_mode?, @release.source, @release.ci_url
- if @release.metadata.present? && user_signed_in_or_guest_mode?
- if expired_date = @release.metadata.mobileprovision['expired_at']
li title="#{t('releases.show.certificate_expired_date', date: expired_date)}" data-toggle="tooltip"
i.fas.fa-certificate
= expired_date_tips(expired_date, colorful: false)
li title="#{t('releases.show.metadata')}" data-toggle="tooltip"
i.fas.fa-layer-group
= link_to t('releases.show.teardown_metadata'), teardown_path(@release.metadata)
= link_to_if user_signed_in_or_guest_mode?, t('releases.show.teardown_metadata'), teardown_path(@release.metadata)

== render 'releases/body/install_app'
6 changes: 4 additions & 2 deletions app/views/releases/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
.col-md-4.col-lg-3
- if current_user&.manage?
= link_to t('releases.new.title'), new_channel_release_path(@channel), class: 'btn btn-success btn-block mb-3'
== render 'releases/sidebar/debug_file', debug_file: @release.debug_file
== render 'releases/sidebar/version', channel: @release.channel

- if user_signed_in_or_guest_mode?
== render 'releases/sidebar/debug_file', debug_file: @release.debug_file
== render 'releases/sidebar/version', channel: @release.channel
== render 'releases/sidebar/qrcode'
- if user_signed_in_or_guest_mode?
= link_to t('.view_detail'), friendly_channel_overview_path(@channel), class: 'btn btn-default btn-block'
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ en:
name: App name
collaborator:
user: User
role: Role
scheme:
name: Scheme name
new_build_callout: New build callout
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form/simple_form.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ zh-CN:
name: 应用名称
collaborator:
user: 用户
role: 权限
scheme:
name: 类型名称
new_build_callout: 新上传版本提示窗
Expand Down
5 changes: 3 additions & 2 deletions config/locales/zealot/api.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ en:
```json
{
"version": "5.3.2",
"version": "5.3.3",
"vcs_ref": "effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d",
"build_date": "2024-05-23T06:04:48.989Z"
}
Expand All @@ -32,7 +32,7 @@ en:
### Personal access tokens
Personal access tokens (PATs) can be found in from the [user settings](/docs/user-guide/user_settings).
Personal access tokens (PATs) can be found in from the [user settings](https://zealot.ews.im/docs/user-guide/user_settings).
servers:
description: Demo server
security:
Expand Down Expand Up @@ -96,6 +96,7 @@ en:
channel_key: Channel key, keep it empty to create a new App
file: The location of upload App binary file
name: the name of App. Use app name from parsed metadata in given file if leave it empty
password: visit password, clear it if leave it empty
release_type: Release type, for example, debug, beta, adhoc, release, enterprise etc
source: the source of upload (default is `api`)
changelog: Change log, accept plain text or JSON formatted data
Expand Down
5 changes: 3 additions & 2 deletions config/locales/zealot/api.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ zh-CN:
```json
{
"version": "5.3.2",
"version": "5.3.3",
"vcs_ref": "effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d",
"build_date": "2024-05-23T06:04:48.989Z"
}
Expand All @@ -29,7 +29,7 @@ zh-CN:
### 用户密钥
用户密钥在[用户详情](/docs/user-guide/user_settings)最底部找到。
用户密钥在[用户详情](https://zealot.ews.im/zh-Hans/docs/user-guide/user_settings)最底部找到。
servers:
description: 演示服务器
security:
Expand Down Expand Up @@ -93,6 +93,7 @@ zh-CN:
channel_key: 应用具体渠道的 Key,没有传此参数会字段创建对于的应用、类型和渠道
file: 本地支持上传类型的应用文件
name: 应用名称,为空时取 App 的信息
password: 设置访问密码,为空时清除密码
release_type: 应用类型,比如 debug, beta, adhoc, release, enterprise 等
source: 上传渠道名称,默认是 `api`
changelog: 变更日志,接受纯文本或 JSON 格式化的数据
Expand Down
3 changes: 2 additions & 1 deletion config/locales/zealot/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ en:
mailer_options: Options
analytics: Analytics
google_analytics_id: Google Analytics ID
umami_script_url: Umami script URL
umami_website_id: Umami Website ID
archives: Archive uploaded binaries
keep_uploads: Keep all builds
Expand Down Expand Up @@ -835,7 +836,7 @@ en:
adhoc: Adhoc
production: Production
preset_role:
user: User
member: Member
developer: Developer
admin: Admin
site_locale:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/zealot/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ zh-CN:
mailer_options: 发件服务器配置
analytics: 统计
google_analytics_id: Google 统计
umami_script_url: Umami 脚本 URL
umami_website_id: Umami 统计
archives: 上传文件
keep_uploads: 永久保存上传应用版本
Expand Down Expand Up @@ -829,7 +830,7 @@ zh-CN:
adhoc: 内测版
production: 产品版
preset_role:
user: 用户
member: 用户
developer: 开发者
admin: 管理员
site_locale:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zealot",
"version": "5.3.2",
"version": "5.3.3",
"private": true,
"license": "MIT",
"dependencies": {
Expand Down
3 changes: 0 additions & 3 deletions spec/api/apps_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
require 'swagger_helper'

RSpec.describe 'Apps API' do
let(:user) { create(:user) }
let(:app) { create(:app) }

path '/apps' do
get I18n.t('api.apps.index.title') do
tags I18n.t('api.apps.default.tags')
Expand Down
3 changes: 2 additions & 1 deletion spec/swagger_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
description: I18n.t('api.schemas.version.description'),
type: :object,
properties: {
version: { type: :integer, format: :int32, example: '5.3.2' },
version: { type: :integer, format: :int32, example: '5.3.3' },
vcs_ref: { type: :string, example: 'effe99c25b79fd55d3e1959ea3af0bcb6b75ba1d' },
build_date: { type: :string, example: '2024-05-23T06:04:48.989Z' }
}
Expand Down Expand Up @@ -298,6 +298,7 @@
channel_key: { type: :string, description: I18n.t('api.definitions.upload_options.properties.channel_key') },
file: { type: :file, description: I18n.t('api.definitions.upload_options.properties.file') },
name: { type: :string, description: I18n.t('api.definitions.upload_options.properties.name') },
password: { type: :string, description: I18n.t('api.definitions.upload_options.properties.password') },
release_type: { type: :string, description: I18n.t('api.definitions.upload_options.properties.release_type') },
source: { type: :string, description: I18n.t('api.definitions.upload_options.properties.source') },
changelog: { type: :array, items: { '$ref': '#/components/schemas/ReleaseChangelog' }, description: I18n.t('api.definitions.upload_options.properties.changelog')},
Expand Down
Loading

0 comments on commit c89a645

Please sign in to comment.