diff --git a/Gemfile b/Gemfile index 87bd6f758..e14844a76 100644 --- a/Gemfile +++ b/Gemfile @@ -73,7 +73,7 @@ gem 'nested_form_fields' gem 'nokogiri', '~> 1.14.3' # HTML/XML parser gem 'rails_autolink', '~> 1.1', '>= 1.1.6' gem 'rgl' # Graph framework for project diagram calculations -gem 'roo', '~> 2.8.2' # Spreadsheet parser +gem 'roo', '~> 2.10.0' # Spreadsheet parser gem 'rotp' gem 'rqrcode', '~> 2.0' # QR code generator gem 'rubyzip', '>= 2.3.0' # will load new rubyzip version diff --git a/Gemfile.lock b/Gemfile.lock index 349c2cd4e..656783ff8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,47 +60,47 @@ GIT GEM remote: http://rubygems.org/ specs: - actioncable (7.0.5) - actionpack (= 7.0.5) - activesupport (= 7.0.5) + actioncable (7.0.5.1) + actionpack (= 7.0.5.1) + activesupport (= 7.0.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.5) - actionpack (= 7.0.5) - activejob (= 7.0.5) - activerecord (= 7.0.5) - activestorage (= 7.0.5) - activesupport (= 7.0.5) + actionmailbox (7.0.5.1) + actionpack (= 7.0.5.1) + activejob (= 7.0.5.1) + activerecord (= 7.0.5.1) + activestorage (= 7.0.5.1) + activesupport (= 7.0.5.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.5) - actionpack (= 7.0.5) - actionview (= 7.0.5) - activejob (= 7.0.5) - activesupport (= 7.0.5) + actionmailer (7.0.5.1) + actionpack (= 7.0.5.1) + actionview (= 7.0.5.1) + activejob (= 7.0.5.1) + activesupport (= 7.0.5.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.5) - actionview (= 7.0.5) - activesupport (= 7.0.5) + actionpack (7.0.5.1) + actionview (= 7.0.5.1) + activesupport (= 7.0.5.1) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.5) - actionpack (= 7.0.5) - activerecord (= 7.0.5) - activestorage (= 7.0.5) - activesupport (= 7.0.5) + actiontext (7.0.5.1) + actionpack (= 7.0.5.1) + activerecord (= 7.0.5.1) + activestorage (= 7.0.5.1) + activesupport (= 7.0.5.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.5) - activesupport (= 7.0.5) + actionview (7.0.5.1) + activesupport (= 7.0.5.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -110,24 +110,24 @@ GEM activemodel (>= 4.1, < 7.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (7.0.5) - activesupport (= 7.0.5) + activejob (7.0.5.1) + activesupport (= 7.0.5.1) globalid (>= 0.3.6) - activemodel (7.0.5) - activesupport (= 7.0.5) - activerecord (7.0.5) - activemodel (= 7.0.5) - activesupport (= 7.0.5) + activemodel (7.0.5.1) + activesupport (= 7.0.5.1) + activerecord (7.0.5.1) + activemodel (= 7.0.5.1) + activesupport (= 7.0.5.1) activerecord-import (1.4.1) activerecord (>= 4.2) - activestorage (7.0.5) - actionpack (= 7.0.5) - activejob (= 7.0.5) - activerecord (= 7.0.5) - activesupport (= 7.0.5) + activestorage (7.0.5.1) + actionpack (= 7.0.5.1) + activejob (= 7.0.5.1) + activerecord (= 7.0.5.1) + activesupport (= 7.0.5.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.5) + activesupport (7.0.5.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -412,8 +412,8 @@ GEM mime-types-data (3.2023.0218.1) mini_magick (4.12.0) mini_mime (1.1.2) - mini_portile2 (2.8.2) - minitest (5.18.0) + mini_portile2 (2.8.4) + minitest (5.18.1) momentjs-rails (2.17.1) railties (>= 3.1) msgpack (1.7.1) @@ -505,26 +505,27 @@ GEM rack rack-test (2.1.0) rack (>= 1.3) - rails (7.0.5) - actioncable (= 7.0.5) - actionmailbox (= 7.0.5) - actionmailer (= 7.0.5) - actionpack (= 7.0.5) - actiontext (= 7.0.5) - actionview (= 7.0.5) - activejob (= 7.0.5) - activemodel (= 7.0.5) - activerecord (= 7.0.5) - activestorage (= 7.0.5) - activesupport (= 7.0.5) + rails (7.0.5.1) + actioncable (= 7.0.5.1) + actionmailbox (= 7.0.5.1) + actionmailer (= 7.0.5.1) + actionpack (= 7.0.5.1) + actiontext (= 7.0.5.1) + actionview (= 7.0.5.1) + activejob (= 7.0.5.1) + activemodel (= 7.0.5.1) + activerecord (= 7.0.5.1) + activestorage (= 7.0.5.1) + activesupport (= 7.0.5.1) bundler (>= 1.15.0) - railties (= 7.0.5) + railties (= 7.0.5.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.1.1) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) rails-html-sanitizer (1.6.0) loofah (~> 2.21) @@ -538,9 +539,9 @@ GEM railties (> 3.1) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (7.0.5) - actionpack (= 7.0.5) - activesupport (= 7.0.5) + railties (7.0.5.1) + actionpack (= 7.0.5.1) + activesupport (= 7.0.5.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -561,7 +562,7 @@ GEM pairing_heap (>= 0.3.0) rexml (~> 3.2, >= 3.2.4) stream (~> 0.5.3) - roo (2.8.3) + roo (2.10.0) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) rotp (6.2.2) @@ -664,7 +665,7 @@ GEM thor (1.2.2) tilt (2.2.0) timecop (0.9.6) - timeout (0.3.2) + timeout (0.4.0) turbolinks (5.1.1) turbolinks-source (~> 5.1) turbolinks-source (5.2.0) @@ -772,7 +773,7 @@ DEPENDENCIES omniauth-okta! omniauth-rails_csrf_protection (~> 1.0) overcommit - pg (~> 1.1) + pg (~> 1.5) pg_search pry pry-byebug @@ -781,13 +782,13 @@ DEPENDENCIES puma rack-attack rack-cors - rails (~> 7.0.5) + rails (~> 7.0.5.1) rails-controller-testing rails_12factor rails_autolink (~> 1.1, >= 1.1.6) recaptcha rgl - roo (~> 2.8.2) + roo (~> 2.10.0) rotp rqrcode (~> 2.0) rspec-rails diff --git a/app/assets/javascripts/assets/asset_inline.js b/app/assets/javascripts/assets/asset_inline.js deleted file mode 100644 index fbe839544..000000000 --- a/app/assets/javascripts/assets/asset_inline.js +++ /dev/null @@ -1,7 +0,0 @@ -/* global ActiveStoragePreviews */ - -(function() { - $('.attachment-preview, .asset-inline-image') - .on('load', (event) => ActiveStoragePreviews.showPreview(event)) - .on('error', (event) => ActiveStoragePreviews.reCheckPreview(event)); -}()); diff --git a/app/assets/javascripts/assets/asset_thumbnail.js b/app/assets/javascripts/assets/asset_thumbnail.js deleted file mode 100644 index 6aa90fd53..000000000 --- a/app/assets/javascripts/assets/asset_thumbnail.js +++ /dev/null @@ -1,7 +0,0 @@ -/* global ActiveStoragePreviews */ - -(function() { - $('.attachment-preview .asset-thumbnail-image') - .on('load', (event) => ActiveStoragePreviews.showPreview(event)) - .on('error', (event) => ActiveStoragePreviews.reCheckPreview(event)); -}()); diff --git a/app/assets/javascripts/projects/index.js b/app/assets/javascripts/projects/index.js index dfea730ac..e9e194f0b 100644 --- a/app/assets/javascripts/projects/index.js +++ b/app/assets/javascripts/projects/index.js @@ -37,6 +37,7 @@ var ProjectsIndex = (function() { // Arrays with selected project and folder IDs shared between both views var selectedProjects = []; var selectedProjectFolders = []; + var singleSelectedProject; var destinationFolder; // Init new project folder modal function @@ -163,6 +164,7 @@ var ProjectsIndex = (function() { ev.preventDefault(); const projectId = $(this).data('projectId'); + singleSelectedProject = projectId; // Load HTML to refresh users list $.ajax({ @@ -223,7 +225,7 @@ var ProjectsIndex = (function() { type: 'POST', dataType: 'json', data: { - project_ids: selectedProjects, + project_ids: selectedProjects.length > 0 ? selectedProjects : [singleSelectedProject], project_folder_ids: selectedProjectFolders }, success: function(data) { @@ -232,7 +234,7 @@ var ProjectsIndex = (function() { HelperModule.flashAlertMsg(data.flash, 'success'); }, error: function() { - // TODO + HelperModule.flashAlertMsg(I18n.t('projects.export_projects.error_flash'), 'danger'); } }); }); diff --git a/app/assets/javascripts/reports/content.js b/app/assets/javascripts/reports/content.js index ee0aff54a..f0eb9c79d 100644 --- a/app/assets/javascripts/reports/content.js +++ b/app/assets/javascripts/reports/content.js @@ -64,7 +64,7 @@ el.handsontable('getInstance').getPlugin('columnSorting').sort(3, order); } else { - metadata = JSON.parse(metadataJson.val() || '{}'); + metadata = metadataJson.val() || {}; el.handsontable({ disableVisualSelection: true, rowHeaders: tableRowHeaders(metadata.plateTemplate), diff --git a/app/assets/javascripts/repositories/repository_datatable.js b/app/assets/javascripts/repositories/repository_datatable.js index 10d15e3d0..42ec8b9ac 100644 --- a/app/assets/javascripts/repositories/repository_datatable.js +++ b/app/assets/javascripts/repositories/repository_datatable.js @@ -503,7 +503,7 @@ var RepositoryDatatable = (function(global) { TABLE.ColSizes = state.ColSizes; - restoreColumnSizes(); + setTimeout(restoreColumnSizes, 100); } function dataTableInit() { @@ -547,6 +547,15 @@ var RepositoryDatatable = (function(global) { // force width of checkbox column data[0] = 30; + + // perserve widths of invisible columns or enforce min width + for (let i = 0; i < data.length; i++) { + if (data[i] === 0) { + let minWidth = parseInt($(TABLE.column(i).header()).css('min-width'), 10); + data[i] = colSizeMap[i] || minWidth; + } + } + state.ColSizes = data; $(TABLE_WRAPPER_ID).find('.table').addClass('table--resizable-columns'); @@ -744,8 +753,8 @@ var RepositoryDatatable = (function(global) { } }); }, - stateSaveCallback: function(settings, data) { - if (Object.keys(colSizeMap).length === 0) return; + stateSaveCallback: function(_, data) { + if (Object.keys(colSizeMap).length === 0) return true; let colSizes = []; diff --git a/app/assets/javascripts/repository_columns/index.js b/app/assets/javascripts/repository_columns/index.js index da755afbf..1c9eb54a3 100644 --- a/app/assets/javascripts/repository_columns/index.js +++ b/app/assets/javascripts/repository_columns/index.js @@ -237,24 +237,22 @@ var RepositoryColumns = (function() { } function toggleColumnVisibility() { - var lis = $(columnsList).find('.vis'); - lis.on('click', function(event) { - var self = $(this); - var li = self.closest('li'); - var column = TABLE.column(li.attr('data-position')); + $(columnsList).find('.vis').on('click', function(event) { + const $this = $(this); + const li = $this.closest('li'); + const column = TABLE.column(li.attr('data-position')); event.stopPropagation(); - - if (column.header.id !== 'row-name') { + if (!['row-name', 'archived-by', 'archived-on'].includes(column.header().id)) { if (column.visible()) { - self.addClass('sn-icon-visibility-hide'); - self.removeClass('sn-icon-visibility-show'); + $this.addClass('sn-icon-visibility-hide'); + $this.removeClass('sn-icon-visibility-show'); li.addClass('col-invisible'); column.visible(false); TABLE.setColumnSearchable(column.index(), false); } else { - self.addClass('sn-icon-visibility-show'); - self.removeClass('sn-icon-visibility-hide'); + $this.addClass('sn-icon-visibility-show'); + $this.removeClass('sn-icon-visibility-hide'); li.removeClass('col-invisible'); column.visible(true); TABLE.setColumnSearchable(column.index(), true); diff --git a/app/assets/javascripts/sitewide/active_storage_previews.js b/app/assets/javascripts/sitewide/active_storage_previews.js index 71ae5e95d..2a7ddb6bf 100644 --- a/app/assets/javascripts/sitewide/active_storage_previews.js +++ b/app/assets/javascripts/sitewide/active_storage_previews.js @@ -30,3 +30,16 @@ var ActiveStoragePreviews = (function() { } }); }()); + +$(document).on('turbolinks:load', function() { + $('.asset-preview-image') + .one('load', (event) => ActiveStoragePreviews.showPreview(event)) + .one('error', (event) => ActiveStoragePreviews.reCheckPreview(event)) + .each(function() { + if (this.complete) { + $(this).load(); + } else if (this.error) { + $(this).error(); + } + }); +}); diff --git a/app/assets/stylesheets/projects.scss b/app/assets/stylesheets/projects.scss index 00bb3c329..57cd56f27 100644 --- a/app/assets/stylesheets/projects.scss +++ b/app/assets/stylesheets/projects.scss @@ -386,7 +386,6 @@ path, ._jsPlumb_endpoint { div { font-size: 20px; width: 4px; - height: 0px; display: inline-block; & .fas { diff --git a/app/assets/stylesheets/settings/addons.scss b/app/assets/stylesheets/settings/addons.scss index 92e40912b..17c8e34ec 100644 --- a/app/assets/stylesheets/settings/addons.scss +++ b/app/assets/stylesheets/settings/addons.scss @@ -34,6 +34,8 @@ } .control { + align-items: center; + display: flex; margin-left: auto; } @@ -51,7 +53,7 @@ } } - .fas-check { + .sn-icon-check { margin-left: .25em; } } @@ -62,3 +64,14 @@ } } } + +.panel.panel-default { + .pull-right { + align-items: center; + display: flex; + + .sn-icon-check { + margin-left: .25em; + } + } +} diff --git a/app/assets/stylesheets/settings/teams.scss b/app/assets/stylesheets/settings/teams.scss index 7627e7e28..90f73ecf0 100644 --- a/app/assets/stylesheets/settings/teams.scss +++ b/app/assets/stylesheets/settings/teams.scss @@ -125,6 +125,10 @@ padding: 5px 0; } + .filter-table input { + width: auto !important; + } + .filter-table, .display-limit { flex-shrink: 0; diff --git a/app/assets/stylesheets/shared/form_errors.scss b/app/assets/stylesheets/shared/form_errors.scss index 661b214ac..3b12fd2ba 100644 --- a/app/assets/stylesheets/shared/form_errors.scss +++ b/app/assets/stylesheets/shared/form_errors.scss @@ -2,6 +2,7 @@ .sci-input-container { .help-block { color: $brand-danger; + font-size: 12px; } } diff --git a/app/assets/stylesheets/steps/components/text.scss b/app/assets/stylesheets/steps/components/text.scss index bf47be4e7..b79bfa881 100644 --- a/app/assets/stylesheets/steps/components/text.scss +++ b/app/assets/stylesheets/steps/components/text.scss @@ -22,6 +22,9 @@ } .view-text-element { + overflow-x: scroll; + pointer-events: initial; + a { pointer-events: initial; } diff --git a/app/controllers/concerns/active_storage/check_blob_permissions.rb b/app/controllers/concerns/active_storage/check_blob_permissions.rb index 8c1ddd970..064c2ea4c 100644 --- a/app/controllers/concerns/active_storage/check_blob_permissions.rb +++ b/app/controllers/concerns/active_storage/check_blob_permissions.rb @@ -58,7 +58,7 @@ module ActiveStorage current_user.permission_team = asset.team || current_team - return true if !asset.saved && can_read_team?(asset.team) + return true if asset.object.nil? && can_read_team?(asset.team) case asset.object_type when 'MyModule' diff --git a/app/controllers/global_activities_controller.rb b/app/controllers/global_activities_controller.rb index 56eeca497..6e29f7375 100644 --- a/app/controllers/global_activities_controller.rb +++ b/app/controllers/global_activities_controller.rb @@ -41,10 +41,6 @@ class GlobalActivitiesController < ApplicationController @teams.order(name: :asc) end @activity_types = Activity.activity_types_list - @user_list = User.where(id: UserTeam.where(team: current_user.teams).select(:user_id)) - .distinct - .order(full_name: :asc) - .pluck(:full_name, :id) activities = ActivitiesService.load_activities(current_user, selected_teams, activity_filters) diff --git a/app/controllers/my_module_tags_controller.rb b/app/controllers/my_module_tags_controller.rb index 312e38ed4..ea4c3665d 100644 --- a/app/controllers/my_module_tags_controller.rb +++ b/app/controllers/my_module_tags_controller.rb @@ -21,7 +21,8 @@ class MyModuleTagsController < ApplicationController render json: { html_module_header: render_to_string( partial: 'my_modules/tags', - locals: { my_module: @my_module, editable: can_manage_my_module?(@my_module) } + locals: { my_module: @my_module, editable: can_manage_my_module?(@my_module) }, + formats: :html ) } end @@ -36,7 +37,8 @@ class MyModuleTagsController < ApplicationController id: my_module.id, tags_html: render_to_string( partial: 'canvas/tags', - locals: { my_module: my_module } + locals: { my_module: my_module }, + formats: :html ) } end diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index db653d777..a6828bdef 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -115,9 +115,7 @@ class MyModulesController < ApplicationController MyModule: [@my_module.id] } @activity_types = Activity.activity_types_list - @user_list = User.where(id: UserTeam.where(team: current_user.teams).select(:user_id)) - .distinct - .pluck(:full_name, :id) + activities = ActivitiesService.load_activities(current_user, current_team, activity_filters) @grouped_activities = activities.group_by do |activity| diff --git a/app/controllers/navigator/base_controller.rb b/app/controllers/navigator/base_controller.rb index 37aa43e5c..d59fa42ba 100644 --- a/app/controllers/navigator/base_controller.rb +++ b/app/controllers/navigator/base_controller.rb @@ -109,20 +109,21 @@ module Navigator else object&.project_folder end + has_children_sql = 'SUM(CASE WHEN viewable_projects.id IS NOT NULL OR project_folders_project_folders.id IS NOT NULL + THEN 1 ELSE 0 END) > 0' current_team.project_folders.where(parent_folder: folder) - .where(project_folders: { archived: archived }) .left_outer_joins(:projects, project_folders: {}) .joins( - "LEFT OUTER JOIN (#{Project.viewable_by_user(current_user, current_team).to_sql}) " \ + "LEFT OUTER JOIN (#{Project.viewable_by_user(current_user, current_team).where(archived: archived).to_sql}) " \ "viewable_projects ON viewable_projects.project_folder_id = project_folders.id" ) .select( 'project_folders.id', 'project_folders.name', 'project_folders.archived', - 'SUM(CASE WHEN viewable_projects.id IS NOT NULL OR project_folders_project_folders.id IS NOT NULL - THEN 1 ELSE 0 END) > 0 AS has_children' + "#{has_children_sql} AS has_children" ).group('project_folders.id') + .having("project_folders.archived = :archived OR #{has_children_sql}", archived: archived) end def fetch_experiments(object, archived = false) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 4cbb31fb1..a7f6024d9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -175,9 +175,7 @@ class RepositoriesController < ApplicationController def rename_modal render json: { - html: render_to_string( - partial: 'rename_repository_modal' - ) + html: render_to_string(partial: 'rename_repository_modal', formats: :html) } end @@ -200,7 +198,7 @@ class RepositoriesController < ApplicationController name: @repository.name ) render json: { - html: render_to_string(partial: 'copy_repository_modal') + html: render_to_string(partial: 'copy_repository_modal', formats: :html) } end @@ -288,7 +286,7 @@ class RepositoriesController < ApplicationController if (@temp_file = parsed_file.generate_temp_file) render json: { - html: render_to_string(partial: 'repositories/parse_records_modal') + html: render_to_string(partial: 'repositories/parse_records_modal', formats: :html) } else repository_response(t('repositories.parse_sheet.errors.temp_file_failure')) diff --git a/app/controllers/result_assets_controller.rb b/app/controllers/result_assets_controller.rb index 3ff236a65..d351348ed 100644 --- a/app/controllers/result_assets_controller.rb +++ b/app/controllers/result_assets_controller.rb @@ -103,9 +103,9 @@ class ResultAssetsController < ApplicationController format.json do render json: { html: render_to_string( - partial: 'my_modules/result', locals: { result: @result } + partial: 'my_modules/result', locals: { result: @result }, formats: :html ) - }, status: :ok + } end else format.json do diff --git a/app/controllers/user_my_modules_controller.rb b/app/controllers/user_my_modules_controller.rb index 1e2302ad8..05fc01a42 100644 --- a/app/controllers/user_my_modules_controller.rb +++ b/app/controllers/user_my_modules_controller.rb @@ -54,7 +54,7 @@ class UserMyModulesController < ApplicationController render json: { user: { id: @um.user.id, - full_name: @um.user.full_name, + full_name: escape_input(@um.user.full_name), avatar_url: avatar_path(@um.user, :icon_small), user_module_id: @um.id } diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index 232869234..e320a141e 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -150,8 +150,7 @@ module Users .distinct teams = teams.where_attributes_like('teams.name', params[:query]) if params[:query].present? - teams.select { |team| can_invite_team_users?(team) } - + teams = teams.select { |team| can_invite_team_users?(team) } render json: teams.map { |t| { value: t.id, label: escape_input(t.name) } }.to_json end diff --git a/app/controllers/users/settings/teams_controller.rb b/app/controllers/users/settings/teams_controller.rb index 5c72f9c29..6208fc2f8 100644 --- a/app/controllers/users/settings/teams_controller.rb +++ b/app/controllers/users/settings/teams_controller.rb @@ -57,9 +57,7 @@ module Users end end - def show - @user_team = UserTeam.find_by(user: @user, team: @team) - end + def show; end def users_datatable render json: ::TeamUsersDatatable.new(view_context, @team, @user) diff --git a/app/controllers/wopi_controller.rb b/app/controllers/wopi_controller.rb index b4fd31622..f8f218b76 100644 --- a/app/controllers/wopi_controller.rb +++ b/app/controllers/wopi_controller.rb @@ -100,15 +100,15 @@ class WopiController < ActionController::Base if @asset.lock == lock @asset.refresh_lock response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok else response.headers['X-WOPI-Lock'] = @asset.lock - return render body: nil, status: :conflict + render body: nil, status: :conflict end else @asset.lock_asset(lock) response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok end end end @@ -126,14 +126,14 @@ class WopiController < ActionController::Base @asset.unlock @asset.lock_asset(lock) response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok else response.headers['X-WOPI-Lock'] = @asset.lock - return render body: nil, status: :conflict + render body: nil, status: :conflict end else response.headers['X-WOPI-Lock'] = ' ' - return render body: nil, status: :conflict + render body: nil, status: :conflict end end end @@ -151,15 +151,15 @@ class WopiController < ActionController::Base create_wopi_file_activity(@user, false) response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok else response.headers['X-WOPI-Lock'] = @asset.lock - return render body: nil, status: :conflict + render body: nil, status: :conflict end else logger.warn 'WOPI: tried to unlock non-locked file' response.headers['X-WOPI-Lock'] = ' ' - return render body: nil, status: :conflict + render body: nil, status: :conflict end end end @@ -174,14 +174,14 @@ class WopiController < ActionController::Base @asset.refresh_lock response.headers['X-WOPI-ItemVersion'] = @asset.version response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok else response.headers['X-WOPI-Lock'] = @asset.lock - return render body: nil, status: :conflict + render body: nil, status: :conflict end else response.headers['X-WOPI-Lock'] = ' ' - return render body: nil, status: :conflict + render body: nil, status: :conflict end end end @@ -189,7 +189,7 @@ class WopiController < ActionController::Base def get_lock @asset.with_lock do response.headers['X-WOPI-Lock'] = @asset.locked? ? @asset.lock : ' ' - return render body: nil, status: :ok + render body: nil, status: :ok end end @@ -211,11 +211,11 @@ class WopiController < ActionController::Base @protocol&.update(updated_at: Time.now.utc) response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok else logger.warn 'WOPI: wrong lock used to try and modify file' response.headers['X-WOPI-Lock'] = @asset.lock - return render body: nil, status: :conflict + render body: nil, status: :conflict end elsif !@asset.file_size.nil? && @asset.file_size.zero? logger.warn 'WOPI: initializing empty file' @@ -227,11 +227,11 @@ class WopiController < ActionController::Base @team.save response.headers['X-WOPI-ItemVersion'] = @asset.version - return render body: nil, status: :ok + render body: nil, status: :ok else logger.warn 'WOPI: trying to modify unlocked file' response.headers['X-WOPI-Lock'] = ' ' - return render body: nil, status: :conflict + render body: nil, status: :conflict end end end @@ -249,13 +249,13 @@ class WopiController < ActionController::Base @assoc = result_assoc unless result_assoc.nil? @assoc = repository_cell_assoc unless repository_cell_assoc.nil? - if @assoc.class == Step + if @assoc.instance_of?(Step) @protocol = @asset.step.protocol @team = @protocol.team - elsif @assoc.class == Result + elsif @assoc.instance_of?(Result) @my_module = @assoc.my_module @team = @my_module.experiment.project.team - elsif @assoc.class == RepositoryCell + elsif @assoc.instance_of?(RepositoryCell) @repository = @assoc.repository_column.repository @team = @repository.team end @@ -278,8 +278,9 @@ class WopiController < ActionController::Base # This is what we get for settings permission methods with # current_user + @user.permission_team = @team @current_user = @user - if @assoc.class == Step + if @assoc.instance_of?(Step) if @protocol.in_module? @can_read = can_read_protocol_in_module?(@protocol) @can_write = can_manage_step?(@assoc) @@ -299,7 +300,7 @@ class WopiController < ActionController::Base @breadcrumb_folder_name = 'Protocol managament' end @breadcrumb_folder_url = @close_url - elsif @assoc.class == Result + elsif @assoc.instance_of?(Result) @can_read = can_read_experiment?(@my_module.experiment) @can_write = can_manage_my_module?(@my_module) @@ -311,7 +312,7 @@ class WopiController < ActionController::Base host: ENV['WOPI_USER_HOST']) @breadcrumb_folder_name = @my_module.name @breadcrumb_folder_url = @close_url - elsif @assoc.class == RepositoryCell + elsif @assoc.instance_of?(RepositoryCell) @can_read = can_read_repository?(@repository) @can_write = !@repository.is_a?(RepositorySnapshot) && can_edit_wopi_file_in_repository_rows? diff --git a/app/datatables/protocol_linked_children_datatable.rb b/app/datatables/protocol_linked_children_datatable.rb index 4459eda06..9e4dd68b0 100644 --- a/app/datatables/protocol_linked_children_datatable.rb +++ b/app/datatables/protocol_linked_children_datatable.rb @@ -60,7 +60,7 @@ class ProtocolLinkedChildrenDatatable < CustomDatatable res += "