mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-24 08:41:56 +08:00
Refactor permissions breadcrumbs for users [SCI-6260] (#3665)
* Refactor permissions breadcrumbs for users [SCI-6260] * Change creator assignments to automatically [SCI-6260] Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
parent
6e65433c8d
commit
8f9ab4f6c3
8 changed files with 32 additions and 44 deletions
|
@ -24,6 +24,13 @@
|
|||
width: 200px;
|
||||
}
|
||||
|
||||
.permission-object-tag {
|
||||
@include font-small;
|
||||
background: $color-concrete;
|
||||
border-radius: $border-radius-tag;
|
||||
padding: .25em;
|
||||
}
|
||||
|
||||
.member-item,
|
||||
.user-assignment-info,
|
||||
.user-assignment-controls {
|
||||
|
|
|
@ -10,44 +10,17 @@ module UserAssignmentsHelper
|
|||
sanitize_input(display_name)
|
||||
end
|
||||
|
||||
def user_assignment_resource_role_name(user_assignment, user, resource)
|
||||
# Triggers N+1 but the partial is cached
|
||||
def user_assignment_resource_role_name(user, resource, inherit = '')
|
||||
user_assignment = resource.user_assignments.find_by(user: user)
|
||||
if resource.class != Project && user_assignment.automatically_assigned?
|
||||
parent = resource.permission_parent
|
||||
return user_assignment_resource_role_name(user, parent, '_inherit')
|
||||
end
|
||||
|
||||
if resource.is_a?(Experiment)
|
||||
project_user_assignment_name = resource.permission_parent
|
||||
.user_assignments
|
||||
.find_by(user: user)
|
||||
.user_role
|
||||
.name
|
||||
current_user_assignment_name = user_assignment.user_role.name
|
||||
|
||||
[
|
||||
t('user_assignment.from_project', user_role: project_user_assignment_name),
|
||||
(current_user_assignment_name unless current_user_assignment_name == project_user_assignment_name)
|
||||
].compact.join(' / ')
|
||||
elsif resource.is_a?(MyModule)
|
||||
project_user_assignment_name = resource.permission_parent
|
||||
.permission_parent
|
||||
.user_assignments
|
||||
.find_by(user: user)
|
||||
.user_role
|
||||
.name
|
||||
experiment_user_assignment_name = resource.permission_parent
|
||||
.user_assignments
|
||||
.find_by(user: user)
|
||||
.user_role
|
||||
.name
|
||||
current_user_assignment_name = user_assignment.user_role.name
|
||||
|
||||
[
|
||||
t('user_assignment.from_project',
|
||||
user_role: project_user_assignment_name),
|
||||
(t('user_assignment.from_experiment',
|
||||
user_role: experiment_user_assignment_name) unless project_user_assignment_name == experiment_user_assignment_name),
|
||||
(current_user_assignment_name unless experiment_user_assignment_name == current_user_assignment_name)
|
||||
].compact.join(' / ')
|
||||
else
|
||||
user_assignment.user_role.name
|
||||
end
|
||||
"#{user_assignment.user_role.name}
|
||||
<span class='permission-object-tag'
|
||||
title='#{t("access_permissions.partials.#{resource.class.to_s.downcase}_tooltip#{inherit}")}'>
|
||||
#{t("access_permissions.partials.#{resource.class.to_s.downcase}")}
|
||||
</span>".html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ module Assignable
|
|||
UserAssignment.create!(
|
||||
user: created_by,
|
||||
assignable: self,
|
||||
assigned: :manually, # we set this to manually since was the user action to create the item
|
||||
assigned: :automatically,
|
||||
user_role: role
|
||||
)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div>
|
||||
<%= current_assignee_name(user) %>
|
||||
<br>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(experiment_member, user, experiment) %></small>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(user, experiment) %></small>
|
||||
</div>
|
||||
</div>
|
||||
<% unless user == current_user %>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div>
|
||||
<%= current_assignee_name(user) %>
|
||||
<br>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(my_module_member, user, my_module) %></small>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(user, my_module) %></small>
|
||||
</div>
|
||||
</div>
|
||||
<% unless user == current_user %>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div>
|
||||
<%= current_assignee_name(user) %>
|
||||
<br>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(project_member, user, project) %></small>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(user, project) %></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-assignment-controls">
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
<div class="col-xs-10">
|
||||
<span><%= current_assignee_name(user) %></span>
|
||||
<br>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(user_assignment, user, resource) %></small>
|
||||
<small class="text-muted"><%= user_assignment_resource_role_name(user, resource) %></small>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2536,6 +2536,14 @@ en:
|
|||
my_module_member_field:
|
||||
reset: "Inherit role"
|
||||
reset_description: "The inherited role from project or experiment will be applied"
|
||||
project: "Project"
|
||||
project_tooltip: "This role was set on this project."
|
||||
project_tooltip_inherit: "This role was inhertied from the project."
|
||||
experiment: "Experiment"
|
||||
experiment_tooltip: "This role was set on this experiment."
|
||||
experiment_tooltip_inherit: "This role was inhertied from the experiment."
|
||||
mymodule: "Task"
|
||||
mymodule_tooltip: "This role was set on this task"
|
||||
|
||||
projects:
|
||||
modals:
|
||||
|
@ -2548,7 +2556,7 @@ en:
|
|||
title: "Access to %{resource_name}"
|
||||
edit_modal:
|
||||
title: "Manage access for %{resource_name}"
|
||||
description: "Changing roles will not take away any permissions from previous levels. Permissions can only be added with a new role. New permissions apply only to this concrete experiment."
|
||||
description: "Changing a role will take away any permissions inherited from the project. New permissions will apply only to this specific experiment and its tasks."
|
||||
my_modules:
|
||||
modals:
|
||||
show_modal:
|
||||
|
|
Loading…
Reference in a new issue