Merge branch 'features/rails-upgrade' into features/remove-front-end-gems

This commit is contained in:
Anton 2023-07-06 11:14:48 +02:00
commit 4b82ba9613
36 changed files with 144 additions and 129 deletions

View file

@ -9,7 +9,7 @@ AllCops:
- "spec/**/*"
NewCops: enable
UseCache: false
TargetRubyVersion: 2.6
TargetRubyVersion: 3.2
##################### Style ####################################
@ -100,6 +100,7 @@ Style/GuardClause:
Style/HashSyntax:
EnforcedStyle: ruby19
EnforcedShorthandSyntax: never
Style/IfUnlessModifier:
Enabled: true

View file

@ -15,7 +15,7 @@ RUN \
ENV APP_HOME /usr/src/app
ENV RAILS_ENV=production
ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/2.7.0
ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0
ENV PATH=$GEM_HOME/bin:$PATH
ENV BUNDLE_APP_CONFIG=.bundle
ENV BUNDLE_BUILD__SASSC=--disable-march-tune-native
@ -29,7 +29,7 @@ RUN \
bundle config set path '/usr/src/app/tmp/bundle' && \
bundle install --jobs `nproc` && \
cp -r tmp/bundle/ vendor && \
rm -rf vendor/bundle/ruby/2.7.0/cache && \
rm -rf vendor/bundle/ruby/3.2.0/cache && \
find vendor/bundle/ruby -type d -name '.git' -exec rm -rf {} + && \
bundle config --local path vendor/bundle
@ -65,14 +65,17 @@ RUN \
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
DEBIAN_FRONTEND=noninteractive \
apt-get update -qq && \
apt-get install -y --no-install-recommends \
default-jre-headless \
ca-certificates-java && \
apt-get install -y --no-install-recommends \
libjemalloc2 \
groff-base \
postgresql-client \
netcat-openbsd \
npm \
default-jre-headless \
netcat-openbsd \
poppler-utils \
librsvg2-2 \
libvips42 \
@ -95,7 +98,7 @@ RUN \
ENV APP_HOME /usr/src/app
ENV RAILS_ENV=production
ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/2.7.0
ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0
ENV PATH=$GEM_HOME/bin:$PATH
ENV BUNDLE_APP_CONFIG=.bundle

View file

@ -8,7 +8,7 @@ module ActiveStorage
def show
expires_in ActiveStorage.service_urls_expire_in
redirect_to @blob.url(disposition: params[:disposition])
redirect_to @blob.url(disposition: params[:disposition]), allow_other_host: true
end
end
end

View file

@ -12,7 +12,8 @@ module ActiveStorage
end
expires_in ActiveStorage.service_urls_expire_in
redirect_to @blob.representation(params[:variation_key]).processed.url(disposition: params[:disposition])
redirect_to @blob.representation(params[:variation_key]).processed.url(disposition: params[:disposition]),
allow_other_host: true
end
private

View file

@ -6,7 +6,7 @@ class ActivitiesController < ApplicationController
render json: {
more_url: local_vars.fetch(:more_activities_url),
html: render_to_string(
partial: 'list', locals: @vars
partial: 'list', locals: @vars, formats: :html
)
}
end

View file

@ -28,7 +28,8 @@ class AssetsController < ApplicationController
can_edit: can_manage_asset?(@asset),
gallery: params[:gallery],
preview: params[:preview]
}
},
formats: :html
) }
end
@ -60,7 +61,8 @@ class AssetsController < ApplicationController
locals: {
asset: @asset,
gallery_view_id: gallery_view_id
}) }
},
formats: :html) }
end
def file_url

View file

@ -7,7 +7,7 @@ class AtWhoController < ApplicationController
def users
users = @team.search_users(@query).limit(Constants::ATWHO_SEARCH_LIMIT + 1)
render json: {
users: [render_to_string(partial: 'shared/smart_annotation/users', locals: { users: users })]
users: [render_to_string(partial: 'shared/smart_annotation/users', locals: { users: users }, formats: :html)]
}
end
@ -44,7 +44,8 @@ class AtWhoController < ApplicationController
render json: {
res: [
render_to_string(partial: 'shared/smart_annotation/repository_items',
locals: { repository_rows: items, repository: repository })
locals: { repository_rows: items, repository: repository },
formats: :html)
],
repository: repository_id,
team: current_team.id
@ -53,15 +54,19 @@ class AtWhoController < ApplicationController
def menu
repositories = Repository.active.accessible_by_teams(@team)
render json: { html: render_to_string({ partial: "shared/smart_annotation/menu.html.erb",
locals: { repositories: repositories } }) }
render json: {
html: render_to_string(partial: 'shared/smart_annotation/menu',
locals: { repositories: repositories },
formats: :html)
}
end
def projects
res = SmartAnnotation.new(current_user, current_team, @query)
render json: {
res: [render_to_string(partial: 'shared/smart_annotation/project_items',
locals: { projects: res.projects })],
locals: { projects: res.projects },
formats: :html)],
team: current_team.id
}
end
@ -70,7 +75,8 @@ class AtWhoController < ApplicationController
res = SmartAnnotation.new(current_user, current_team, @query)
render json: {
res: [render_to_string(partial: 'shared/smart_annotation/experiment_items',
locals: { experiments: res.experiments })],
locals: { experiments: res.experiments },
formats: :html)],
team: current_team.id
}
end
@ -79,7 +85,8 @@ class AtWhoController < ApplicationController
res = SmartAnnotation.new(current_user, current_team, @query)
render json: {
res: [render_to_string(partial: 'shared/smart_annotation/my_module_items',
locals: { my_modules: res.my_modules })],
locals: { my_modules: res.my_modules },
formats: :html)],
team: current_team.id
}
end

View file

@ -18,10 +18,9 @@ class BioEddieAssetsController < ApplicationController
if asset && bio_eddie_params[:object_type] == 'Step'
create_register_bio_eddie_activity(asset, current_user) if bio_eddie_params[:schedule_for_registration] == 'true'
render json: {
html: render_to_string(partial: 'assets/asset', locals: {
asset: asset,
gallery_view_id: bio_eddie_params[:object_id]
})
html: render_to_string(partial: 'assets/asset',
locals: { asset: asset, gallery_view_id: bio_eddie_params[:object_id] },
formats: :html)
}
elsif asset && bio_eddie_params[:object_type] == 'Result'
create_register_bio_eddie_activity(asset, current_user) if bio_eddie_params[:schedule_for_registration] == 'true'

View file

@ -28,7 +28,8 @@ class CommentsController < ApplicationController
object_url: object_url,
comment_addable: comment_addable?(@commentable),
comments: render_to_string(partial: 'shared/comments/comments_list',
locals: { comments: comments })
locals: { comments: comments },
formats: :html)
}
end

View file

@ -30,9 +30,9 @@ module Dashboard
.where('my_modules.due_date > ? AND my_modules.due_date < ?', start_date, end_date)
.where(projects: { team_id: current_team.id })
render json: {
html: render_to_string(partial: 'shared/my_modules_list_partial', locals: {
my_modules: my_modules
})
html: render_to_string(partial: 'shared/my_modules_list_partial',
locals: { my_modules: my_modules },
formats: :html)
}
end
end

View file

@ -14,7 +14,7 @@ module Dashboard
tasks = load_tasks.page(page).per(Constants::INFINITE_SCROLL_LIMIT).without_count
tasks_list = tasks.map do |task|
render_to_string(partial: 'dashboards/current_tasks/task', locals: { task: task })
render_to_string(partial: 'dashboards/current_tasks/task', locals: { task: task }, formats: :html)
end
render json: { data: tasks_list, next_page: tasks.next_page }

View file

@ -31,8 +31,7 @@ class ExperimentsController < ApplicationController
@experiment = Experiment.new
render json: {
html: render_to_string(
partial: 'new_modal',
formats: :html
partial: 'new_modal', formats: :html
)
}
end
@ -63,7 +62,7 @@ class ExperimentsController < ApplicationController
def show
render json: {
html: render_to_string(partial: 'experiments/details_modal')
html: render_to_string(partial: 'experiments/details_modal', formats: :html)
}
end
@ -143,9 +142,7 @@ class ExperimentsController < ApplicationController
def edit
render json: {
html: render_to_string(
partial: 'edit_modal'
)
html: render_to_string(partial: 'edit_modal', formats: :html)
}
end
@ -256,7 +253,8 @@ class ExperimentsController < ApplicationController
render json: {
html: render_to_string(
partial: 'clone_modal',
locals: { view_mode: params[:view_mode] }
locals: { view_mode: params[:view_mode] },
formats: :html
)
}
end
@ -285,9 +283,7 @@ class ExperimentsController < ApplicationController
def move_modal
@projects = @experiment.movable_projects(current_user)
render json: {
html: render_to_string(
partial: 'move_modal'
)
html: render_to_string(partial: 'move_modal', formats: :html)
}
end
@ -331,9 +327,7 @@ class ExperimentsController < ApplicationController
@experiments = @experiment.project.experiments.active.where.not(id: @experiment)
.managable_by_user(current_user).order(name: :asc)
render json: {
html: render_to_string(
partial: 'move_modules_modal'
)
html: render_to_string(partial: 'move_modules_modal', formats: :html)
}
end
@ -394,7 +388,8 @@ class ExperimentsController < ApplicationController
render json: {
workflowimg: render_to_string(
partial: 'projects/show/workflow_img',
locals: { experiment: @experiment }
locals: { experiment: @experiment },
formats: :html
)
}
end

View file

@ -55,11 +55,17 @@ class GlobalActivitiesController < ApplicationController
@next_page = activities.next_page
@starting_timestamp = activities.first&.created_at.to_i
render json: {
activities_html: render_to_string(partial: 'activity_list'),
next_page: @next_page,
starting_timestamp: @starting_timestamp
}
respond_to do |format|
format.json do
render json: {
activities_html: render_to_string(partial: 'activity_list'),
next_page: @next_page,
starting_timestamp: @starting_timestamp
}
end
format.html do
end
end
end
def team_filter

View file

@ -143,15 +143,15 @@ class MyModulesController < ApplicationController
@activities = @my_module.last_activities(1, @per_page)
render json: {
html: render_to_string(partial: 'activities')
html: render_to_string(partial: 'activities', formats: :html)
}
end
# Due date modal window in full-zoom canvas
def due_date
render json: {
html: render_to_string(partial: 'due_date'),
title: t('my_modules.due_date.title', module: escape_input(@my_module.name))
html: render_to_string(partial: 'due_date', formats: :html),
title: t('.due_date.title', module: escape_input(@my_module.name))
}
end

View file

@ -852,28 +852,15 @@ class ProtocolsController < ApplicationController
end
def load_from_repository_modal
@protocol = Protocol.find_by_id(params[:id])
respond_to do |format|
format.json do
render json: {
html: render_to_string({
partial: "my_modules/protocols/load_from_repository_modal_body.html.erb"
})
}
end
end
render json: {
html: render_to_string(partial: 'my_modules/protocols/load_from_repository_modal_body', formats: :html)
}
end
def protocol_status_bar
respond_to do |format|
format.json do
render json: {
html: render_to_string({
partial: "my_modules/protocols/protocol_status_bar.html.erb"
})
}
end
end
render json: {
html: render_to_string(partial: 'my_modules/protocols/protocol_status_bar', formats: :html)
}
end
def version_comment

View file

@ -84,23 +84,13 @@ class RepositoriesController < ApplicationController
def create_modal
@repository = Repository.new
respond_to do |format|
format.json do
render json: {
html: render_to_string(
partial: 'create_repository_modal'
)
}
end
end
render json: {
html: render_to_string(partial: 'create_repository_modal', formats: :html)
}
end
def share_modal
respond_to do |format|
format.json do
render json: { html: render_to_string(partial: 'share_repository_modal') }
end
end
render json: { html: render_to_string(partial: 'share_repository_modal', formats: :html) }
end
def hide_reminders

View file

@ -101,20 +101,19 @@ class ResultTextsController < ApplicationController
respond_to do |format|
if saved
format.html {
format.html do
flash[:success] = success_flash
redirect_to results_my_module_path(@my_module)
}
format.json {
end
format.json do
render json: {
html: render_to_string({
partial: "my_modules/result.html.erb",
locals: {
result: @result
}
})
}, status: :ok
}
html: render_to_string(
partial: 'my_modules/result.html.erb',
locals: { result: @result },
formats: :html
)
}
end
else
format.json {
render json: @result.errors, status: :bad_request

View file

@ -102,7 +102,8 @@ class StepsController < ApplicationController
render json: {
html: render_to_string(
partial: 'steps/step',
locals: { step: @step }
locals: { step: @step },
formats: :html
)
}
end

View file

@ -15,7 +15,8 @@ class TeamsController < ApplicationController
render json: {
html: render_to_string(
partial: 'shared/sidebar/projects',
locals: { team: current_team, sort: params[:sort] }
locals: { team: current_team, sort: params[:sort] },
formats: :html
)
}
end
@ -50,7 +51,8 @@ class TeamsController < ApplicationController
partial: 'projects/export/modal',
locals: { num_projects: @exp_projects.size,
limit: TeamZipExport.exports_limit,
num_of_requests_left: current_user.exports_left - 1 }
num_of_requests_left: current_user.exports_left - 1 },
formats: :html
),
title: t('projects.export_projects.modal_title')
}
@ -58,7 +60,8 @@ class TeamsController < ApplicationController
render json: {
html: render_to_string(
partial: 'projects/export/error',
locals: { limit: TeamZipExport.exports_limit }
locals: { limit: TeamZipExport.exports_limit },
formats: :html
),
title: t('projects.export_projects.error_title'),
status: 'error'

View file

@ -11,9 +11,7 @@ class UserMyModulesController < ApplicationController
@user_my_modules = @my_module.user_my_modules
render json: {
html: render_to_string(
partial: 'designated_users'
),
html: render_to_string(partial: 'designated_users', formats: :html),
my_module_id: @my_module.id,
counter: @my_module.designated_users.count # Used for counter badge
}
@ -21,7 +19,7 @@ class UserMyModulesController < ApplicationController
def index
render json: {
html: render_to_string(partial: 'index')
html: render_to_string(partial: 'index', formats: :html)
}
end
@ -33,7 +31,7 @@ class UserMyModulesController < ApplicationController
render json: {
my_module: @my_module,
html: render_to_string(
partial: 'index_edit'
partial: 'index_edit', formats: :html
)
}
end
@ -48,7 +46,8 @@ class UserMyModulesController < ApplicationController
if params[:table]
render json: {
html: render_to_string(partial: 'experiments/assigned_users',
locals: { my_module: @my_module, user: current_user, skip_unassigned: false }),
locals: { my_module: @my_module, user: current_user, skip_unassigned: false },
formats: :html),
unassign_url: my_module_user_my_module_path(@my_module, @um)
}
else
@ -75,7 +74,8 @@ class UserMyModulesController < ApplicationController
if params[:table]
render json: {
html: render_to_string(partial: 'experiments/assigned_users',
locals: { my_module: @my_module, user: current_user, skip_unassigned: false })
locals: { my_module: @my_module, user: current_user, skip_unassigned: false },
formats: :html)
}
else
render json: {}

View file

@ -137,7 +137,7 @@ module Users
end
render json: {
html: render_to_string(partial: 'shared/invite_users_modal_results')
html: render_to_string(partial: 'shared/invite_users_modal_results', formats: :html)
}
end

View file

@ -77,7 +77,8 @@ module Users
render json: {
html: render_to_string(
partial: 'users/settings/teams/name_modal_body',
locals: { team: @team }
locals: { team: @team },
formats: :html
)
}
end
@ -86,7 +87,8 @@ module Users
render json: {
html: render_to_string(
partial: 'users/settings/teams/description_modal_body',
locals: { team: @team }
locals: { team: @team },
formats: :html
)
}
end

View file

@ -40,7 +40,8 @@ module Users
render json: {
html: render_to_string(
partial: 'users/settings/user_teams/leave_user_team_modal_body',
locals: { user_assignment: @user_assignment }
locals: { user_assignment: @user_assignment },
formats: :html
),
heading: I18n.t(
'users.settings.user_teams.leave_uo_heading',
@ -54,7 +55,8 @@ module Users
html: render_to_string(
partial: 'users/settings/user_teams/' \
'destroy_user_team_modal_body',
locals: { user_assignment: @user_assignment }
locals: { user_assignment: @user_assignment },
formats: :html
),
heading: I18n.t(
'users.settings.user_teams.destroy_uo_heading',

View file

@ -60,19 +60,22 @@ class ProtocolLinkedChildrenDatatable < CustomDatatable
res += "<li><span class='sn-icon sn-icon-projects'></span>&nbsp;"
res += @controller.render_to_string(
partial: 'search/results/partials/project_text',
locals: { project: record.my_module.experiment.project }
locals: { project: record.my_module.experiment.project },
formats: :html
)
res += '</li>'
res += "<li><i class='sn-icon sn-icon-experiment'></i>&nbsp;"
res += @controller.render_to_string(
partial: 'search/results/partials/experiment_text',
locals: { experiment: record.my_module.experiment }
locals: { experiment: record.my_module.experiment },
formats: :html
)
res += '</li>'
res += "<li><span class='sn-icon sn-icon-task'></span>&nbsp;"
res += @controller.render_to_string(
partial: 'search/results/partials/my_module_text',
locals: { my_module: record.my_module, link_to_page: :protocols }
locals: { my_module: record.my_module, link_to_page: :protocols },
formats: :html
)
res += '</li>'
res += '</ol>'

View file

@ -241,11 +241,12 @@ class ProtocolsDatatable < CustomDatatable
def versions_html(record)
@view.controller
.render_to_string(partial: 'protocols/index/protocol_versions',
locals: { protocol: record, readable: can_read_protocol_in_repository?(@user, record) })
locals: { protocol: record, readable: can_read_protocol_in_repository?(@user, record) },
formats: :html)
end
def access_html(record)
@view.controller.render_to_string(partial: 'protocols/index/protocol_access', locals: { protocol: record })
@view.controller.render_to_string(partial: 'protocols/index/protocol_access', locals: { protocol: record }, formats: :html)
end
def published_by(record)

View file

@ -78,7 +78,8 @@ class TeamUsersDatatable < CustomDatatable
data: { action: 'destroy-user-team' }
),
user: @user
}
},
formats: :html
)
}
end

View file

@ -173,7 +173,8 @@ module ApplicationHelper
:thumb,
base64_encoded_imgs
)
}
},
formats: :html
)
end

View file

@ -21,7 +21,7 @@ module CommentHelper
resultsNumber: comments.size,
moreUrl: more_url,
html: render_to_string(
partial: partial, locals: { comments: comments }
partial: partial, locals: { comments: comments }, formats: :html
)
}
end
@ -49,7 +49,8 @@ module CommentHelper
locals: {
comment: comment,
skip_header: false
}
},
formats: :html
)
}
else
@ -111,7 +112,8 @@ module CommentHelper
locals: {
comment: comment,
skip_header: false
}
},
formats: :html
)
}
else

View file

@ -23,10 +23,10 @@ module GlobalActivitiesHelper
end
if no_custom_links
I18n.t("global_activities.content.#{activity.type_of}_html", parameters.symbolize_keys)
I18n.t("global_activities.content.#{activity.type_of}_html", **parameters.symbolize_keys)
else
custom_auto_link(
I18n.t("global_activities.content.#{activity.type_of}_html", parameters.symbolize_keys),
I18n.t("global_activities.content.#{activity.type_of}_html", **parameters.symbolize_keys),
team: activity.team
)
end

View file

@ -32,7 +32,7 @@ module Experiments
penwidth: '3.0'
}
@graph = Graphviz::Graph.new('G', @graph_params)
@graph = Graphviz::Graph.new('G', **@graph_params)
@errors = []
end
@ -58,7 +58,7 @@ module Experiments
# draw nodes
node = @graph.add_node(
"#{subgraph_id}-#{index}",
@node_params.merge(
**@node_params.merge(
label: '',
pos: "#{my_module.x / 10},-#{my_module.y / 10}!"
)
@ -80,7 +80,7 @@ module Experiments
@exp.my_modules.without_group.each do |my_module|
@graph.add_node(
"Orphan-#{my_module.id}",
@node_params.merge(
**@node_params.merge(
label: '',
pos: "#{my_module.x / 10},-#{my_module.y / 10}!"
)

View file

@ -1,6 +1,6 @@
<% editable ||= false %>
<% if assignable.visible? %>
<%= form_with(model: assignable, url: [:update_default_public_user_role, :access_permissions, assignable], method: :put, remote: true, html: { class: 'member-item', id: 'public_assignments', data: { action: 'replace-form autosave-form', object_type: assignable.class.name.underscore.to_sym } }) do |f| %>
<%= form_with(model: assignable, url: [:update_default_public_user_role, :access_permissions, assignable], method: :put, html: { class: 'member-item', id: 'public_assignments', data: { remote: true, action: 'replace-form autosave-form', object_type: assignable.class.name.underscore.to_sym } }) do |f| %>
<div class="user-assignment-info">
<div class="global-avatar-container">
<%= image_tag "icon/team.png", class: 'img-circle pull-left' %>

View file

@ -6,7 +6,7 @@
item_id = dom_id(user, :assignment_member)
%>
<%= form_with(model: assignment, url: update_path, method: :put, remote: true, html: { class: 'member-item', id: item_id, data: { action: 'replace-form autosave-form', object_type: :assignment_member } }) do |f| %>
<%= form_with(model: assignment, url: update_path, method: :put, html: { class: 'member-item', id: item_id, data: { remote: true, action: 'replace-form autosave-form', object_type: :assignment_member } }) do |f| %>
<%= f.hidden_field :user_id, value: f.object.user.id %>
<div class="user-assignment-info">
<div class="global-avatar-container">

View file

@ -10,7 +10,7 @@
<%= t '.title', resource_name: assignable.name %>
</h4>
</div>
<%= form_with(url: create_path, method: :post, remote: true, html: { id: 'new-user-assignment-form', data: { object_type: assignable.class.to_s.downcase } }) do |f| %>
<%= form_with(url: create_path, method: :post, html: { id: 'new-user-assignment-form', data: { remote: true, object_type: assignable.class.to_s.downcase } }) do |f| %>
<div class="modal-body">
<div class="sci-input-container left-icon">
<%= text_field_tag :search_users, '',

View file

@ -47,6 +47,10 @@ Rails.application.configure do
config.action_mailer.perform_caching = false
Rails.application.routes.default_url_options = {
host: Rails.application.secrets.mail_server_url
}
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

View file

@ -38,6 +38,10 @@ Rails.application.configure do
config.action_mailer.perform_caching = false
Rails.application.routes.default_url_options = {
host: Rails.application.secrets.mail_server_url
}
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.

View file

@ -17,13 +17,13 @@ Rails.application.config.active_storage.variable_content_types << 'image/svg+xml
Rails.application.config.active_storage.variant_processor = :vips if ENV['ACTIVESTORAGE_ENABLE_VIPS'] == 'true'
ActiveStorage::Downloader.class_eval do
def open(key, checksum:, name: 'ActiveStorage-', tmpdir: nil)
def open(key, checksum: nil, verify: true, name: 'ActiveStorage-', tmpdir: nil)
open_tempfile(name, tmpdir) do |file|
download key, file
if checksum == 'dummy' || checksum.nil?
ActiveStorage::Blob.find_by(key: key).update(checksum: Digest::MD5.file(file).base64digest)
else
verify_integrity_of file, checksum: checksum
verify_integrity_of(file, checksum: checksum) if verify
end
yield file
end