diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 3263b06c3..a4712a277 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -857,6 +857,12 @@ "text1": "Are you sure you want to remove this user from the team?", "text2": "They will lose access to all lists and namespaces this team has access to. This CANNOT BE UNDONE!", "success": "The user was successfully deleted from the team." + }, + "leave": { + "title": "Leave team", + "text1": "Are you sure you want to leave this team?", + "text2": "You will loose access to all lists and namespaces this team has access to. If you change your mind you'll need a team admin to add you again.", + "success": "You have successfully left the team." } }, "attributes": { diff --git a/src/views/teams/EditTeam.vue b/src/views/teams/EditTeam.vue index 60ec6b851..8c6fbab1c 100644 --- a/src/views/teams/EditTeam.vue +++ b/src/views/teams/EditTeam.vue @@ -127,6 +127,24 @@ + + {{ $t('team.edit.leave.title') }} + + + + + + + + + (new TeamMemberService()) const userService = ref(new UserService()) const team = ref() -const teamId = computed(() => route.params.id) +const teamId = computed(() => Number(route.params.id)) const memberToDelete = ref() const newMember = ref() const foundUsers = ref() const showDeleteModal = ref(false) const showUserDeleteModal = ref(false) +const showLeaveModal = ref(false) const showError = ref(false) const title = ref('') @@ -287,6 +306,19 @@ async function findUser(query: string) { const users = await userService.value.getAll({}, {s: query}) foundUsers.value = users.filter((u: IUser) => u.id !== userInfo.value.id) } + +async function leave() { + try { + await teamMemberService.value.delete({ + teamId: teamId.value, + username: userInfo.value.username, + }) + success({message: t('team.edit.leave.success')}) + await router.push({name: 'home'}) + } finally { + showUserDeleteModal.value = false + } +}