From 77a153deac0c840ee25b0e12c046b546b90a91bf Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 11 Oct 2019 03:28:55 +0300 Subject: [PATCH] Update api for ActivateUsers and DeactivateUsers actions --- src/api/users.js | 29 +++++++++++++------ src/store/modules/users.js | 15 ++++++---- src/views/reports/components/TimelineItem.vue | 14 +++++---- src/views/users/index.vue | 8 +++-- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/api/users.js b/src/api/users.js index 9351cc45..12e13e6f 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -2,6 +2,16 @@ import request from '@/utils/request' import { getToken } from '@/utils/auth' import { baseName } from './utils' +export async function activateUsers(nicknames, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/activate`, + method: 'patch', + headers: authHeaders(token), + data: { nicknames } + }) +} + export async function addRight(nicknames, right, authHost, token) { return await request({ baseURL: baseName(authHost), @@ -22,6 +32,16 @@ export async function createNewAccount(nickname, email, password, authHost, toke }) } +export async function deactivateUsers(nicknames, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/deactivate`, + method: 'patch', + headers: authHeaders(token), + data: { nicknames } + }) +} + export async function deleteRight(nicknames, right, authHost, token) { return await request({ baseURL: baseName(authHost), @@ -96,15 +116,6 @@ export async function tagUser(nicknames, tags, authHost, token) { }) } -export async function toggleUserActivation(nickname, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/${nickname}/toggle_activation`, - method: 'patch', - headers: authHeaders(token) - }) -} - export async function untagUser(nicknames, tags, authHost, token) { return await request({ baseURL: baseName(authHost), diff --git a/src/store/modules/users.js b/src/store/modules/users.js index f087d930..f35ad9aa 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -1,13 +1,14 @@ import { + activateUsers, addRight, createNewAccount, + deactivateUsers, deleteRight, deleteUser, fetchUsers, getPasswordResetToken, searchUsers, tagUser, - toggleUserActivation, untagUser, requirePasswordReset } from '@/api/users' @@ -76,6 +77,10 @@ const users = { } }, actions: { + async ActivateUsers({ commit, getters }, nicknames) { + const { data } = await activateUsers(nicknames, getters.authHost, getters.token) + commit('SWAP_USERS', data) + }, async AddRight({ dispatch, getters, state }, { users, right }) { const usersNicknames = users.map(user => user.nickname) await addRight(usersNicknames, right, getters.authHost, getters.token) @@ -98,6 +103,10 @@ const users = { await createNewAccount(nickname, email, password, getters.authHost, getters.token) dispatch('FetchUsers', { page: state.currentPage }) }, + async DeactivateUsers({ commit, getters }, nicknames) { + const { data } = await deactivateUsers(nicknames, getters.authHost, getters.token) + commit('SWAP_USERS', data) + }, async DeleteRight({ dispatch, getters, state }, { users, right }) { const usersNicknames = users.map(user => user.nickname) await deleteRight(usersNicknames, right, getters.authHost, getters.token) @@ -148,10 +157,6 @@ const users = { loadUsers(commit, page, response.data) } }, - async ToggleUserActivation({ commit, getters }, nickname) { - const { data } = await toggleUserActivation(nickname, getters.authHost, getters.token) - commit('SWAP_USER', data) - }, async ToggleUsersFilter({ commit, dispatch, state }, filters) { const defaultFilters = { local: false, diff --git a/src/views/reports/components/TimelineItem.vue b/src/views/reports/components/TimelineItem.vue index 771298aa..96433a22 100644 --- a/src/views/reports/components/TimelineItem.vue +++ b/src/views/reports/components/TimelineItem.vue @@ -21,7 +21,7 @@ + @click.native="toggleActivation(report.account)"> {{ report.account.deactivated ? $t('users.activateAccount') : $t('users.deactivateAccount') }} + @click.native="toggleActivation(scope.row)"> {{ scope.row.deactivated ? $t('users.activateAccount') : $t('users.deactivateAccount') }}