diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index 1ef63c8b6..0da3fbecc 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -1,8 +1,8 @@ class ExperimentsController < ApplicationController include PermissionHelper before_action :set_experiment, except: [:new, :create] - before_action :set_project, only: [:new, :create] - before_action :check_view_permissions, only: [:canvas] + before_action :set_project, only: [:new, :create, :samples_index, :samples ] + # before_action :check_view_permissions, only: [:canvas] # except parameter could be used but it is not working. layout :choose_layout @@ -66,6 +66,22 @@ class ExperimentsController < ApplicationController end end + def samples + @samples_index_link = samples_index_experiment_path(@experiment, format: :json) + @organization = @experiment.project.organization + end + + def samples_index + @organization = @experiment.project.organization + + respond_to do |format| + format.html + format.json { + render json: ::SampleDatatable.new(view_context, @organization, @experiment, nil) + } + end + end + private def set_experiment @@ -74,7 +90,7 @@ class ExperimentsController < ApplicationController end def set_project - @project = Project.find_by_id(params[:project_id]) + @project = Project.find_by_id(params[:project_id]) || @experiment.project render_404 unless @project end diff --git a/app/helpers/permission_helper.rb b/app/helpers/permission_helper.rb index 162d332b3..f061a4ca7 100644 --- a/app/helpers/permission_helper.rb +++ b/app/helpers/permission_helper.rb @@ -140,7 +140,8 @@ module PermissionHelper :can_view_experiment, :can_view_experiment_archive, :can_archive_experiment, - :can_restore_experiment + :can_restore_experiment, + :can_view_experiment_samples ] do |proxy, *args, &block| if args[0] experiment = args[0] @@ -346,6 +347,9 @@ module PermissionHelper experiment.archived? and is_user_or_higher_of_project(experiment.project) end + def can_view_experiment_samples(experiment) + can_view_samples(experiment.project.organization) + end # ---- WORKFLOW PERMISSIONS ---- def can_edit_canvas(experiment) diff --git a/app/helpers/secondary_navigation_helper.rb b/app/helpers/secondary_navigation_helper.rb index a12c48af7..e867d3c4a 100644 --- a/app/helpers/secondary_navigation_helper.rb +++ b/app/helpers/secondary_navigation_helper.rb @@ -28,6 +28,10 @@ module SecondaryNavigationHelper action_name == 'module_archive' end + def is_experiment_samples? + action_name == 'samples' + end + def is_module_info? action_name == 'show' end diff --git a/app/views/experiments/samples.html.erb b/app/views/experiments/samples.html.erb new file mode 100644 index 000000000..4f5692ae9 --- /dev/null +++ b/app/views/experiments/samples.html.erb @@ -0,0 +1,7 @@ +<% provide(:head_title, raw(t("projects.samples.head_title", project: @experiment.name))) %> +<%= render partial: "shared/sidebar" %> +<%= render partial: "shared/secondary_navigation" %> + +