diff --git a/app/controllers/storage_location_repository_rows_controller.rb b/app/controllers/storage_location_repository_rows_controller.rb index 4ffa5365b..a35aa8cbf 100644 --- a/app/controllers/storage_location_repository_rows_controller.rb +++ b/app/controllers/storage_location_repository_rows_controller.rb @@ -6,7 +6,7 @@ class StorageLocationRepositoryRowsController < ApplicationController before_action :load_storage_location before_action :load_repository_row, only: %i(create update destroy move) before_action :check_read_permissions, except: %i(create actions_toolbar) - before_action :check_manage_permissions, only: %i(create update destroy) + before_action :check_manage_permissions, only: %i(create update destroy move) def index storage_location_repository_row = Lists::StorageLocationRepositoryRowsService.new( @@ -54,6 +54,9 @@ class StorageLocationRepositoryRowsController < ApplicationController def move ActiveRecord::Base.transaction do + @original_storage_location = @storage_location_repository_row.storage_location + @original_position = @storage_location_repository_row.human_readable_position + @storage_location_repository_row.discard @storage_location_repository_row = StorageLocationRepositoryRow.create!( repository_row: @repository_row, @@ -61,7 +64,13 @@ class StorageLocationRepositoryRowsController < ApplicationController metadata: storage_location_repository_row_params[:metadata] || {}, created_by: current_user ) - log_activity(:storage_location_repository_row_moved) + log_activity( + :storage_location_repository_row_moved, + { + storage_location_original: @original_storage_location.id, + position_original: @original_position + } + ) render json: @storage_location_repository_row, serializer: Lists::StorageLocationRepositoryRowSerializer rescue ActiveRecord::RecordInvalid => e @@ -125,7 +134,7 @@ class StorageLocationRepositoryRowsController < ApplicationController end def check_manage_permissions - render_403 unless can_create_storage_location_repository_rows?(@storage_location) + render_403 unless can_manage_storage_location_repository_rows?(@storage_location) end def log_activity(type_of, message_items = {}) diff --git a/app/controllers/storage_locations_controller.rb b/app/controllers/storage_locations_controller.rb index 13da18b9c..3bae95dd8 100644 --- a/app/controllers/storage_locations_controller.rb +++ b/app/controllers/storage_locations_controller.rb @@ -10,6 +10,7 @@ class StorageLocationsController < ApplicationController before_action :check_storage_locations_enabled, except: :unassign_rows before_action :load_storage_location, only: %i(update destroy duplicate move show available_positions unassign_rows export_container import_container) before_action :check_read_permissions, except: %i(index create tree actions_toolbar import_container unassign_rows) + before_action :check_manage_repository_rows_permissions, only: %i(import_container unassign_rows) before_action :check_create_permissions, only: :create before_action :check_manage_permissions, only: %i(update destroy duplicate move) before_action :set_breadcrumbs_items, only: %i(index show) @@ -86,7 +87,7 @@ class StorageLocationsController < ApplicationController def duplicate ActiveRecord::Base.transaction do - new_storage_location = @storage_location.duplicate!(current_user) + new_storage_location = @storage_location.duplicate!(current_user, current_team) if new_storage_location @storage_location = new_storage_location log_activity('storage_location_created') @@ -104,9 +105,11 @@ class StorageLocationsController < ApplicationController if move_params[:destination_storage_location_id] == 'root_storage_location' nil else - current_team.storage_locations.find(move_params[:destination_storage_location_id]) + StorageLocation.find(move_params[:destination_storage_location_id]) end + render_403 and return if destination_storage_location && !can_manage_storage_location?(destination_storage_location) + @storage_location.update!(parent: destination_storage_location) log_activity('storage_location_moved', { @@ -228,6 +231,10 @@ class StorageLocationsController < ApplicationController render_403 unless can_manage_storage_location?(@storage_location) end + def check_manage_repository_rows_permissions + render_403 unless can_manage_storage_location_repository_rows?(@storage_location) + end + def set_breadcrumbs_items @breadcrumbs_items = [] diff --git a/app/controllers/team_shared_objects_controller.rb b/app/controllers/team_shared_objects_controller.rb index c3cbb65f9..41e712d0c 100644 --- a/app/controllers/team_shared_objects_controller.rb +++ b/app/controllers/team_shared_objects_controller.rb @@ -8,26 +8,24 @@ class TeamSharedObjectsController < ApplicationController ActiveRecord::Base.transaction do @activities_to_log = [] + global_permission_level = + if params[:select_all_teams] + params[:select_all_write_permission] ? :shared_write : :shared_read + else + :not_shared + end + # Global share if @model.globally_shareable? - permission_level = - if params[:select_all_teams] - params[:select_all_write_permission] ? :shared_write : :shared_read - else - :not_shared - end - - @model.permission_level = permission_level + @model.permission_level = global_permission_level if @model.permission_level_changed? @model.save! - @model.team_shared_objects.each(&:destroy!) unless permission_level == :not_shared + @model.team_shared_objects.each(&:destroy!) unless global_permission_level == :not_shared case @model when Repository setup_repository_global_share_activity end - - log_activities and next end end @@ -35,11 +33,10 @@ class TeamSharedObjectsController < ApplicationController params[:team_share_params].each do |t| next unless t['private_shared_with'] - @model.update!(permission_level: :not_shared) if @model.globally_shareable? - team_shared_object = @model.team_shared_objects.find_or_initialize_by(team_id: t['id']) new_record = team_shared_object.new_record? + team_shared_object.update!( permission_level: t['private_shared_with_write'] ? :shared_write : :shared_read ) diff --git a/app/javascript/vue/protocol/container.vue b/app/javascript/vue/protocol/container.vue index d03b02909..a85f124d5 100644 --- a/app/javascript/vue/protocol/container.vue +++ b/app/javascript/vue/protocol/container.vue @@ -225,6 +225,7 @@ :title="i18n.t('protocols.reorder_steps.modal.title')" :items="steps" :includeNumbers="true" + dataE2e="protocol-templateSteps-reorder" @reorder="updateStepOrder" @close="closeStepReorderModal" /> diff --git a/app/javascript/vue/protocol/step.vue b/app/javascript/vue/protocol/step.vue index 88a7dd2b0..0546f3f04 100644 --- a/app/javascript/vue/protocol/step.vue +++ b/app/javascript/vue/protocol/step.vue @@ -162,7 +162,7 @@ diff --git a/app/javascript/vue/protocols/modals/new.vue b/app/javascript/vue/protocols/modals/new.vue index f97c78ae4..1ca7c71e7 100644 --- a/app/javascript/vue/protocols/modals/new.vue +++ b/app/javascript/vue/protocols/modals/new.vue @@ -31,7 +31,12 @@
- +