Refactor the implementation in projects and experiements [SCI-8087]

This commit is contained in:
sboursen-scinote 2023-03-30 19:13:15 +02:00
parent b43d14f549
commit 42687547cf
2 changed files with 6 additions and 9 deletions

View file

@ -18,6 +18,7 @@ class ExperimentsController < ApplicationController
before_action :check_clone_permissions, only: %i(clone_modal clone)
before_action :check_move_permissions, only: %i(move_modal move)
before_action :set_inline_name_editing, only: %i(canvas table module_archive)
before_action :set_breadcrumbs_items, only: %i(canvas table module_archive)
layout 'fluid'
@ -77,7 +78,6 @@ class ExperimentsController < ApplicationController
end
def canvas
@breadcrumbs_items = breadcrumbs_items
redirect_to module_archive_experiment_path(@experiment) if @experiment.archived_branch?
@project = @experiment.project
@active_modules = @experiment.my_modules.active.order(:name)
@ -90,7 +90,6 @@ class ExperimentsController < ApplicationController
end
def table
@breadcrumbs_items = breadcrumbs_items
@project = @experiment.project
@experiment.current_view_state(current_user)
@my_module_visible_table_columns = current_user.my_module_visible_table_columns
@ -374,7 +373,6 @@ class ExperimentsController < ApplicationController
end
def module_archive
@breadcrumbs_items = breadcrumbs_items
@project = @experiment.project
@my_modules = @experiment.archived_branch? ? @experiment.my_modules : @experiment.my_modules.archived
@my_modules = @my_modules.with_granted_permissions(current_user, MyModulePermissions::READ_ARCHIVED)
@ -662,7 +660,7 @@ class ExperimentsController < ApplicationController
end
end
def breadcrumbs_items
def set_breadcrumbs_items
experiment = @experiment
project = experiment.project
current_folder = project&.project_folder
@ -693,6 +691,6 @@ class ExperimentsController < ApplicationController
url: my_modules_experiment_path(experiment)
})
breadcrumbs_items
@breadcrumbs_items = breadcrumbs_items
end
end

View file

@ -22,11 +22,11 @@ class ProjectsController < ApplicationController
before_action :load_exp_sort_var, only: :show
before_action :reset_invalid_view_state, only: %i(index cards show)
before_action :set_folder_inline_name_editing, only: %i(index cards)
before_action :set_breadcrumbs_items, only: %i(index show)
layout 'fluid'
def index
@breadcrumbs_items = breadcrumbs_items
if current_team
view_state = current_team.current_view_state(current_user)
@current_sort = view_state.state.dig('projects', projects_view_mode, 'sort') || 'atoz'
@ -307,7 +307,6 @@ class ProjectsController < ApplicationController
end
def show
@breadcrumbs_items = breadcrumbs_items
view_state = @project.current_view_state(current_user)
@current_sort = view_state.state.dig('experiments', experiments_view_mode(@project), 'sort') || 'atoz'
@current_view_type = view_state.state.dig('experiments', 'view_type')
@ -479,7 +478,7 @@ class ProjectsController < ApplicationController
message_items: message_items)
end
def breadcrumbs_items
def set_breadcrumbs_items
breadcrumbs_items = []
folders = helpers.tree_ordered_parent_folders(current_folder)
breadcrumbs_items.push({
@ -503,6 +502,6 @@ class ProjectsController < ApplicationController
})
end
breadcrumbs_items
@breadcrumbs_items = breadcrumbs_items
end
end