diff --git a/src/api/users.js b/src/api/users.js
index 167c3303..b9740cff 100644
--- a/src/api/users.js
+++ b/src/api/users.js
@@ -7,4 +7,11 @@ export async function fetchUsers() {
})
}
-export default { fetchUsers }
+export async function toggleUserActivation(nickname) {
+ return await request({
+ url: `/api/pleroma/admin/users/${nickname}/toggle_activation`,
+ method: 'patch'
+ })
+}
+
+export default { fetchUsers, toggleUserActivation }
diff --git a/src/store/modules/users.js b/src/store/modules/users.js
index e96dbe09..f77db0fa 100644
--- a/src/store/modules/users.js
+++ b/src/store/modules/users.js
@@ -1,4 +1,4 @@
-import { fetchUsers } from '@/api/users'
+import { fetchUsers, toggleUserActivation } from '@/api/users'
const user = {
state: {
@@ -7,10 +7,17 @@ const user = {
},
mutations: {
SET_USERS: (state, users) => {
- state.fetchedUsers = users
+ state.fetchedUsers = users.sort((a, b) => a.id.localeCompare(b.id))
},
SET_LOADING: (state, status) => {
state.loading = status
+ },
+ SWAP_USER: (state, user) => {
+ const usersWithoutSwapped = state.fetchedUsers.filter((u) => {
+ return u.id !== user.id
+ })
+
+ state.fetchedUsers = [...usersWithoutSwapped, user].sort((a, b) => a.id.localeCompare(b.id))
}
},
actions: {
@@ -19,6 +26,11 @@ const user = {
commit('SET_USERS', response.data)
commit('SET_LOADING', false)
+ },
+ async ToggleUserActivation({ commit }, nickname) {
+ const response = await toggleUserActivation(nickname)
+
+ commit('SWAP_USER', response.data)
}
}
}
diff --git a/src/views/users/index.vue b/src/views/users/index.vue
index 86b27a7f..69f16127 100644
--- a/src/views/users/index.vue
+++ b/src/views/users/index.vue
@@ -10,14 +10,22 @@
label="ID"
width="100" />
+
+
+
+ {{ scope.row.deactivated ? 'deactivated' : 'active' }}
+
+
+
-
- Disable user
+ label="Actions">
+
+ Activate
+ Deactivate
@@ -40,8 +48,8 @@ export default {
this.$store.dispatch('FetchUsers')
},
methods: {
- handleRevoke() {
-
+ handleDeactivate({ nickname }) {
+ this.$store.dispatch('ToggleUserActivation', nickname)
}
}
}