diff --git a/next-ui/src/colada/mutations/update-user.ts b/next-ui/src/colada/mutations/update-user.ts index 389a39c7..e8662a8b 100644 --- a/next-ui/src/colada/mutations/update-user.ts +++ b/next-ui/src/colada/mutations/update-user.ts @@ -33,3 +33,19 @@ export const useUpdateUserPassword = defineMutation(() => { }, }) }) + +export const useDeleteUser = defineMutation(() => { + const queryCache = useQueryCache() + return useMutation({ + mutation: (userId: string) => + komgaClient.DELETE('/api/v2/users/{id}', { + params: {path: {id: userId}}, + }), + onSuccess: () => { + void queryCache.invalidateQueries({key: ['users']}) + }, + onError: (error) => { + console.log('delete user error', error) + }, + }) +}) diff --git a/next-ui/src/components.d.ts b/next-ui/src/components.d.ts index c2903223..8c2850ef 100644 --- a/next-ui/src/components.d.ts +++ b/next-ui/src/components.d.ts @@ -21,6 +21,7 @@ declare module 'vue' { AppFooter: typeof import('./components/AppFooter.vue')['default'] BuildCommit: typeof import('./components/BuildCommit.vue')['default'] BuildVersion: typeof import('./components/BuildVersion.vue')['default'] + DialogConfirm: typeof import('./components/dialogs/DialogConfirm.vue')['default'] DialogConfirmEdit: typeof import('./components/dialogs/DialogConfirmEdit.vue')['default'] FormUserChangePassword: typeof import('./components/forms/user/FormUserChangePassword.vue')['default'] FormUserRoles: typeof import('./components/forms/user/FormUserRoles.vue')['default'] diff --git a/next-ui/src/components/dialogs/DialogConfirm.vue b/next-ui/src/components/dialogs/DialogConfirm.vue new file mode 100644 index 00000000..ea82c21b --- /dev/null +++ b/next-ui/src/components/dialogs/DialogConfirm.vue @@ -0,0 +1,89 @@ + + + + + + + + Please type {{ validateText }} to confirm. + + + + + + + + + + + + + + + + + diff --git a/next-ui/src/components/dialogs/DialogConfirmEdit.vue b/next-ui/src/components/dialogs/DialogConfirmEdit.vue index 7b050456..d3b57d10 100644 --- a/next-ui/src/components/dialogs/DialogConfirmEdit.vue +++ b/next-ui/src/components/dialogs/DialogConfirmEdit.vue @@ -47,6 +47,7 @@ - diff --git a/next-ui/src/pages/server/users.vue b/next-ui/src/pages/server/users.vue index f4e1dbbf..0e9fb7fa 100644 --- a/next-ui/src/pages/server/users.vue +++ b/next-ui/src/pages/server/users.vue @@ -54,7 +54,7 @@ icon="mdi-delete" :disabled="me?.id == user.id" @click="showDialog(ACTION.DELETE, user)" - @mouseenter="activator = $event.currentTarget" + @mouseenter="activatorDelete = $event.currentTarget" /> @@ -75,6 +75,33 @@ /> + + + + + The user account will be deleted from this server. + + The read progress for this user account will be permanently deleted. + Authentication activity for this user will be permanently deleted. + + + This action cannot be undone. + + + + @@ -84,7 +111,7 @@ import {komgaClient} from '@/api/komga-client.ts' import type {components} from '@/generated/openapi/komga' import {useCurrentUser} from '@/colada/queries/current-user.ts' import {UserRoles} from '@/types/UserRoles.ts' -import {useUpdateUser, useUpdateUserPassword} from '@/colada/mutations/update-user.ts' +import {useDeleteUser, useUpdateUser, useUpdateUserPassword} from '@/colada/mutations/update-user.ts' import FormUserChangePassword from '@/components/forms/user/FormUserChangePassword.vue' import FormUserRoles from '@/components/forms/user/FormUserRoles.vue' import type {Component} from 'vue' @@ -140,12 +167,14 @@ const currentAction = ref() // the record passed to the dialog's form's model const dialogRecord = ref() const activator = ref() +const activatorDelete = ref() const dialogTitle = ref() // dynamic component for the dialog's inner form const dialogComponent = shallowRef() const {mutate: mutateUser} = useUpdateUser() const {mutate: mutateUserPassword} = useUpdateUserPassword() +const {mutate: mutateDeleteUser} = useDeleteUser() enum ACTION { EDIT, DELETE, RESTRICTIONS, PASSWORD @@ -184,6 +213,7 @@ function handleDialogConfirmation() { mutateUser(dialogRecord.value as components["schemas"]["UserDto"]) break; case ACTION.DELETE: + mutateDeleteUser(userRecord.value!.id) break; case ACTION.RESTRICTIONS: break;