mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Activities update for grant project access to all team members [SCI-8383] (#5598)
* Create new activities for granting/revoking access to all team members on projects [SCI-8383]
This commit is contained in:
parent
e4076c931a
commit
966b92e8d2
4 changed files with 39 additions and 11 deletions
|
@ -68,7 +68,10 @@ module AccessPermissions
|
|||
|
||||
if user_assignment_params[:user_id] == 'all'
|
||||
@project.update!(visibility: :visible, default_public_user_role_id: user_assignment_params[:user_role_id])
|
||||
log_activity(:change_project_visibility, { visibility: t('projects.activity.visibility_visible') })
|
||||
log_activity(:project_grant_access_to_all_team_members,
|
||||
{ visibility: t('projects.activity.visibility_visible'),
|
||||
role: @project.default_public_user_role.name,
|
||||
team: @project.team.id })
|
||||
else
|
||||
user_assignment = UserAssignment.find_or_initialize_by(
|
||||
assignable: @project,
|
||||
|
@ -141,8 +144,13 @@ module AccessPermissions
|
|||
if permitted_default_public_user_role_params[:default_public_user_role_id].blank?
|
||||
# revoke all team members access
|
||||
@project.visibility = :hidden
|
||||
previous_user_role_name = @project.default_public_user_role.name
|
||||
@project.default_public_user_role_id = nil
|
||||
@project.save!
|
||||
log_activity(:change_project_visibility, { visibility: t('projects.activity.visibility_hidden') })
|
||||
log_activity(:project_remove_access_from_all_team_members,
|
||||
{ visibility: t('projects.activity.visibility_hidden'),
|
||||
role: previous_user_role_name,
|
||||
team: @project.team.id })
|
||||
render json: { flash: t('access_permissions.update.revoke_all_team_members') }
|
||||
else
|
||||
# update all team members access
|
||||
|
|
|
@ -184,7 +184,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
message_renamed = @project.name_changed?
|
||||
message_visibility = if @project.visibility_changed?
|
||||
message_visibility = if !@project.visibility_changed?
|
||||
nil
|
||||
elsif @project.visible?
|
||||
t('projects.activity.visibility_visible')
|
||||
|
@ -200,24 +200,38 @@ class ProjectsController < ApplicationController
|
|||
'restore'
|
||||
end
|
||||
|
||||
default_public_user_name = nil
|
||||
if @project.visibility_changed? && @project.default_public_user_role_id_changed?
|
||||
default_public_user_name = UserRole.find(project_params[:default_public_user_role_id])&.name
|
||||
default_public_user_role_name = nil
|
||||
if !@project.visibility_changed? && @project.default_public_user_role_id_changed?
|
||||
default_public_user_role_name = UserRole.find(project_params[:default_public_user_role_id]).name
|
||||
end
|
||||
|
||||
@project.last_modified_by = current_user
|
||||
if !return_error && @project.save
|
||||
|
||||
# Add activities if needed
|
||||
log_activity(:change_project_visibility, @project, visibility: message_visibility) if message_visibility.present?
|
||||
if message_visibility.present? && @project.visible?
|
||||
log_activity(:project_grant_access_to_all_team_members,
|
||||
@project,
|
||||
{ visibility: message_visibility,
|
||||
role: @project.default_public_user_role.name,
|
||||
team: @project.team.id })
|
||||
end
|
||||
if message_visibility.present? && !@project.visible?
|
||||
log_activity(:project_remove_access_from_all_team_members,
|
||||
@project,
|
||||
{ visibility: message_visibility,
|
||||
role: @project.default_public_user_role.name,
|
||||
team: @project.team.id })
|
||||
end
|
||||
|
||||
log_activity(:rename_project) if message_renamed.present?
|
||||
log_activity(:archive_project) if message_archived == 'archive'
|
||||
log_activity(:restore_project) if message_archived == 'restore'
|
||||
|
||||
if default_public_user_name.present?
|
||||
if default_public_user_role_name.present?
|
||||
log_activity(:project_access_changed_all_team_members,
|
||||
@project,
|
||||
{ team: @project.team.id, role: default_public_user_name })
|
||||
{ team: @project.team.id, role: default_public_user_role_name })
|
||||
end
|
||||
|
||||
flash_success = t('projects.update.success_flash', name: escape_input(@project.name))
|
||||
|
|
|
@ -441,11 +441,13 @@ class Extends
|
|||
protocol_template_access_granted_all_team_members: 238,
|
||||
protocol_template_access_changed_all_team_members: 239,
|
||||
protocol_template_access_revoked_all_team_members: 240,
|
||||
project_access_changed_all_team_members: 241
|
||||
project_access_changed_all_team_members: 241,
|
||||
project_grant_access_to_all_team_members: 242,
|
||||
project_remove_access_from_all_team_members: 243
|
||||
}
|
||||
|
||||
ACTIVITY_GROUPS = {
|
||||
projects: [*0..7, 32, 33, 34, 95, 108, 65, 109, *158..162, 241],
|
||||
projects: [*0..7, 32, 33, 34, 95, 108, 65, 109, *158..162, 241, 242, 243],
|
||||
task_results: [23, 26, 25, 42, 24, 40, 41, 99, 110, 122, 116, 128, 169, 172, 178],
|
||||
task: [8, 58, 9, 59, *10..14, 35, 36, 37, 53, 54, *60..63, 138, 139, 140, 64, 66, 106, 126, 120, 132,
|
||||
*146..148, 166],
|
||||
|
|
|
@ -47,6 +47,8 @@ en:
|
|||
create_project_html: "%{user} created project %{project}."
|
||||
rename_project_html: "%{user} renamed project %{project}."
|
||||
change_project_visibility_html: "%{user} changed project %{project}'s visibility to %{visibility}."
|
||||
project_grant_access_to_all_team_members_html: "%{user} granted access to all team members of %{team} team with user role %{role} to project %{project}."
|
||||
project_remove_access_from_all_team_members_html: "%{user} removed %{team} team members with user role %{role} from project %{project}."
|
||||
archive_project_html: "%{user} archived project %{project}."
|
||||
restore_project_html: "%{user} restored project %{project} from archive."
|
||||
add_comment_to_project_html: "%{user} commented on project %{project}."
|
||||
|
@ -270,6 +272,8 @@ en:
|
|||
create_project: "Project created"
|
||||
rename_project: "Project renamed"
|
||||
change_project_visibility: "Project visibility changed"
|
||||
project_grant_access_to_all_team_members: "Grant access to all team members"
|
||||
project_remove_access_from_all_team_members: "Remove access from all team members"
|
||||
archive_project: "Project archived"
|
||||
restore_project: "Project restored"
|
||||
add_comment_to_project: "Project comment added"
|
||||
|
|
Loading…
Reference in a new issue