diff --git a/src/lang/en.js b/src/lang/en.js index d86a3a1e..2008aec8 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -229,13 +229,14 @@ export default { revokeRightConfirmation: 'Are you sure you want to revoke {right} rights from all selected users?', activateMultipleUsersConfirmation: 'Are you sure you want to activate accounts of all selected users?', deactivateMultipleUsersConfirmation: 'Are you sure you want to deactivate accounts of all selected users?', - deleteUsersConfirmation: 'Are you sure you want to delete this account? This action cannot be undone.', - deleteMultipleUsersConfirmation: 'Are you sure you want to delete accounts of all selected users?', + deleteUserConfirmation: 'Are you sure you want to delete this account? This action cannot be undone.', + rejectAccountConfirmation: 'Are you sure you want to reject this account? This account will be deleted and it cannot be undone.', + deleteMultipleUsersConfirmation: 'Are you sure you want to delete accounts of all selected users? This action cannot be undone.', addTagForMultipleUsersConfirmation: 'Are you sure you want to apply tag to all selected users?', removeTagFromMultipleUsersConfirmation: 'Are you sure you want to remove tag from all selected users?', requirePasswordResetConfirmation: 'Are you sure you want to require password reset for all selected users?', approveAccountsConfirmation: 'Are you sure you want to approve accounts for all selected users?', - rejectAccountsConfirmation: 'Are you sure you want to reject accounts for all selected users?', + rejectAccountsConfirmation: 'Are you sure you want to reject accounts for all selected users? These accounts will be deleted and it cannot be undone.', confirmAccountsConfirmation: 'Are you sure you want to confirm emails for all selected users?', resendEmailConfirmation: 'Are you sure you want to resend confirmation email for all selected users?', mailerMustBeEnabled: 'To require user\'s password reset you must enable mailer.', @@ -268,7 +269,8 @@ export default { invalidAccount: 'This account has invalid nickname and can\'t be modified', invalidNickname: 'invalid nickname', passwordResetTokenGenerated: 'Password reset token was generated:', - linkToResetPassword: 'You can also use this link to reset password:' + linkToResetPassword: 'You can also use this link to reset password:', + registrationReason: 'Registration Reason' }, statuses: { statuses: 'Statuses', @@ -323,7 +325,7 @@ export default { external: 'External', byStatus: 'By status', active: 'Active', - pending: 'Pending', + pending: 'Pending Approval', deactivated: 'Deactivated' }, reports: { diff --git a/src/store/modules/users.js b/src/store/modules/users.js index ccfc10b3..760a4afa 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -31,7 +31,7 @@ const users = { local: false, external: false, active: false, - needApproval: false, + need_approval: false, deactivated: false }, passwordResetToken: { @@ -126,14 +126,32 @@ const users = { dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId, statusId: _statusId }) }, + async ApproveUsersAccount({ dispatch, getters }, { users, _userId, _statusId }) { + const updatedUsers = users.map(user => { + return { ...user, approval_pending: false } + }) + const nicknames = users.map(user => user.nickname) + const callApiFn = async() => await approveUserAccount(nicknames, getters.authHost, getters.token) + + dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId, statusId: _statusId }) + }, ClearUsersState({ commit }) { commit('SET_SEARCH_QUERY', '') - commit('SET_USERS_FILTERS', { local: false, external: false, active: false, needApproval: false, deactivated: false }) + commit('SET_USERS_FILTERS', { local: false, external: false, active: false, need_approval: false, deactivated: false }) }, async ClearFilters({ commit, dispatch, state }) { commit('CLEAR_USERS_FILTERS') dispatch('SearchUsers', { query: state.searchQuery, page: 1 }) }, + async ConfirmUsersEmail({ dispatch, getters }, { users, _userId, _statusId }) { + const updatedUsers = users.map(user => { + return { ...user, confirmation_pending: false } + }) + const nicknames = users.map(user => user.nickname) + const callApiFn = async() => await confirmUserEmail(nicknames, getters.authHost, getters.token) + + dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId, statusId: _statusId }) + }, async CreateNewAccount({ dispatch, getters, state }, { nickname, email, password }) { try { await createNewAccount(nickname, email, password, getters.authHost, getters.token) @@ -161,33 +179,6 @@ const users = { } dispatch('SuccessMessage') }, - async ApproveUsersAccount({ dispatch, getters }, { users, _userId, _statusId }) { - const updatedUsers = users.map(user => { - return { ...user, approval_pending: false } - }) - const nicknames = users.map(user => user.nickname) - const callApiFn = async() => await approveUserAccount(nicknames, getters.authHost, getters.token) - - dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId, statusId: _statusId }) - }, - async ConfirmUsersEmail({ dispatch, getters }, { users, _userId, _statusId }) { - const updatedUsers = users.map(user => { - return { ...user, confirmation_pending: false } - }) - const nicknames = users.map(user => user.nickname) - const callApiFn = async() => await confirmUserEmail(nicknames, getters.authHost, getters.token) - - dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId, statusId: _statusId }) - }, - async ResendConfirmationEmail({ dispatch, getters }, users) { - const usersNicknames = users.map(user => user.nickname) - try { - await resendConfirmationEmail(usersNicknames, getters.authHost, getters.token) - } catch (_e) { - return - } - dispatch('SuccessMessage') - }, async DeleteRight({ dispatch, getters }, { users, right, _userId, _statusId }) { const updatedUsers = users.map(user => { return user.local ? { ...user, roles: { ...user.roles, [right]: false }} : user @@ -246,6 +237,15 @@ const users = { } dispatch('SuccessMessage') }, + async ResendConfirmationEmail({ dispatch, getters }, users) { + const usersNicknames = users.map(user => user.nickname) + try { + await resendConfirmationEmail(usersNicknames, getters.authHost, getters.token) + } catch (_e) { + return + } + dispatch('SuccessMessage') + }, async SearchUsers({ commit, dispatch, state, getters }, { query, page }) { if (query.length === 0) { commit('SET_SEARCH_QUERY', query) @@ -271,7 +271,7 @@ const users = { local: false, external: false, active: false, - needApproval: false, + need_approval: false, deactivated: false } const currentFilters = { ...defaultFilters, ...filters } diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue index b8312b4c..4ae3d7f2 100644 --- a/src/views/users/components/ModerationDropdown.vue +++ b/src/views/users/components/ModerationDropdown.vue @@ -155,7 +155,7 @@ export default { }, handleDeletion(user) { this.$confirm( - this.$t('users.deleteUsersConfirmation'), + this.$t('users.deleteUserConfirmation'), { confirmButtonText: 'Delete', cancelButtonText: 'Cancel', @@ -174,9 +174,9 @@ export default { }, handleAccountRejection(user) { this.$confirm( - this.$t('users.deleteUsersConfirmation'), + this.$t('users.rejectAccountConfirmation'), { - confirmButtonText: 'Delete', + confirmButtonText: 'Reject', cancelButtonText: 'Cancel', type: 'warning' }).then(() => { @@ -184,7 +184,7 @@ export default { }).catch(() => { this.$message({ type: 'info', - message: 'Delete canceled' + message: 'Reject canceled' }) }) }, diff --git a/src/views/users/components/MultipleUsersMenu.vue b/src/views/users/components/MultipleUsersMenu.vue index 652436a5..976d2913 100644 --- a/src/views/users/components/MultipleUsersMenu.vue +++ b/src/views/users/components/MultipleUsersMenu.vue @@ -325,7 +325,7 @@ export default { rejectAccountsForMultipleUsers() { const { remove } = this.mappers() this.confirmMessage( - this.$t('users.deleteMultipleUsersConfirmation'), + this.$t('users.rejectAccountsConfirmation'), remove ) }, diff --git a/src/views/users/components/UsersFilter.vue b/src/views/users/components/UsersFilter.vue index 424b7071..9ba4e3fa 100644 --- a/src/views/users/components/UsersFilter.vue +++ b/src/views/users/components/UsersFilter.vue @@ -12,7 +12,7 @@ {{ $t('usersFilter.active') }} - {{ $t('usersFilter.pending') }} + {{ $t('usersFilter.pending') }} {{ $t('usersFilter.deactivated') }} @@ -37,20 +37,25 @@ export default { methods: { removeOppositeFilters() { const filtersQuantity = Object.keys(this.$store.state.users.filters).length - const currentFilters = this.$data.value.slice() - const indexOfLocal = currentFilters.indexOf('local') - const indexOfExternal = currentFilters.indexOf('external') - const indexOfActive = currentFilters.indexOf('active') - const indexOfDeactivated = currentFilters.indexOf('deactivated') - if (currentFilters.length === filtersQuantity) { + const currentFilters = [] + const indexOfLocal = this.$data.value.indexOf('local') + const indexOfExternal = this.$data.value.indexOf('external') + const indexOfActive = this.$data.value.indexOf('active') + const indexOfDeactivated = this.$data.value.indexOf('deactivated') + const indexOfPending = this.$data.value.indexOf('need_approval') + + if (this.$data.value.length === filtersQuantity) { return [] - } else if (indexOfLocal > -1 && indexOfExternal > -1) { - const filterToRemove = indexOfLocal > indexOfExternal ? indexOfExternal : indexOfLocal - currentFilters.splice(filterToRemove, 1) - } else if (indexOfActive > -1 && indexOfDeactivated > -1) { - const filterToRemove = indexOfActive > indexOfDeactivated ? indexOfDeactivated : indexOfActive - currentFilters.splice(filterToRemove, 1) } + + Math.max(indexOfLocal, indexOfExternal) > -1 + ? currentFilters.push(this.$data.value[Math.max(indexOfLocal, indexOfExternal)]) + : currentFilters + + Math.max(indexOfActive, indexOfDeactivated, indexOfPending) > -1 + ? currentFilters.push(this.$data.value[Math.max(indexOfActive, indexOfDeactivated, indexOfPending)]) + : currentFilters + return currentFilters }, toggleFilters() { diff --git a/src/views/users/index.vue b/src/views/users/index.vue index 3831ba80..ea892416 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -56,10 +56,20 @@ - + + +