From 23054af57d88c5486e5a314d6084de7a84455019 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 27 Jan 2020 15:05:51 +0300 Subject: [PATCH 1/7] Extract moderation menu into a separate component --- .../users/components/ModerationDropdown.vue | 155 ++++++++++++++++++ src/views/users/index.vue | 139 +--------------- 2 files changed, 160 insertions(+), 134 deletions(-) create mode 100644 src/views/users/components/ModerationDropdown.vue diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue new file mode 100644 index 00000000..1a06559f --- /dev/null +++ b/src/views/users/components/ModerationDropdown.vue @@ -0,0 +1,155 @@ + + + diff --git a/src/views/users/index.vue b/src/views/users/index.vue index 4cb24199..1ac63789 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -66,96 +66,7 @@ @@ -191,13 +102,15 @@ import numeral from 'numeral' import UsersFilter from './components/UsersFilter' import MultipleUsersMenu from './components/MultipleUsersMenu' import NewAccountDialog from './components/NewAccountDialog' +import ModerationDropdown from './components/ModerationDropdown' export default { name: 'Users', components: { - UsersFilter, + NewAccountDialog, + ModerationDropdown, MultipleUsersMenu, - NewAccountDialog + UsersFilter }, data() { return { @@ -264,29 +177,6 @@ export default { getFirstLetter(str) { return str.charAt(0).toUpperCase() }, - getPasswordResetToken(nickname) { - this.resetPasswordDialogOpen = true - this.$store.dispatch('GetPasswordResetToken', nickname) - }, - requirePasswordReset(nickname) { - const mailerEnabled = this.$store.state.user.nodeInfo.metadata.mailerEnabled - - if (!mailerEnabled) { - this.$alert(this.$t('users.mailerMustBeEnabled'), 'Error', { type: 'error' }) - - return - } - - this.$store.dispatch('RequirePasswordReset', { nickname }) - }, - toggleActivation(user) { - user.deactivated - ? this.$store.dispatch('ActivateUsers', [user]) - : this.$store.dispatch('DeactivateUsers', [user]) - }, - handleDeletion(user) { - this.$store.dispatch('DeleteUsers', [user]) - }, handlePageChange(page) { const searchQuery = this.$store.state.users.searchQuery if (searchQuery === '') { @@ -302,27 +192,8 @@ export default { this.resetPasswordDialogOpen = false this.$store.dispatch('RemovePasswordToken') }, - showAdminAction({ local, id }) { - return local && this.showDeactivatedButton(id) - }, showDeactivatedButton(id) { return this.$store.state.user.id !== id - }, - toggleTag(user, tag) { - user.tags.includes(tag) - ? this.$store.dispatch('RemoveTag', { users: [user], tag }) - : this.$store.dispatch('AddTag', { users: [user], tag }) - }, - toggleUserRight(user, right) { - user.roles[right] - ? this.$store.dispatch('DeleteRight', { users: [user], right }) - : this.$store.dispatch('AddRight', { users: [user], right }) - }, - handleEmailConfirmation(user) { - this.$store.dispatch('ConfirmUsersEmail', [user]) - }, - handleConfirmationResend(user) { - this.$store.dispatch('ResendConfirmationEmail', [user]) } } } From 1896c009466951e55ea5f10b40e3f2544663f593 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 27 Jan 2020 19:41:16 +0300 Subject: [PATCH 2/7] 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 @@