diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index 297d4f14a..800b3341d 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -297,8 +297,7 @@ class ExperimentsController < ApplicationController # POST: move_experiment(id) def move - move_response = nil - status = nil + project = Project.find_by(id: params[:project_id]) ActiveRecord::Base.transaction do @experiments.each do |experiment| @@ -309,20 +308,18 @@ class ExperimentsController < ApplicationController user_id: current_user.id) if service.succeed? flash[:success] = t('experiments.move.success_flash', experiment: experiment.name) - status = :ok view_state = experiment.current_view_state(current_user) view_type = view_state.state['my_modules']['view_type'] || 'canvas' - path = view_mode_redirect_url(view_type) else - message = "#{service.errors.values.join('. ')}." - status = :unprocessable_entity + render json: { + message: service.errors.values.join('. ') + }, status: :unprocessable_entity end - - move_response = { message: message, path: path } end end - render json: move_response, status: status + render json: { message: t('experiments.table.move_success_flash', + project: escape_input(project.name)), path: project_path(project) } end def move_modules_modal diff --git a/config/locales/en.yml b/config/locales/en.yml index 5599022c3..ffbd8e011 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1526,6 +1526,7 @@ en: no_projects: 'No projects: You don’t have edit access to any other projects.' table: head_title: "%{experiment} | Overview" + move_success_flash: "Successfully moved experiment(s) to project %{project}." column: id_html: 'ID' task_name_html: 'Task name'