From 2580e1e1eb74ba276dc30ab3b854b5946baedf7a Mon Sep 17 00:00:00 2001 From: ivanscinote <138504771+ivanscinote@users.noreply.github.com> Date: Tue, 14 Nov 2023 09:48:29 +0100 Subject: [PATCH 1/4] Fix display_url for Grover gem and add html format for r epository_rows show [SCI-9566] (#6632) * Apply layout for Grover PDF library [SCI-9566] * Fix display_url for Grover gem and add html format for repository_rows show [SCI-9566] --- app/controllers/repository_rows_controller.rb | 46 +++++++++++-------- app/jobs/reports/pdf_job.rb | 6 +-- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/app/controllers/repository_rows_controller.rb b/app/controllers/repository_rows_controller.rb index df30b23fe..a73c96396 100644 --- a/app/controllers/repository_rows_controller.rb +++ b/app/controllers/repository_rows_controller.rb @@ -46,27 +46,35 @@ class RepositoryRowsController < ApplicationController @repository_row = @repository.repository_rows.find_by(id: params[:id]) return render_404 unless @repository_row - @my_module = if params[:my_module_id].present? - MyModule.repository_row_assignable_by_user(current_user).find_by(id: params[:my_module_id]) - end - return render_403 if @my_module && !can_read_my_module?(@my_module) + respond_to do |format| + format.html do + redirect_to repository_path(@repository) + end - if @my_module - @my_module_assign_error = if !can_assign_my_module_repository_rows?(@my_module) - I18n.t('repository_row.modal_info.assign_to_task_error.no_access') - elsif @repository_row.my_modules.where(id: @my_module.id).any? - I18n.t('repository_row.modal_info.assign_to_task_error.already_assigned') - end + format.json do + @my_module = if params[:my_module_id].present? + MyModule.repository_row_assignable_by_user(current_user).find_by(id: params[:my_module_id]) + end + return render_403 if @my_module && !can_read_my_module?(@my_module) + + if @my_module + @my_module_assign_error = if !can_assign_my_module_repository_rows?(@my_module) + I18n.t('repository_row.modal_info.assign_to_task_error.no_access') + elsif @repository_row.my_modules.where(id: @my_module.id).any? + I18n.t('repository_row.modal_info.assign_to_task_error.already_assigned') + end + end + + @assigned_modules = @repository_row.my_modules + .joins(experiment: :project) + .joins(:my_module_repository_rows) + .select('my_module_repository_rows.created_at, my_modules.*') + .order('my_module_repository_rows.created_at': :desc) + .distinct + @viewable_modules = @assigned_modules.viewable_by_user(current_user, current_user.teams) + @reminders_present = @repository_row.repository_cells.with_active_reminder(@current_user).any? + end end - - @assigned_modules = @repository_row.my_modules - .joins(experiment: :project) - .joins(:my_module_repository_rows) - .select('my_module_repository_rows.created_at, my_modules.*') - .order('my_module_repository_rows.created_at': :desc) - .distinct - @viewable_modules = @assigned_modules.viewable_by_user(current_user, current_user.teams) - @reminders_present = @repository_row.repository_cells.with_active_reminder(@current_user).any? end def create diff --git a/app/jobs/reports/pdf_job.rb b/app/jobs/reports/pdf_job.rb index 86c166794..e14c83a2b 100644 --- a/app/jobs/reports/pdf_job.rb +++ b/app/jobs/reports/pdf_job.rb @@ -144,8 +144,7 @@ module Reports script_tag_options: @script_tag_options, page_ranges: "#{cover_pages_shift}-999999", emulate_media: 'screen', - display_url: "#{Rails.application.config.force_ssl ? 'https' : 'http'}://" \ - "#{Rails.application.routes.default_url_options[:host]}" + display_url: Rails.application.routes.default_url_options[:host] ).to_pdf(@file.path) end @@ -249,8 +248,7 @@ module Reports script_tag_options: @script_tag_options, emulate_media: 'screen', print_background: true, - display_url: "#{Rails.application.config.force_ssl ? 'https' : 'http'}://" \ - "#{Rails.application.routes.default_url_options[:host]}" + display_url: Rails.application.routes.default_url_options[:host] ).to_pdf(title_page.path) title_page.rewind From 83eb4eeb1674b03a6965c7a49a080f653632dd04 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 14 Nov 2023 11:54:50 +0100 Subject: [PATCH 2/4] Make task description TinyMCE init in line with the vue one [SCI-9682] --- app/assets/javascripts/my_modules/protocols.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/my_modules/protocols.js b/app/assets/javascripts/my_modules/protocols.js index b294dec22..97f9d581a 100644 --- a/app/assets/javascripts/my_modules/protocols.js +++ b/app/assets/javascripts/my_modules/protocols.js @@ -12,7 +12,12 @@ var selectedRow = null; function initEditMyModuleDescription() { var viewObject = $('#my_module_description_view'); viewObject.on('click', function(e) { - if ($(e.target).hasClass('record-info-link') || $(e.target).parent().hasClass('record-info-link')) return; + if (e && $(e.target).prop("tagName") === 'A') return; + if (e && $(e.target).hasClass('atwho-user-popover')) return; + if (e && $(e.target).hasClass('record-info-link')) return; + if (e && $(e.target).parent().hasClass('record-info-link')) return; + if (e && $(e.target).parent().hasClass('atwho-inserted')) return; + TinyMCE.init( '#my_module_description_textarea', { From 4c82e037a27225231c4cf029de10cecd407a9357 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 14 Nov 2023 16:38:51 +0100 Subject: [PATCH 3/4] Switch to install of yarn from system packages --- Dockerfile | 10 ++++++---- Dockerfile.production | 15 +++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 82c960073..4dc87507a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ RUN apt-get update -qq && \ libjemalloc2 \ libssl-dev \ nodejs \ - npm \ postgresql-client \ default-jre-headless \ poppler-utils \ @@ -21,12 +20,15 @@ RUN apt-get update -qq && \ fonts-wqy-microhei \ fonts-wqy-zenhei \ libfile-mimeinfo-perl \ - chromium-driver && \ - npm install -g yarn && \ - yarn add puppeteer@npm:puppeteer-core && \ + chromium-driver \ + yarnpkg && \ ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so && \ rm -rf /var/lib/apt/lists/* +ENV PATH=/usr/share/nodejs/yarn/bin:$PATH + +RUN yarn add puppeteer@npm:puppeteer-core + ENV BUNDLE_PATH /usr/local/bundle/ # create app directory diff --git a/Dockerfile.production b/Dockerfile.production index 8384a8c79..b5a7a99fb 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -9,14 +9,13 @@ RUN \ apt-get install -y --no-install-recommends \ libssl-dev \ nodejs \ - npm \ - postgresql-client && \ - npm install -g yarn + yarnpkg \ + postgresql-client ENV APP_HOME /usr/src/app ENV RAILS_ENV=production ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0 -ENV PATH=$GEM_HOME/bin:$PATH +ENV PATH=$GEM_HOME/bin:/usr/share/nodejs/yarn/bin:$PATH ENV BUNDLE_APP_CONFIG=.bundle ENV BUNDLE_BUILD__SASSC=--disable-march-tune-native @@ -69,7 +68,7 @@ RUN \ libjemalloc2 \ groff-base \ postgresql-client \ - npm \ + nodejs \ awscli \ netcat-openbsd \ poppler-utils \ @@ -77,9 +76,9 @@ RUN \ libvips42 \ graphviz \ chromium \ - libfile-mimeinfo-perl && \ - npm install -g yarn && \ - yarn add puppeteer@npm:puppeteer-core && \ + libfile-mimeinfo-perl \ + yarnpkg && \ + /usr/share/nodejs/yarn/bin/yarn add puppeteer@npm:puppeteer-core && \ apt-get install -y libreoffice && \ ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so From 3ff7e691090c9cd0e86082a4fffaaba5ffe22aa4 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 14 Nov 2023 16:57:57 +0100 Subject: [PATCH 4/4] Fix result settings for reports [SCI-9693] --- .../elements/_my_module_element.html.erb | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/app/views/reports/elements/_my_module_element.html.erb b/app/views/reports/elements/_my_module_element.html.erb index 5d91b2d0a..e3504a250 100644 --- a/app/views/reports/elements/_my_module_element.html.erb +++ b/app/views/reports/elements/_my_module_element.html.erb @@ -71,34 +71,37 @@
<%= t('projects.reports.elements.module.results') %>

- <% end %> - <% order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| %> -
- <%= result.name.presence || I18n.t('projects.reports.unnamed') %> - <% if result.archived? %> - <%= t('search.index.archived') %> - <% end %> -
+ <% order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| %> +
+ <%= result.name.presence || I18n.t('projects.reports.unnamed') %> + <% if result.archived? %> + <%= t('search.index.archived') %> + <% end %> +
- <% result.result_orderable_elements.each do |element| %> - <% if element.orderable_type == "ResultTable" %> - <%= render partial: 'reports/elements/my_module_result_table_element', locals: { result: result, export_all: export_all, element: element} %> - <% elsif element.orderable_type == "ResultText" %> - <%= render partial: 'reports/elements/my_module_result_text_element', locals: { result: result, export_all: export_all, element: element } %> + <% result.result_orderable_elements.each do |element| %> + <% if element.orderable_type == "ResultTable" && @settings.dig('task', 'table_results') %> + <%= render partial: 'reports/elements/my_module_result_table_element', locals: { result: result, export_all: export_all, element: element} %> + <% elsif element.orderable_type == "ResultText" && @settings.dig('task', 'text_results') %> + <%= render partial: 'reports/elements/my_module_result_text_element', locals: { result: result, export_all: export_all, element: element } %> + <% end %> <% end %> + + <% if @settings.dig('task', 'file_results') %> + <%= render partial: 'reports/elements/my_module_result_asset_element', locals: { result: result, report: report, export_all: export_all } %> + <% end %> + +
+ <%= t('projects.reports.elements.result.user_time', user: result.user.full_name, timestamp: l(result.created_at, format: :full)) %> +
+ +
+ <% if @settings.dig('task', 'result_comments') %> + <%= render partial: 'reports/elements/result_comments_element', locals: { result: result } %> + <% end %> +
<% end %> - - <%= render partial: 'reports/elements/my_module_result_asset_element', locals: { result: result, report: report, export_all: export_all } %> -
- <%= t('projects.reports.elements.result.user_time', user: result.user.full_name, timestamp: l(result.created_at, format: :full)) %> -
- -
- <% if @settings.dig('task', 'result_comments') %> - <%= render partial: 'reports/elements/result_comments_element', locals: { result: result } %> - <% end %> -
<% end %>