Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 6.0 #1698

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && \
build-essential gnupg2 tar git zsh libssl-dev zlib1g-dev libyaml-dev \
imagemagick libjpeg-dev libpng-dev libtiff-dev libwebp-dev \
tzdata \
vim git-flow tig tmux
vim git-lfs tig tmux

# Install postgresql-client-16
RUN curl -1sLf 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \
Expand Down Expand Up @@ -46,7 +46,7 @@ ENV RUBY_YJIT_ENABLE=true
ENV PATH "${ASDF_DIR}/bin:${ASDF_DIR}/shims:$PATH"
RUN git clone --quiet https://github.com/asdf-vm/asdf.git ${ASDF_DIR} && \
echo ". ${ASDF_DIR}/asdf.sh" >> ~/.bashrc && \
sed -i -E "s/^plugins=\(.+\)$/plugins=(debian asdf git git-flow tmux yarn ruby gem bundler rails)/g" ~/.zshrc
sed -i -E "s/^plugins=\(.+\)$/plugins=(debian asdf git tmux npm yarn ruby gem bundler rails)/g" ~/.zshrc

RUN asdf plugin add nodejs && \
asdf install nodejs $NODEJS_VERSION && \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
},
"rubyLsp.rubyVersionManager": {
"identifier": "asdf"
"identifier": "auto"
},
"dev.containers.mountWaylandSocket": false
},
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
# Tools
pgweb:
# no editing function yet, https://github.com/sosedoff/pgweb/issues/656
image: sosedoff/pgweb:0.16.1
image: sosedoff/pgweb:0.16.2
restart: unless-stopped
network_mode: service:db
environment:
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.ipa filter=lfs diff=lfs merge=lfs -binary
*.apk filter=lfs diff=lfs merge=lfs -binary
*.aab filter=lfs diff=lfs merge=lfs -binary
*.zip filter=lfs diff=lfs merge=lfs -binary
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ group :development, :test do
gem 'pry-rescue'

gem 'factory_bot_rails'
gem 'faker'

gem 'rspec-rails'
gem 'rswag-specs'
end
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ GEM
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
faker (3.4.2)
i18n (>= 1.8.11, < 2)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
Expand Down Expand Up @@ -649,6 +651,7 @@ DEPENDENCIES
devise-i18n (~> 1.12.1)
dotenv-rails
factory_bot_rails
faker
faraday (~> 2.12.0)
friendly_id (~> 5.5.1)
gitlab_omniauth-ldap (~> 2.2.0)
Expand Down
12 changes: 6 additions & 6 deletions app/assets/stylesheets/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ a {
text-decoration: none;
}

.callout {
a {
text-decoration: underline;
}
}

.navbar-brand {
.brand-text {
vertical-align: middle;
Expand Down Expand Up @@ -104,12 +110,6 @@ i.icon {
background-color: var(--bs-primary-bg);
}

.callout {
a {
text-decoration: underline;
}
}

.border-bottom {
border-color: var(--bs-border-color) !important;
}
Expand Down
12 changes: 8 additions & 4 deletions app/controllers/admin/apple_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ def create
@apple_key.private_key = private_key&.read
@apple_key.filename = private_key&.original_filename

if @apple_key.save
redirect_to admin_apple_key_path(@apple_key), notice: t('admin.apple_keys.create.successful')
else
render :new, status: :unprocessable_entity
ActiveRecord::Base.transaction do
if @apple_key.save
@apple_key.sync_team
@apple_key.sync_devices_job
redirect_to admin_apple_key_path(@apple_key), notice: t('admin.apple_keys.create.successful')
else
render :new, status: :unprocessable_entity
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/udid_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def update
end

if device_params[:sync_to_apple_key].to_i == 1
@device.start_sync_device_job(@apple_key.id)
@device.sync_devices_job(@apple_key.id)
end

redirect_to admin_apple_key_path(@apple_key.id)
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/controllers/modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ export default class extends Controller {
this.modal.show()
}

disconnect() {
this.clear()
}

close() {
this.clear()
}

clear() {
this.modal.hide()
this.element.remove()
}
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/reset_for_demo_mode_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def clear_all_data

def reset_table_auto_sequences
[
App, Scheme, Channel, Release, Device, Metadatum, DebugFile,
App, Scheme, Channel, Release, Device, Metadatum, DebugFile, DebugFileMetadatum,
Setting, AppleKey, AppleTeam, User, WebHook, Backup
].each do |model|
sequence_name = ActiveRecord::Base.connection.execute(
Expand All @@ -62,7 +62,7 @@ def reset_jobs

def init_demo_data
user = CreateAdminService.new.call
CreateSampleAppsService.new.call(user)
CreateSampleDataService.new.call(user)
end

def demo_mode?
Expand Down
12 changes: 5 additions & 7 deletions app/models/apple_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class AppleKey < ApplicationRecord
validate :appstoreconnect_api_role_permissions, on: :create
validate :distribution_certificate, on: :create

before_validation :generate_checksum
after_save :create_relate_team
after_create :start_sync_device_job
before_create :generate_checksum

def private_key_filename
@private_key_filename ||= "#{key_id}.key"
Expand Down Expand Up @@ -95,9 +93,7 @@ def update_device_name(device)
logger.error "Device may not exists or the other error in apple key #{id}: #{e}"
end

private

def create_relate_team
def sync_team
cert = apple_distribtion_certiticate
logger.debug "Fetching distribution_certificates is #{cert.name}"
create_team(
Expand All @@ -106,10 +102,12 @@ def create_relate_team
)
end

def start_sync_device_job
def sync_devices_job
SyncAppleDevicesJob.perform_later(id)
end

private

def private_key_format
OpenSSL::PKey.read(private_key)
rescue => e
Expand Down
2 changes: 1 addition & 1 deletion app/models/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def latest_release
releases.last
end

def recently_releases(limit = 10)
def recently_releases(limit = Setting.per_page)
releases.limit(limit).order(id: :desc)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def self.create_from_api(response)
device
end

def start_sync_device_job(apple_key_id)
def sync_devices_job(apple_key_id)
SyncDeviceNameJob.perform_later(apple_key_id, id)
end

Expand Down
9 changes: 7 additions & 2 deletions app/models/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ def bundle_id_matched
errors.add(:file, message)
end

def perform_teardown_job(user_id)
TeardownJob.perform_later(id, user_id)
def perform_teardown_job(user_id, when_to_run: :later)
case when_to_run
when :later
TeardownJob.perform_later(id, user_id)
when :now
TeardownJob.perform_now(id, user_id)
end
end

def platform
Expand Down
24 changes: 24 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ class User < ApplicationRecord
after_initialize :set_user_default_settings, if: :new_record?
after_initialize :generate_user_token, if: :new_record?

def create_app(**params)
role_params = params.delete(:roles) || {}
owner = params.delete(:owner) || false
role = params.delete(:role) || Collaborator.roles[:member]

ActiveRecord::Base.transaction do
app = App.create(params)

role_params[:user] = self
role_params[:app] = app
if owner
role_params[:role] = Collaborator.roles[:admin]
role_params[:owner] = true
else
role_params[:role] = role
role_params[:owner] = false
end

Collaborator.create(role_params)

app
end
end

private

def set_default_role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'securerandom'

class CreateSampleAppsService # rubocop:disable Metrics/ClassLength
class CreateSampleDataService # rubocop:disable Metrics/ClassLength
RELEASE_COUNT = 3

def call(user)
Expand Down
19 changes: 9 additions & 10 deletions app/views/admin/apple_keys/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,23 @@ ruby:
.card.mb-3
.card-header
h3.card-title = t('.key_metadata')
- if current_user&.manage?
.card-tools
= link_to t('.download_private_key'), private_key_admin_apple_key_path(@apple_key), \
class: 'btn btn-success btn-sm', title: "#{@apple_key.private_key_filename}", \
data: { bs_toggle: 'tooltip', bs_custom_class: 'default-tooltip' }
.card-body.p-0
.d-flex.px-3.py-2.border-bottom
.fw-bold.flex-fill = t('simple_form.labels.apple_key.issuer_id')
.text-end = @apple_key.issuer_id
.d-flex.px-3.py-2
.fw-bold.flex-fill = t('simple_form.labels.apple_key.key_id')
.text-end
= @apple_key.key_id
- if current_user&.manage?
| (
span title="#{@apple_key.private_key_filename}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip"
= link_to t('.download_private_key'), private_key_admin_apple_key_path(@apple_key)
| )

.text-end = @apple_key.key_id
.col-md-12
.card
.card-header
h3.card-title
= t('.devices', size: device_total)
.card-tools
= button_to t('.sync_now'), sync_devices_admin_apple_key_path(@apple_key), method: :put, class: 'btn btn-success btn-sm'
- if device_total
.card-body.p-0
table.table.table-bottom-borderless
Expand All @@ -65,6 +61,9 @@ ruby:
span title="#{l(device.created_at, format: :nice)}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip" data-bs-placement="right"
= time_ago_in_words(device.created_at)
.card-footer
.float-end
= button_to t('.sync_now'), sync_devices_admin_apple_key_path(@apple_key), method: :put, class: 'btn btn-success btn-sm'

- if @apple_key.last_synced_at.present?
span title="#{l(@apple_key.last_synced_at, format: :nice)}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip" data-bs-placement="right"
= t('.last_synced_at', time: time_ago_in_words(@apple_key.last_synced_at))
Expand Down
15 changes: 4 additions & 11 deletions app/views/admin/users/_user.html.slim
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
= turbo_frame_tag user, class: 'p-2 ps-3 border-top d-flex' do
.col-3.col-md-2.my-auto
.col-3.col-md-3.my-auto
= link_to user.username, edit_admin_user_path(user), data: { turbo_frame: :modal }
.col-7.col-md-3.my-auto
.col-7.col-md-4.my-auto
= user.email
.col-3.col-md-2.my-auto
= user.role_name
.col-2.my-auto.d-none.d-sm-table-cell
.col-2.col-md-1.my-auto.d-none.d-sm-table-cell
- if user.access_locked?
span.badge.text-bg-danger = t('admin.users.index.locked')
- elsif user.confirmed_at
span.badge.text-bg-secondary = t('admin.users.index.activated')
- else
span.badge.text-bg-primary = t('admin.users.index.inactive')
.col-2.my-auto.d-none.d-sm-table-cell
.col-2.col-md-2.my-auto.d-none.d-sm-table-cell
- if user.last_sign_in_at
= time_ago_in_words(user.last_sign_in_at)
- else
= t('admin.users.index.never_logged_in')
.col-1.my-auto.d-none.d-sm-table-cell
- if default_admin_in_demo_mode?(current_user)
button.btn.text-danger.p-0.float-end
i.fas.fa-trash-alt
- else
= button_link_to '', admin_user_path(user), 'trash-alt', class: 'btn text-danger p-0 me-3 float-end', \
data: { turbo_method: :delete, turbo_confirm: t('admin.users.index.destroy_user_confirm', user: user.username) }
11 changes: 5 additions & 6 deletions app/views/admin/users/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
.card
.card-body.p-0
.p-2.ps-3.d-flex.fw-bolder.border-bottom.border-1
.col-sm-4.col-md-2.my-auto
.col-3.col-md-3.my-auto
= t('.nickname')
.col-sm-4.col-md-3.my-auto
.col-7.col-md-4.my-auto
= t('.email')
.col-sm-4.col-md-2.my-auto
.col-3.col-md-2.my-auto
= t('.role')
.col-sm-2.my-auto.d-none.d-sm-table-cell
.col-2.col-md-1.my-auto.d-none.d-sm-table-cell
= t('.status')
.col-2.my-auto.d-none.d-sm-table-cell
.col-2.col-md-2.my-auto.d-none.d-sm-table-cell
= t('.last_login_time')
.col-1.my-auto.d-none.d-sm-table-cell
#users
- @users.each_with_index do |user, i|
= render user
14 changes: 10 additions & 4 deletions app/views/teardowns/_list.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
th = t('teardowns.index.platform')
th.d-none.d-sm-table-cell = t('teardowns.index.uploader')
th style="width: 160px" = t('teardowns.index.uploaded_at')

- if user_signed_in? && @metadata.any? { |md| current_user&.manage?(app: md.app) || current_user == md.user }
th.d-none.d-sm-table-cell style="width: 90px" = t('teardowns.index.actions')
- @metadata.each_with_index do |md, index|
Expand All @@ -36,11 +35,18 @@
= time_ago_in_words(md.created_at)

- if user_signed_in? && (md.user == current_user || current_user&.manage?(app: md.app))
td.d-none.d-sm-table-cell
= button_to teardown_path(md), method: :delete, class: 'btn btn-tool', \
data: { turbo_confirm: t('teardowns.messages.confirm.destroy') } do
td.d-none.d-sm-table-cell[
data-controller="destroy"
data-destroy-title-value="#{t('debug_files.confirm.destroy.title')}"
data-destroy-content-value="#{t('teardowns.messages.confirm.destroy')}"
data-destroy-cancel-value="#{t('debug_files.confirm.destroy.cancel')}"
]
button.btn.btn-tool data-action="click->destroy#click"
i.fas.fa-trash-alt

= button_to t('debug_files.confirm.destroy.ok'), teardown_path(md), method: :delete, \
class: 'btn btn-danger d-none', form: { data: { 'destroy-target' => 'destroyButton' } }

- if @metadata.total_pages > 1
.card-footer.clearfix
.float-end
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default: &default
<% if (url = ENV['ZEALOT_POSTGRES_URL']) && !url.to_s.empty? %>
<% if (url = ENV['ZEALOT_DATABASE_URL']) && !url.to_s.empty? %>
url: <%= url %>
<% else %>
adapter: postgresql
Expand Down
Loading