mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-09 21:56:32 +08:00
Fix task archiving permissions, archived labels in breadcrumbs [SCI-8586] (#5535)
This commit is contained in:
parent
26e4064ac9
commit
d4fb499a17
4 changed files with 17 additions and 25 deletions
|
|
@ -15,7 +15,8 @@ module Breadcrumbs
|
|||
|
||||
@breadcrumbs_items.push({
|
||||
label: t('projects.index.breadcrumbs_root'),
|
||||
url: projects_path(view_mode: project&.archived? ? :archived : :active)
|
||||
url: projects_path(view_mode: project&.archived? ? :archived : :active),
|
||||
archived: project&.archived? || (!project && params[:view_mode] == 'archived')
|
||||
})
|
||||
|
||||
folders&.each do |project_folder|
|
||||
|
|
@ -31,12 +32,8 @@ module Breadcrumbs
|
|||
|
||||
include_my_module(my_module) if my_module
|
||||
|
||||
archived_exists = @breadcrumbs_items.any? { |item| item[:archived] == true }
|
||||
|
||||
if params[:view_mode] == 'archived' || archived_exists
|
||||
@breadcrumbs_items.each do |item|
|
||||
item[:label] = "(A) #{item[:label]}"
|
||||
end
|
||||
@breadcrumbs_items.each do |item|
|
||||
item[:label] = "(A) #{item[:label]}" if item[:archived]
|
||||
end
|
||||
@breadcrumbs_items
|
||||
end
|
||||
|
|
@ -47,7 +44,7 @@ module Breadcrumbs
|
|||
def include_project(project)
|
||||
@breadcrumbs_items.push({
|
||||
label: project.name,
|
||||
url: project_path(project),
|
||||
url: project_path(view_mode: project.archived? ? :archived : :active),
|
||||
archived: project.archived?
|
||||
})
|
||||
end
|
||||
|
|
@ -56,7 +53,7 @@ module Breadcrumbs
|
|||
@breadcrumbs_items.push({
|
||||
label: experiment.name,
|
||||
url: my_modules_experiment_path(experiment),
|
||||
archived: experiment.archived?
|
||||
archived: experiment.archived_branch?
|
||||
})
|
||||
end
|
||||
|
||||
|
|
@ -64,7 +61,7 @@ module Breadcrumbs
|
|||
@breadcrumbs_items.push({
|
||||
label: my_module.name,
|
||||
url: my_module_path(my_module),
|
||||
archived: my_module.archived?
|
||||
archived: my_module.archived_branch?
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1163,7 +1163,8 @@ class ProtocolsController < ApplicationController
|
|||
|
||||
@breadcrumbs_items.push({
|
||||
label: t('breadcrumbs.protocols'),
|
||||
url: protocols_path
|
||||
url: protocols_path,
|
||||
archived: params[:type] == 'archived' || @protocol&.archived?
|
||||
})
|
||||
|
||||
if @protocol
|
||||
|
|
@ -1174,12 +1175,8 @@ class ProtocolsController < ApplicationController
|
|||
})
|
||||
end
|
||||
|
||||
archived_exists = @breadcrumbs_items.any? { |item| item[:archived] == true }
|
||||
|
||||
if params[:type] == 'archived' || archived_exists
|
||||
@breadcrumbs_items.each do |item|
|
||||
item[:label] = "(A) #{item[:label]}"
|
||||
end
|
||||
@breadcrumbs_items.each do |item|
|
||||
item[:label] = "(A) #{item[:label]}" if item[:archived]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -544,7 +544,8 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
@breadcrumbs_items.push({
|
||||
label: t('breadcrumbs.inventories'),
|
||||
url: repositories_path
|
||||
url: repositories_path,
|
||||
archived: params[:archived] == 'true' || @repository&.archived?
|
||||
})
|
||||
|
||||
if @repository
|
||||
|
|
@ -555,12 +556,8 @@ class RepositoriesController < ApplicationController
|
|||
})
|
||||
end
|
||||
|
||||
archived_exists = @breadcrumbs_items.any? { |item| item[:archived] == true }
|
||||
|
||||
if params[:archived] == 'true' || archived_exists
|
||||
@breadcrumbs_items.each do |item|
|
||||
item[:label] = "(A) #{item[:label]}"
|
||||
end
|
||||
@breadcrumbs_items.each do |item|
|
||||
item[:label] = "(A) #{item[:label]}" if item[:archived]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ Canaid::Permissions.register_for(MyModule) do
|
|||
# Module, its experiment and its project must be active for all the specified
|
||||
# permissions
|
||||
%i(manage_my_module
|
||||
archive_my_module
|
||||
manage_my_module_protocol
|
||||
manage_my_module_users
|
||||
manage_my_module_designated_users
|
||||
|
|
@ -48,7 +49,7 @@ Canaid::Permissions.register_for(MyModule) do
|
|||
end
|
||||
|
||||
can :archive_my_module do |user, my_module|
|
||||
!my_module.archived? && my_module.permission_granted?(user, MyModulePermissions::MANAGE)
|
||||
my_module.permission_granted?(user, MyModulePermissions::MANAGE)
|
||||
end
|
||||
|
||||
can :move_my_module do |user, my_module|
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue