diff --git a/src/components/specific/subscriptions/space-creator/SpaceCreator.vue b/src/components/specific/subscriptions/space-creator/SpaceCreator.vue
index 264847ee2..908a61250 100644
--- a/src/components/specific/subscriptions/space-creator/SpaceCreator.vue
+++ b/src/components/specific/subscriptions/space-creator/SpaceCreator.vue
@@ -116,7 +116,7 @@ export default {
newSpaceLoading.value = true;
// TODO: Try to fix/improve
- // Here we set both `organizationId` and `organization.id`
+ // Here we set both `organization_id` and `organization.id`
// because they are both used elsewhere in the code.
// Setting only one of the two would break in some cases.
// More specifically:
@@ -144,10 +144,10 @@ export default {
// References
newSpace,
newSpaceLoading,
- openBillingAccountModal,
orga,
spaceNameInput,
// Methods
+ openBillingAccountModal,
submit,
updateOrga
};
diff --git a/src/components/specific/users/invitation-form/InvitationForm.vue b/src/components/specific/users/invitation-form/InvitationForm.vue
index 57236b3c1..f8b79a92a 100644
--- a/src/components/specific/users/invitation-form/InvitationForm.vue
+++ b/src/components/specific/users/invitation-form/InvitationForm.vue
@@ -7,17 +7,13 @@
class="invitation-form__input__email"
:placeholder="$t('InvitationForm.emailInputPlaceholder')"
v-model="email"
- :error="hasError"
- :errorMessage="
- userAlreadyExist
- ? $t('InvitationForm.userAlreadyExistInputErrorMessage')
- : $t('InvitationForm.emailInputErrorMessage')
- "
+ :error="errorMessage !== ''"
+ :errorMessage="errorMessage"
@keyup.enter.stop="submit"
margin="0px"
/>
-
+
{{ $t("t.cancel") }}
import { onMounted, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { useAppNotification } from "../../app/app-notification/app-notification.js";
import { PROJECT_ROLE } from "../../../../config/projects.js";
-import { useProjects } from "../../../../state/projects.js";
-import { useSpaces } from "../../../../state/spaces.js";
import { debounce } from "../../../../utils/async.js";
+import { parseEmails } from "../../../../utils/users.js";
const roleList = [
{ id: "admin", value: PROJECT_ROLE.ADMIN },
@@ -60,34 +54,26 @@ const roleList = [
export default {
props: {
- space: {
- type: Object,
- default: null,
+ roleSelector: {
+ type: Boolean,
+ default: false,
},
- project: {
- type: Object,
- default: null,
- },
- users: {
- type: Array,
- default: () => [],
- },
- currentTab: {
+ error: {
type: String,
- default: "admins",
- },
+ default: ""
+ }
},
- emits: ["close", "success"],
+ emits: ["cancel", "submit"],
setup(props, { emit }) {
const { locale, t } = useI18n();
- const { pushNotification } = useAppNotification();
- const { sendSpaceInvitation, updateSpaceUser, spaceUsers } = useSpaces();
- const { sendProjectInvitation } = useProjects();
+
+ const emailInput = ref(null);
+ const email = ref("");
const roleOptions = ref([]);
const role = ref(null);
watch(
- [() => props.space, () => props.project, () => locale.value],
+ locale,
() => {
let availableRoles = roleList;
@@ -101,76 +87,38 @@ export default {
{ immediate: true }
);
- const emailInput = ref(null);
- const email = ref("");
- const hasError = ref(false);
- const userAlreadyExist = ref(false);
+ const errorMessage = ref("");
+ watch(
+ () => props.error,
+ msg => {
+ errorMessage.value = msg;
+ },
+ { immediate: true }
+ );
const reset = () => {
email.value = "";
- hasError.value = false;
+ errorMessage.value = "";
};
const submit = debounce(async () => {
- let currentUser;
- if (email.value) {
- if (props.users.map((user) => user.email).includes(email.value)) {
- emailInput.value.focus();
- hasError.value = true;
- userAlreadyExist.value = true;
- } else {
- userAlreadyExist.value = false;
- if (props.project) {
- await sendProjectInvitation(props.project, {
- email: email.value,
- role: role.value.value,
- });
- } else if (props.space) {
- currentUser = spaceUsers.value.find((user) => user.email === email.value);
- if (currentUser) {
- await updateSpaceUser(props.space, {
- ...currentUser,
- cloud_role: 100,
- });
- } else {
- if (props.currentTab === "users") {
- await sendSpaceInvitation(props.space, {
- email: email.value,
- in_all_projects: true,
- project_role: 50,
- role: 50,
- });
- } else {
- await sendSpaceInvitation(props.space, {
- email: email.value,
- });
- }
- }
- }
- pushNotification(
- {
- type: "success",
- title: t("t.success"),
- message: t(
- currentUser
- ? "InvitationForm.successUsertoAdmin"
- : "InvitationForm.successNotifText"
- ),
- },
- 2500
- );
- reset();
- emit("success");
- }
- } else {
+ errorMessage.value = "";
+
+ if (!email.value) {
emailInput.value.focus();
- hasError.value = true;
+ errorMessage.value = t("InvitationForm.emailInputErrorMessage");
+ return;
}
+
+ const emails = parseEmails(email.value);
+
+ emit("submit", { emails, role: role.value.value });
+ reset();
}, 500);
- const close = () => {
+ const cancel = () => {
+ emit("cancel");
reset();
- emit("close");
};
onMounted(() => {
@@ -181,12 +129,11 @@ export default {
// References
email,
emailInput,
- hasError,
- userAlreadyExist,
+ errorMessage,
role,
roleOptions,
// Methods
- close,
+ cancel,
submit,
};
},
diff --git a/src/components/specific/users/invitation-form/ProjectInvitationForm.vue b/src/components/specific/users/invitation-form/ProjectInvitationForm.vue
new file mode 100644
index 000000000..7b743399c
--- /dev/null
+++ b/src/components/specific/users/invitation-form/ProjectInvitationForm.vue
@@ -0,0 +1,58 @@
+
+
+
+
+
diff --git a/src/components/specific/users/invitation-form/SpaceInvitationForm.vue b/src/components/specific/users/invitation-form/SpaceInvitationForm.vue
new file mode 100644
index 000000000..f28f8f958
--- /dev/null
+++ b/src/components/specific/users/invitation-form/SpaceInvitationForm.vue
@@ -0,0 +1,70 @@
+
+
+
+
+
diff --git a/src/components/specific/users/project-users-manager/ProjectUsersManager.vue b/src/components/specific/users/project-users-manager/ProjectUsersManager.vue
index d90884de7..19aa5805b 100644
--- a/src/components/specific/users/project-users-manager/ProjectUsersManager.vue
+++ b/src/components/specific/users/project-users-manager/ProjectUsersManager.vue
@@ -33,7 +33,7 @@
clear
/>
-
-
-
@@ -60,7 +61,7 @@ import { useSpaces } from "../../../../state/spaces.js";
import { wait } from "../../../../utils/async.js";
// Components
import InvitationCard from "../invitation-card/InvitationCard.vue";
-import InvitationForm from "../invitation-form/InvitationForm.vue";
+import SpaceInvitationForm from "../invitation-form/SpaceInvitationForm.vue";
import UserCard from "../user-card/UserCard.vue";
const tabsDef = [{ id: "admins" }, { id: "users" }];
@@ -68,7 +69,7 @@ const tabsDef = [{ id: "admins" }, { id: "users" }];
export default {
components: {
InvitationCard,
- InvitationForm,
+ SpaceInvitationForm,
UserCard,
},
props: {
@@ -116,9 +117,7 @@ export default {
const list = computed(() => {
if (currentTab.value === "admins") {
- return props.invitations
- .filter((invitation) => invitation.role === 100)
- .concat(admins.value);
+ return props.invitations.filter((invitation) => invitation.role === 100).concat(admins.value);
} else {
return props.invitations.filter((invitation) => invitation.role === 50).concat(users.value);
}
diff --git a/src/i18n/lang/de.json b/src/i18n/lang/de.json
index 617a3d07e..18fc239e7 100644
--- a/src/i18n/lang/de.json
+++ b/src/i18n/lang/de.json
@@ -217,7 +217,7 @@
},
"submitButtonText": "Einladen",
"successNotifText": "Einladung versendet",
- "successUsertoAdmin": "Der Nutzer wurde zum Administrator befördert.",
+ "successUserToAdmin": "Der Nutzer wurde zum Administrator befördert.",
"userAlreadyExistInputErrorMessage": "Der Nutzer ist bereits in Ihren Projekt."
},
"ModelActionsCell": {
diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json
index 80030c740..04fe808a9 100644
--- a/src/i18n/lang/en.json
+++ b/src/i18n/lang/en.json
@@ -217,7 +217,7 @@
},
"submitButtonText": "Send invitation",
"successNotifText": "Invitation sent",
- "successUsertoAdmin": "The user has now admin role",
+ "successUserToAdmin": "The user has now admin role",
"userAlreadyExistInputErrorMessage": "User is already in the project"
},
"ModelActionsCell": {
diff --git a/src/i18n/lang/es.json b/src/i18n/lang/es.json
index 6aaec67db..01fb515f9 100644
--- a/src/i18n/lang/es.json
+++ b/src/i18n/lang/es.json
@@ -217,7 +217,7 @@
},
"submitButtonText": "Invitar",
"successNotifText": "Invitación enviada",
- "successUsertoAdmin": "El usuario ha sido ascendido a administrador",
+ "successUserToAdmin": "El usuario ha sido ascendido a administrador",
"userAlreadyExistInputErrorMessage": "El usuario ya está en su proyecto"
},
"ModelActionsCell": {
diff --git a/src/i18n/lang/fr.json b/src/i18n/lang/fr.json
index b3128d827..c5feb8bdf 100644
--- a/src/i18n/lang/fr.json
+++ b/src/i18n/lang/fr.json
@@ -318,7 +318,7 @@
},
"submitButtonText": "Inviter",
"successNotifText": "Invitation envoyée",
- "successUsertoAdmin": "L'utilisateur a été promu administrateur"
+ "successUserToAdmin": "L'utilisateur a été promu administrateur"
},
"ModelActionsCell": {
"addTagsButtonText": "Ajouter des tags"
diff --git a/src/i18n/lang/it.json b/src/i18n/lang/it.json
index 75f8dd244..6663e729d 100644
--- a/src/i18n/lang/it.json
+++ b/src/i18n/lang/it.json
@@ -139,7 +139,7 @@
},
"submitButtonText": "Invia invito",
"successNotifText": "Invito spedito",
- "successUsertoAdmin": "L'utente è stato promosso ad amministratore"
+ "successUserToAdmin": "L'utente è stato promosso ad amministratore"
},
"ModelActionsCell": {
"addTagsButtonText": "Aggiungi tag"
@@ -855,4 +855,4 @@
"FileTreePreviewModal": {
"title": "Importa la struttura del file da"
}
-}
+}
\ No newline at end of file
diff --git a/src/i18n/lang/nl.json b/src/i18n/lang/nl.json
index 51e86322c..2b839d2b7 100644
--- a/src/i18n/lang/nl.json
+++ b/src/i18n/lang/nl.json
@@ -135,8 +135,7 @@
"guest": "Gast"
},
"submitButtonText": "Uitnodiging versturen",
- "successNotifText": "Uitnodiging verzonden",
- "successUsertoAdmin": ""
+ "successNotifText": "Uitnodiging verzonden"
},
"ModelActionsCell": {
"addTagsButtonText": "Labels toevoegen"
@@ -852,4 +851,4 @@
"FileTreePreviewModal": {
"title": ""
}
-}
+}
\ No newline at end of file
diff --git a/src/i18n/lang/no.json b/src/i18n/lang/no.json
index d7e4b21d8..da63aa636 100644
--- a/src/i18n/lang/no.json
+++ b/src/i18n/lang/no.json
@@ -135,8 +135,7 @@
"guest": "Gjest"
},
"submitButtonText": "Send invitasjon",
- "successNotifText": "Invitasjon sendt",
- "successUsertoAdmin": ""
+ "successNotifText": "Invitasjon sendt"
},
"ModelActionsCell": {
"addTagsButtonText": "Legg til tags"
@@ -852,4 +851,4 @@
"FileTreePreviewModal": {
"title": ""
}
-}
+}
\ No newline at end of file
diff --git a/src/utils/users.js b/src/utils/users.js
index ed1295a55..ad89b7245 100644
--- a/src/utils/users.js
+++ b/src/utils/users.js
@@ -1,3 +1,7 @@
+function parseEmails(str) {
+ return str.replace(";", ",").split(",").map(email => email.trim());
+}
+
function fullName({ firstname, lastname }) {
return firstname || lastname ? `${firstname} ${lastname}` : "";
}
@@ -6,4 +10,4 @@ function sortUsers(users) {
return users.sort((a, b) => fullName(a) < fullName(b) ? -1 : 1);
}
-export { fullName, sortUsers };
+export { parseEmails, fullName, sortUsers };