Merge pull request #5398 from aignatov-bio/ai-sci-8405-improve-navigation-in-archive-state

Improve navigation in archive state [SCI-8405]
This commit is contained in:
artoscinote 2023-05-16 10:38:37 +02:00 committed by GitHub
commit cf13160c4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -4,11 +4,11 @@ module Navigator
class BaseController < ApplicationController
private
def project_serializer(project)
def project_serializer(project, archived)
{
id: project.code,
name: project.name,
url: project_path(project, view_mode: project.archived ? 'archived' : 'active'),
url: project_path(project, view_mode: archived ? 'archived' : 'active'),
archived: project.archived,
type: :project,
has_children: project.has_children,
@ -16,11 +16,11 @@ module Navigator
}
end
def folder_serializer(folder)
def folder_serializer(folder, archived)
{
id: folder.code,
name: folder.name,
url: projects_path(project_folder_id: folder.id, view_mode: folder.archived ? 'archived' : 'active'),
url: projects_path(project_folder_id: folder.id, view_mode: archived ? 'archived' : 'active'),
archived: folder.archived,
type: :folder,
has_children: folder.has_children,
@ -28,11 +28,11 @@ module Navigator
}
end
def experiment_serializer(experiment)
def experiment_serializer(experiment, archived)
{
id: experiment.code,
name: experiment.name,
url: my_modules_experiment_path(experiment, view_mode: experiment.archived ? 'archived' : 'active'),
url: my_modules_experiment_path(experiment, view_mode: archived ? 'archived' : 'active'),
archived: experiment.archived_branch?,
type: :experiment,
has_children: experiment.has_children,
@ -164,8 +164,8 @@ module Navigator
end
def build_folder_tree(folder, children, archived = false)
tree = fetch_projects(folder.parent_folder, archived).map { |i| project_serializer(i) } +
fetch_project_folders(folder.parent_folder, archived).map { |i| folder_serializer(i) }
tree = fetch_projects(folder.parent_folder, archived).map { |i| project_serializer(i, archived) } +
fetch_project_folders(folder.parent_folder, archived).map { |i| folder_serializer(i, archived) }
tree.find { |i| i[:id] == folder.code }[:children] = children
tree = build_folder_tree(folder.parent_folder, tree, archived) if folder.parent_folder.present?
tree
@ -173,14 +173,14 @@ module Navigator
def project_level_branch(object = nil, archived = false)
fetch_projects(object, archived)
.map { |i| project_serializer(i) } +
.map { |i| project_serializer(i, archived) } +
fetch_project_folders(object, archived)
.map { |i| folder_serializer(i) }
.map { |i| folder_serializer(i, archived) }
end
def experiment_level_branch(object, archived = false)
fetch_experiments(object, archived)
.map { |i| experiment_serializer(i) }
.map { |i| experiment_serializer(i, archived) }
end
def my_module_level_branch(experiment, archived = false)

View file

@ -10,7 +10,6 @@
<a :href="item.url"
class="text-ellipsis overflow-hidden hover:no-underline"
:class="{
'pointer-events-none': (!item.archived && archived),
'text-sn-grey': (!item.archived && archived)
}">
<i v-if="itemIcon" class="mr-2" :class="itemIcon"></i>