From bd7b973559ccc0a373a9bb83407117631723fd47 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 1 Sep 2023 13:18:00 +0200 Subject: [PATCH] feat(api tokens): add deleting api tokens --- src/i18n/lang/en.json | 5 ++++ src/views/user/settings/ApiTokens.vue | 34 ++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index e94eff8f5..d67014b2a 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -151,6 +151,11 @@ "90d": "90 Days", "permissionExplanation": "Permissions allow you to scope what an api token is allowed to do.", "titleRequired": "The title is required", + "delete": { + "header": "Delete this token", + "text1": "Are you sure you want to delete the token \"{token}\"?", + "text2": "This will revoke access to all applications or integrations using it. You cannot undo this." + }, "attributes": { "title": "Title", "titlePlaceholder": "Enter a title you will recognize later", diff --git a/src/views/user/settings/ApiTokens.vue b/src/views/user/settings/ApiTokens.vue index 237341738..98ebb9cc3 100644 --- a/src/views/user/settings/ApiTokens.vue +++ b/src/views/user/settings/ApiTokens.vue @@ -24,6 +24,9 @@ const newTokenPermissions = ref({}) const newTokenTitleValid = ref(true) const apiTokenTitle = ref() +const showDeleteModal = ref(false) +const tokenToDelete = ref(null) + const {t} = useI18n() const authStore = useAuthStore() @@ -57,7 +60,15 @@ function resetPermissions() { }) } -function deleteToken() { +async function deleteToken() { + await service.delete(tokenToDelete.value) + showDeleteModal.value = false + tokenToDelete.value = null + const index = tokens.value.findIndex(el => el.id === tokenToDelete.value.id) + if (index === -1) { + return + } + tokens.value.splice(index, 1) } async function createToken() { @@ -117,7 +128,7 @@ async function createToken() { {{ tk.id }} {{ tk.title }} -