From 0b81053f240367e4b0d7b69981a5d9ef2359098f Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 1 Oct 2020 12:50:42 +0300 Subject: [PATCH] Update action in dropdown, add confirmation when deleting a user --- .../components/ModerateUserDropdown.vue | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/views/reports/components/ModerateUserDropdown.vue b/src/views/reports/components/ModerateUserDropdown.vue index 9be3446e..e2c750a6 100644 --- a/src/views/reports/components/ModerateUserDropdown.vue +++ b/src/views/reports/components/ModerateUserDropdown.vue @@ -72,11 +72,26 @@ export default { } }, methods: { - handleDeactivation({ nickname }) { - this.$store.dispatch('ToggleUserActivation', nickname) + handleDeactivation(user) { + user.deactivated + ? this.$store.dispatch('ActivateUsers', { users: [user], _userId: user.id }) + : this.$store.dispatch('DeactivateUsers', { users: [user], _userId: user.id }) }, handleDeletion(user) { - this.$store.dispatch('DeleteUser', user) + this.$confirm( + this.$t('users.deleteUserConfirmation'), + { + confirmButtonText: 'Delete', + cancelButtonText: 'Cancel', + type: 'warning' + }).then(() => { + this.$store.dispatch('DeleteUsers', { users: [user], _userId: user.id }) + }).catch(() => { + this.$message({ + type: 'info', + message: 'Delete canceled' + }) + }) }, showDeactivatedButton(id) { return this.$store.state.user.id !== id