Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ const errorMessage = ref("");
const submit = async ({ emails, role }) => {
const existingEmails = props.users.map(user => user.email);

if (emails.some(eml => existingEmails.includes(eml))) {
errorMessage.value = t("InvitationForm.userAlreadyExistInputErrorMessage");
const alreadyExistingEmail = emails.find(eml => existingEmails.includes(eml));
if (alreadyExistingEmail) {
errorMessage.value = t("InvitationForm.projectUserAlreadyExistError", { email: alreadyExistingEmail });
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script setup>
import { eachLimit } from "async";
import { ref } from "vue";
import { useI18n } from "vue-i18n";
import { SPACE_ROLE } from "../../../../config/spaces.js";
import { useSpaces } from "../../../../state/spaces.js";
import { useAppNotification } from "../../app/app-notification/app-notification.js";

Expand All @@ -27,29 +29,46 @@ const props = defineProps({

const emit = defineEmits(["close", "success"]);

const errorMessage = ref("");

const submit = async ({ emails }) => {
let isExistingUsersOnly = true;

await eachLimit(emails, 10, async eml => {
const user = props.users.find(user => user.email === eml);
if (user) {
await updateSpaceUser(props.space, { ...user, cloud_role: 100 });
return;
}

isExistingUsersOnly = false;
if (props.admin) {
await sendSpaceInvitation(props.space, { email: eml });
if (user) {
if (user.cloud_role === SPACE_ROLE.ADMIN) {
errorMessage.value = t("InvitationForm.spaceAdminAlreadyExistError", { email: eml });
} else {
await updateSpaceUser(props.space, { ...user, cloud_role: 100 });
}
} else {
isExistingUsersOnly = false;
await sendSpaceInvitation(props.space, { email: eml });
}
} else {
await sendSpaceInvitation(props.space, {
email: eml,
in_all_projects: true,
project_role: 50,
role: 50,
});
if (user) {
if (user.cloud_role === SPACE_ROLE.ADMIN) {
errorMessage.value = t("InvitationForm.spaceAdminAlreadyExistError", { email: eml });
} else {
errorMessage.value = t("InvitationForm.spaceUserAlreadyExistError", { email: eml });
}
} else {
isExistingUsersOnly = false;
await sendSpaceInvitation(props.space, {
email: eml,
role: 50,
in_all_projects: true,
project_role: 50,
});
}
}
});

if (errorMessage.value) return;

pushNotification(
{
type: "success",
Expand All @@ -66,5 +85,9 @@ const submit = async ({ emails }) => {
</script>

<template>
<InvitationForm @cancel="$emit('close')" @submit="submit" />
<InvitationForm
:error="errorMessage"
@cancel="$emit('close')"
@submit="submit"
/>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {
if (props.projectRole === PROJECT_ROLE.GUEST) {
return "guest";
}

return "projectUser";
});

Expand Down
2 changes: 1 addition & 1 deletion src/i18n/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"submitButtonText": "Einladen",
"successNotifText": "Einladung versendet",
"successUserToAdmin": "Der Nutzer wurde zum Administrator befördert.",
"userAlreadyExistInputErrorMessage": "Der Nutzer ist bereits in Ihren Projekt."
"projectUserAlreadyExistError": "Der Nutzer ist bereits in Ihren Projekt."
},
"ModelActionsCell": {
"addTagsButtonText": "Tags hinzufügen",
Expand Down
8 changes: 4 additions & 4 deletions src/i18n/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,10 @@
"folder_permissions_updated": "Folder permissions updated",
"folder_renamed": "Folder renamed",
"folder_moved": "Folder moved",

"cloud_invitation_sent": "Invitation sent",
"cloud_invitation_canceled": "Invitation canceled",
"cloud_invitation_accepted": "Invitation accepted",
"cloud_invitation_denied": "Invitation denied",

"project_invitation_sent": "Project invitation sent",
"project_invitation_canceled": "Project invitation canceled",
"project_invitation_accepted": "Project invitation accepted",
Expand Down Expand Up @@ -288,7 +286,9 @@
"submitButtonText": "Send invitation",
"successNotifText": "Invitation sent",
"successUserToAdmin": "The user has now admin role",
"userAlreadyExistInputErrorMessage": "User is already in the project"
"projectUserAlreadyExistError": "User {email} is already in the project",
"spaceUserAlreadyExistError": "User {email} is already in the space",
"spaceAdminAlreadyExistError": "User {email} is already an admin of the space"
},
"ModelActionsCell": {
"addTagsButtonText": "Add tags",
Expand Down Expand Up @@ -1046,4 +1046,4 @@
"title": "Delete {visasCount} visas",
"message": "You are about to delete the visas on the following files:"
}
}
}
2 changes: 1 addition & 1 deletion src/i18n/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"submitButtonText": "Invitar",
"successNotifText": "Invitación enviada",
"successUserToAdmin": "El usuario ha sido ascendido a administrador",
"userAlreadyExistInputErrorMessage": "El usuario ya está en su proyecto"
"projectUserAlreadyExistError": "El usuario ya está en su proyecto"
},
"ModelActionsCell": {
"addTagsButtonText": "Añadir etiquetas",
Expand Down
8 changes: 4 additions & 4 deletions src/i18n/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@
"folder_permissions_updated": "Modification des droits d’accès",
"folder_renamed": "Renommage du dossier",
"folder_moved": "Déplacement du dossier",

"cloud_invitation_sent": "Invitation envoyée",
"cloud_invitation_canceled": "Invitation annulée",
"cloud_invitation_accepted": "Invitation acceptée",
"cloud_invitation_denied": "Invitation refusée",

"project_invitation_sent": "Invitation projet envoyée",
"project_invitation_canceled": "Invitation projet annulée",
"project_invitation_accepted": "Invitation projet acceptée",
Expand Down Expand Up @@ -388,7 +386,9 @@
"InvitationForm": {
"emailInputPlaceholder": "Email de l'utilisateur",
"emailInputErrorMessage": "Email invalide",
"userAlreadyExistInputErrorMessage": "L'utilisateur est déjà dans votre projet",
"projectUserAlreadyExistError": "L'utilisateur {email} est déjà dans votre projet",
"spaceUserAlreadyExistError": "L'utilisateur {email} est déjà dans votre espace",
"spaceAdminAlreadyExistError": "L'utilisateur {email} est déjà admin dans votre espace",
"roleInputLabel": "Rôle",
"roles": {
"admin": "Administrateur",
Expand Down Expand Up @@ -1071,4 +1071,4 @@
"title": "Suppression de {visasCount} visas",
"message": "Vous êtes sur le point de supprimer les visas sur les fichiers suivants :"
}
}
}