Fix user adding/removing from a team [SCI-7240]

This commit is contained in:
Oleksii Kriuchykhin 2022-09-26 12:14:03 +02:00
parent a3ea6e608c
commit b675fb14eb
4 changed files with 6 additions and 8 deletions

View file

@ -86,7 +86,7 @@ class ProjectsController < ApplicationController
if stale?([@product, current_team])
render json: {
editable: can_manage_project?(@project),
moveable: can_update_team?(current_team),
moveable: can_manage_team?(current_team),
archivable: can_archive_project?(@project),
restorable: can_restore_project?(@project)
}

View file

@ -64,7 +64,7 @@ module Users
break
end
result = { email: email, user_teams: [] }
result = { email: email }
unless Constants::BASIC_EMAIL_REGEX.match?(email)
result[:status] = :user_invalid
@invite_results << result
@ -75,7 +75,6 @@ module Users
if user
result[:status] = :user_exists
result[:user] = user
else
user = User.invite!(
full_name: email,
@ -86,7 +85,6 @@ module Users
user.update(invited_by: @user)
result[:status] = :user_created
result[:user] = user
# Sending email invitation is done in background job to prevent
# issues with email delivery. Also invite method must be call

View file

@ -85,7 +85,7 @@ module Users
unless invalid
begin
UserTeam.transaction do
@user_assignment.transaction do
# If user leaves on his/her own accord,
# new owner for projects is the first
# administrator of team

View file

@ -1,10 +1,10 @@
<%= bootstrap_form_for user_team,
url: destroy_user_team_path(user_team, format: :json),
<%= bootstrap_form_for @user_assignment,
url: destroy_user_team_path(@user_assignment, format: :json),
remote: :true,
method: :delete,
data: { id: 'leave-user-team-form' } do |f| %>
<%= hidden_field_tag :leave, true %>
<p><%= t("users.settings.user_teams.leave_uo_message", team: user_team.team.name) %></p>
<p><%= t("users.settings.user_teams.leave_uo_message", team: @user_assignment.team.name) %></p>
<div class="alert alert-danger" role="alert">
<span class="fas fa-exclamation-triangle"></span>
&nbsp;