From 0c48f3cc9d3f863f6e076d332ebb467e0b82ff24 Mon Sep 17 00:00:00 2001 From: Massedil Date: Thu, 20 Nov 2025 17:23:15 +0100 Subject: [PATCH] add a confirm dialog when deleting a group invitation link --- src/i18n/en_US.json | 2 + src/i18n/fr_FR.json | 2 + src/views/Group/GroupInvitations.vue | 64 +++++++++++++++++----------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index e74487676..0fc4240a1 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -345,6 +345,7 @@ "Delete group resources": "Delete group resources", "Delete group": "Delete group", "Delete invitation":"Delete invitation", + "Delete invitation?":"Delete invitation?", "Delete my account": "Delete my account", "Delete post": "Delete post", "Delete profiles": "Delete profiles", @@ -377,6 +378,7 @@ "Do not receive any mail": "Do not receive any mail", "Do you really want to ban the account \u00ab\u00a0{emailAccount}\u00a0\u00bb\u00a0?": "Do you really want to ban the account \u00ab\u00a0{emailAccount}\u00a0\u00bb\u00a0?", "Do you really want to ban this account? All of the user's profiles will be deleted.": "Do you really want to ban this account? All of the user's profiles will be deleted.", + "Do you really want to delete this invitation link to this group?":"Do you really want to delete this invitation link to this group?", "Do you really want to suspend this profile? All of the profiles content will be deleted.": "Do you really want to suspend this profile? All of the profiles content will be deleted.", "Do you really want to unban this account? The user will be able to log-in again.":"Do you really want to unban this account? The user will be able to log-in again.", "Do you want to join the group {groupName} with the profile {preferredUsername} ?": "Do you want to join the group {groupName} with the profile {preferredUsername} ?", diff --git a/src/i18n/fr_FR.json b/src/i18n/fr_FR.json index 2f0e4c81a..e26afe262 100644 --- a/src/i18n/fr_FR.json +++ b/src/i18n/fr_FR.json @@ -345,6 +345,7 @@ "Delete group resources": "Supprimer des ressources de groupes", "Delete group": "Supprimer le groupe", "Delete invitation":"Supprimer l'invitation", + "Delete invitation?":"Supprimer l'invitation ?", "Delete my account": "Supprimer mon compte", "Delete post": "Supprimer le billet", "Delete profiles": "Supprimer des profils", @@ -377,6 +378,7 @@ "Do not receive any mail": "Ne pas recevoir d'e-mail", "Do you really want to ban the account \u00ab\u00a0{emailAccount}\u00a0\u00bb\u00a0?": "Voulez-vous vraiment bannir le compte \u00ab\u00a0{emailAccount}\u00a0\u00bb\u00a0?", "Do you really want to ban this account? All of the user's profiles will be deleted.": "Voulez-vous vraiment bannir ce compte\u00a0? Tous les profils de cet\u00b7te utilisateur\u00b7ice seront supprim\u00e9s.", + "Do you really want to delete this invitation link to this group?":"Voulez-vous vraiment supprimer ce lien d'invitation pour ce groupe ?", "Do you really want to suspend this profile? All of the profiles content will be deleted.": "Voulez-vous vraiment suspendre ce profil\u00a0? Tout le contenu du profil sera supprim\u00e9.", "Do you really want to unban this account? The user will be able to log-in again.": "Voulez-vous vraiment d\u00e9bannir ce compte\u00a0? L'utilisateur pourra \u00e0 nouveau se connecter.", "Do you want to join the group {groupName} with the profile {preferredUsername} ?": "Voulez-vous rejoindre le groupe {groupName} avec le profil {preferredUsername} ?", diff --git a/src/views/Group/GroupInvitations.vue b/src/views/Group/GroupInvitations.vue index 81f3de0c8..9700fbc5b 100644 --- a/src/views/Group/GroupInvitations.vue +++ b/src/views/Group/GroupInvitations.vue @@ -99,10 +99,7 @@ icon-left="share" @click=" triggerShare( - invitationUrl( - group, - groupInvitationsResult.listInvitations[0].token - ) + invitationUrl(groupInvitationsResult.listInvitations[0].token) ) " variant="primary" @@ -151,7 +148,7 @@ {{ t("Share link") }} @@ -219,13 +216,14 @@ import { usernameWithDomain, displayName, IGroup } from "@/types/actor"; import { useHead } from "@/utils/head"; import { useI18n } from "vue-i18n"; import { useMutation, useQuery } from "@vue/apollo-composable"; -import { computed, ref, watch } from "vue"; +import { computed, inject, ref, watch } from "vue"; import { useGroup } from "@/composition/apollo/group"; import { IInvitation } from "@/types/actor/invitation.model"; import { useCurrentActorClient } from "@/composition/apollo/actor"; import ShareModal from "@/components/Share/ShareModal.vue"; import { IMember } from "@/types/actor/member.model"; import { GROUP_MEMBERS, INVITE_MEMBER } from "@/graphql/member"; +import { Dialog } from "@/plugins/dialog"; const { t } = useI18n({ useScope: "global" }); @@ -242,6 +240,19 @@ const { error: groupError, } = useGroup(preferredUsername); +function invitationUrl(token: string) { + return ( + window.location.origin + + router.resolve({ + name: RouteName.GROUP_INVITATION_ACCEPT, + params: { + preferredUsername: group.value?.preferredUsername, + token, + }, + }).href + ); +} + // ------------------------------------------------------------- // Member invitation // ------------------------------------------------------------- @@ -315,7 +326,7 @@ const { } = useMutation(GROUP_INVITATIONS_CREATE); onCreateGroupInvitationDone(() => { - // TODO : pas de refetch, mise à jour du cache + // TODO: No refetch, but update the cache groupInvitationsRefetch(); }); @@ -338,7 +349,7 @@ const { } = useMutation(GROUP_INVITATIONS_UPDATE); onUpdateGroupInvitationDone(() => { - // TODO : pas de refetch, mise à jour du cache + // TODO: No refetch, but update the cache groupInvitationsRefetch(); updateInvitationToken.value = ""; updateInvitationLabel.value = ""; @@ -377,7 +388,7 @@ const { } = useMutation(GROUP_INVITATIONS_DELETE); deleteGroupInvitationDone(() => { - // TODO : pas de refetch, mise à jour du cache + // TODO: No refetch, but update the cache groupInvitationsRefetch(); }); @@ -385,10 +396,24 @@ deleteGroupInvitationError((error) => { alert(error.message); }); -const actionDeleteGroupInvitation = (token: string) => { - deleteGroupInvitation({ - groupId: group.value?.id, - token: token, +const dialog = inject("dialog"); + +const actionDeleteGroupInvitation = async (token: string): Promise => { + dialog?.confirm({ + title: t("Delete invitation?"), + message: + t("Do you really want to delete this invitation link to this group?") + + "
" + + invitationUrl(token), + confirmText: t("Delete invitation"), + cancelText: t("Cancel"), + variant: "danger", + onConfirm: async () => { + deleteGroupInvitation({ + groupId: group.value?.id, + token: token, + }); + }, }); }; @@ -398,19 +423,6 @@ const actionDeleteGroupInvitation = (token: string) => { const router = useRouter(); -function invitationUrl(group: IGroup, token: string) { - return ( - window.location.origin + - router.resolve({ - name: RouteName.GROUP_INVITATION_ACCEPT, - params: { - preferredUsername: group.preferredUsername, - token, - }, - }).href - ); -} - const isShareModalActive = ref(false); const selectedURL = ref("");