From 1896c009466951e55ea5f10b40e3f2544663f593 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 27 Jan 2020 19:41:16 +0300 Subject: [PATCH] Add ability to moderate user from a user's page --- src/lang/en.js | 1 + src/store/modules/users.js | 14 ++++++++ .../users/components/ModerationDropdown.vue | 23 ++++++++++--- src/views/users/index.vue | 2 +- src/views/users/show.vue | 33 ++++++++++++++----- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 1a8a8c90..fa4d3209 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -202,6 +202,7 @@ export default { disableAnySubscriptionForMultiple: 'Disallow following users at all', requirePasswordReset: 'Require password reset on next login', selectUsers: 'Select users to apply actions to multiple users', + moderateUser: 'Moderate user', moderateUsers: 'Moderate multiple users', createAccount: 'Create new account', apply: 'apply', diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 1f10b6c4..247b2804 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -93,6 +93,8 @@ const users = { } finally { dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) } + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async AddRight({ commit, dispatch, getters, state }, { users, right }) { @@ -109,6 +111,8 @@ const users = { } finally { dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) } + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async AddTag({ commit, dispatch, getters, state }, { users, tag }) { @@ -125,6 +129,8 @@ const users = { } finally { dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) } + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async ClearFilters({ commit, dispatch, state }) { @@ -155,6 +161,8 @@ const users = { } finally { dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) } + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async ConfirmUsersEmail({ commit, dispatch, getters, state }, users) { @@ -196,6 +204,8 @@ const users = { } finally { dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) } + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async DeleteUsers({ commit, dispatch, getters, state }, users) { @@ -208,6 +218,8 @@ const users = { const deletedUsersIds = users.map(deletedUser => deletedUser.id) const updatedUsers = state.fetchedUsers.filter(user => !deletedUsersIds.includes(user.id)) commit('SET_USERS', updatedUsers) + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async FetchUsers({ commit, dispatch, getters, state }, { page }) { @@ -238,6 +250,8 @@ const users = { } finally { dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) } + + dispatch('FetchUserProfile', { userId: users[0].id, godmode: false }) dispatch('SuccessMessage') }, async RequirePasswordReset({ dispatch, getters }, user) { diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue index 1a06559f..85b1fd72 100644 --- a/src/views/users/components/ModerationDropdown.vue +++ b/src/views/users/components/ModerationDropdown.vue @@ -1,9 +1,20 @@