Change user.deactivated field to user.is_active
This commit is contained in:
parent
27db721e39
commit
df0abd99c7
11 changed files with 35 additions and 34 deletions
|
@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
- **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
|
||||
- **Breaking**: AdminAPI changed User field `approval_pending` to `is_approved`
|
||||
- **Breaking**: AdminAPI changed User field `deactivated` to `is_active`
|
||||
- Hide Tag actions on Users tab if MRF TagPolicy is disabled. Add ability to enable TagPolicy from Moderation menu
|
||||
- Move `:restrict_unauthenticated` settings from Authentication tab to Instance tab
|
||||
- Replace regular inputs with textareas for setting welcome messages in the Settings section
|
||||
|
|
|
@ -43,7 +43,7 @@ export function getUserInfo(token, authHost) {
|
|||
'statuses_count': 0,
|
||||
'cover_photo': '',
|
||||
'hide_follows': false,
|
||||
'pleroma': { 'is_confirmed': true, 'deactivated': false, 'tags': ['force_nsfw'], 'is_admin': true },
|
||||
'pleroma': { 'is_confirmed': true, 'is_active': true, 'tags': ['force_nsfw'], 'is_admin': true },
|
||||
'profile_image_url_original': '',
|
||||
'created_at': 'Fri Mar 01 15:15:19 +0000 2019',
|
||||
'fields': [],
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import userChats from './chat'
|
||||
|
||||
export let users = [
|
||||
{ active: true, is_confirmed: true, is_approved: true, deactivated: false, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [], actor_type: 'Person' },
|
||||
{ active: true, is_confirmed: true, is_approved: true, deactivated: false, id: '10', nickname: 'bob', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'], actor_type: 'Person' },
|
||||
{ active: true, is_confirmed: true, is_approved: false, deactivated: false, id: '567', nickname: 'ded', local: false, external: true, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Person' },
|
||||
{ active: false, is_confirmed: true, is_approved: true, deactivated: true, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:media-strip'], actor_type: 'Person' },
|
||||
{ active: true, is_confirmed: true, is_approved: false, deactivated: false, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Service' },
|
||||
{ active: true, is_confirmed: true, is_approved: false, deactivated: false, id: '123', nickname: 'bot', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Application' }
|
||||
{ active: true, is_confirmed: true, is_approved: true, is_active: true, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [], actor_type: 'Person' },
|
||||
{ active: true, is_confirmed: true, is_approved: true, is_active: true, id: '10', nickname: 'bob', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'], actor_type: 'Person' },
|
||||
{ active: true, is_confirmed: true, is_approved: false, is_active: true, id: '567', nickname: 'ded', local: false, external: true, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Person' },
|
||||
{ active: false, is_confirmed: true, is_approved: true, is_active: false, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:media-strip'], actor_type: 'Person' },
|
||||
{ active: true, is_confirmed: true, is_approved: false, is_active: true, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Service' },
|
||||
{ active: true, is_confirmed: true, is_approved: false, is_active: true, id: '123', nickname: 'bot', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Application' }
|
||||
]
|
||||
|
||||
const userProfile = { avatar: 'avatar.jpg', nickname: 'allis', id: '2', tags: [], roles: { admin: true, moderator: false }, local: true, external: false }
|
||||
|
@ -82,7 +82,7 @@ export async function searchUsers(query, filters, actorTypeFilters, authHost, to
|
|||
export async function activateUsers(nicknames, authHost, token) {
|
||||
const response = nicknames.map(nickname => {
|
||||
const currentUser = users.find(user => user.nickname === nickname)
|
||||
return { ...currentUser, deactivated: false }
|
||||
return { ...currentUser, is_active: true }
|
||||
})
|
||||
return Promise.resolve({ data: response })
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ export async function addRight(nicknames, right, authHost, token) {
|
|||
export async function deactivateUsers(nicknames, authHost, token) {
|
||||
const response = nicknames.map(nickname => {
|
||||
const currentUser = users.find(user => user.nickname === nickname)
|
||||
return { ...currentUser, deactivated: true }
|
||||
return { ...currentUser, is_active: false }
|
||||
})
|
||||
return Promise.resolve({ data: response })
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ export async function untagUser(nickname, tag, authHost, token) {
|
|||
}
|
||||
|
||||
export async function createNewAccount(nickname, email, password, authHost, token) {
|
||||
const newUser = { active: true, deactivated: false, id: '15', nickname, local: true, external: false, roles: { admin: false, moderator: false }, tags: [] }
|
||||
const newUser = { active: true, is_active: true, id: '15', nickname, local: true, external: false, roles: { admin: false, moderator: false }, tags: [] }
|
||||
users = [...users, newUser]
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ const reports = {
|
|||
return
|
||||
} finally {
|
||||
const updatedReports = state.fetchedReports.map(report => {
|
||||
const updatedAccount = { ...user, deactivated: false }
|
||||
const updatedAccount = { ...user, is_active: true }
|
||||
return report.id === reportId ? { ...report, account: updatedAccount } : report
|
||||
})
|
||||
commit('SET_REPORTS', updatedReports)
|
||||
|
@ -69,7 +69,7 @@ const reports = {
|
|||
} catch (_e) {
|
||||
return
|
||||
} finally {
|
||||
const updatedReport = { ...state.singleReport, account: { ...user, deactivated: false }}
|
||||
const updatedReport = { ...state.singleReport, account: { ...user, is_active: true }}
|
||||
commit('SET_SINGLE_REPORT', updatedReport)
|
||||
}
|
||||
dispatch('SuccessMessage')
|
||||
|
@ -124,7 +124,7 @@ const reports = {
|
|||
return
|
||||
} finally {
|
||||
const updatedReports = state.fetchedReports.map(report => {
|
||||
const updatedAccount = { ...user, deactivated: true }
|
||||
const updatedAccount = { ...user, is_active: false }
|
||||
return report.id === reportId ? { ...report, account: updatedAccount } : report
|
||||
})
|
||||
commit('SET_REPORTS', updatedReports)
|
||||
|
@ -137,7 +137,7 @@ const reports = {
|
|||
} catch (_e) {
|
||||
return
|
||||
} finally {
|
||||
const updatedReport = { ...state.singleReport, account: { ...user, deactivated: true }}
|
||||
const updatedReport = { ...state.singleReport, account: { ...user, is_active: false }}
|
||||
commit('SET_SINGLE_REPORT', updatedReport)
|
||||
}
|
||||
dispatch('SuccessMessage')
|
||||
|
@ -149,7 +149,7 @@ const reports = {
|
|||
return
|
||||
} finally {
|
||||
const updatedReports = state.fetchedReports.map(report => {
|
||||
const updatedAccount = { ...user, deactivated: true }
|
||||
const updatedAccount = { ...user, is_active: false }
|
||||
return report.id === reportId ? { ...report, account: updatedAccount } : report
|
||||
})
|
||||
commit('SET_REPORTS', updatedReports)
|
||||
|
|
|
@ -88,7 +88,7 @@ const users = {
|
|||
actions: {
|
||||
async ActivateUsers({ dispatch, getters }, { users, _userId }) {
|
||||
const updatedUsers = users.map(user => {
|
||||
return { ...user, deactivated: false }
|
||||
return { ...user, is_active: true }
|
||||
})
|
||||
const nicknames = users.map(user => user.nickname)
|
||||
const callApiFn = async() => await activateUsers(nicknames, getters.authHost, getters.token)
|
||||
|
@ -168,7 +168,7 @@ const users = {
|
|||
},
|
||||
async DeactivateUsers({ dispatch, getters }, { users, _userId }) {
|
||||
const updatedUsers = users.map(user => {
|
||||
return { ...user, deactivated: true }
|
||||
return { ...user, is_active: false }
|
||||
})
|
||||
const nicknames = users.map(user => user.nickname)
|
||||
const callApiFn = async() => await deactivateUsers(nicknames, getters.authHost, getters.token)
|
||||
|
@ -200,7 +200,7 @@ const users = {
|
|||
return
|
||||
}
|
||||
const updatedUsers = users.map(user => {
|
||||
return { ...user, deactivated: true }
|
||||
return { ...user, is_active: false }
|
||||
})
|
||||
commit('SWAP_USERS', updatedUsers)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<el-dropdown-item
|
||||
v-if="showDeactivatedButton(account)"
|
||||
@click.native="handleDeactivation(account)">
|
||||
{{ account.deactivated ? $t('users.activateAccount') : $t('users.deactivateAccount') }}
|
||||
{{ !account.is_active ? $t('users.activateAccount') : $t('users.deactivateAccount') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="showDeactivatedButton(account.id)"
|
||||
|
@ -120,11 +120,11 @@ export default {
|
|||
},
|
||||
handleDeactivation(user) {
|
||||
if (this.renderedFrom === 'showPage') {
|
||||
user.deactivated
|
||||
!user.is_active
|
||||
? this.$store.dispatch('ActivateUserFromReportShow', user)
|
||||
: this.$store.dispatch('DeactivateUserFromReportShow', user)
|
||||
} else if (this.renderedFrom === 'reportsPage') {
|
||||
user.deactivated
|
||||
!user.is_active
|
||||
? this.$store.dispatch('ActivateUserFromReports', { user, reportId: this.reportId })
|
||||
: this.$store.dispatch('DeactivateUserFromReports', { user, reportId: this.reportId })
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
v-if="showDeactivatedButton(user.id) && page !== 'statusPage'"
|
||||
:divided="showAdminAction(user)"
|
||||
@click.native="toggleActivation(user)">
|
||||
{{ user.deactivated ? $t('users.activateAccount') : $t('users.deactivateAccount') }}
|
||||
{{ !user.is_active ? $t('users.activateAccount') : $t('users.deactivateAccount') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="showDeactivatedButton(user.id) && page !== 'statusPage'"
|
||||
|
@ -261,7 +261,7 @@ export default {
|
|||
return this.$store.state.user.id !== id
|
||||
},
|
||||
toggleActivation(user) {
|
||||
user.deactivated
|
||||
!user.is_active
|
||||
? this.$store.dispatch('ActivateUsers', { users: [user], _userId: user.id })
|
||||
: this.$store.dispatch('DeactivateUsers', { users: [user], _userId: user.id })
|
||||
},
|
||||
|
|
|
@ -197,13 +197,13 @@ export default {
|
|||
applyAction(filtered, deleteRightFn)
|
||||
},
|
||||
activate: () => {
|
||||
const filtered = this.selectedUsers.filter(user => user.nickname && user.deactivated && this.$store.state.user.id !== user.id)
|
||||
const filtered = this.selectedUsers.filter(user => user.nickname && !user.is_active && this.$store.state.user.id !== user.id)
|
||||
const activateUsersFn = async(users) => await this.$store.dispatch('ActivateUsers', { users })
|
||||
|
||||
applyAction(filtered, activateUsersFn)
|
||||
},
|
||||
deactivate: () => {
|
||||
const filtered = this.selectedUsers.filter(user => user.nickname && !user.deactivated && this.$store.state.user.id !== user.id)
|
||||
const filtered = this.selectedUsers.filter(user => user.nickname && user.is_active && this.$store.state.user.id !== user.id)
|
||||
const deactivateUsersFn = async(users) => await this.$store.dispatch('DeactivateUsers', { users })
|
||||
|
||||
applyAction(filtered, deactivateUsersFn)
|
||||
|
|
|
@ -56,11 +56,11 @@
|
|||
</el-table-column>
|
||||
<el-table-column :min-width="width" :label="$t('users.status')">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="!scope.row.deactivated && scope.row.is_approved" type="success">
|
||||
<el-tag v-if="scope.row.is_active && scope.row.is_approved" type="success">
|
||||
<span v-if="isDesktop">{{ $t('users.active') }}</span>
|
||||
<i v-else class="el-icon-circle-check"/>
|
||||
</el-tag>
|
||||
<el-tag v-if="scope.row.deactivated && scope.row.is_approved" type="danger">
|
||||
<el-tag v-if="!scope.row.is_active && scope.row.is_approved" type="danger">
|
||||
<span v-if="isDesktop">{{ $t('users.deactivated') }}</span>
|
||||
<i v-else class="el-icon-circle-close"/>
|
||||
</el-tag>
|
||||
|
|
|
@ -90,8 +90,8 @@
|
|||
<td>{{ $t('userProfile.status') }}</td>
|
||||
<td>
|
||||
<el-tag v-if="!user.is_approved" type="info">{{ $t('userProfile.pending') }}</el-tag>
|
||||
<el-tag v-if="!user.deactivated && user.is_approved" type="success">{{ $t('userProfile.active') }}</el-tag>
|
||||
<el-tag v-if="user.deactivated" type="danger">{{ $t('userProfile.deactivated') }}</el-tag>
|
||||
<el-tag v-if="user.is_active && user.is_approved" type="success">{{ $t('userProfile.active') }}</el-tag>
|
||||
<el-tag v-if="!user.is_active" type="danger">{{ $t('userProfile.deactivated') }}</el-tag>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -154,11 +154,11 @@ describe('Users actions', () => {
|
|||
await flushPromises()
|
||||
|
||||
const user = store.state.users.fetchedUsers[1]
|
||||
expect(user.deactivated).toBe(false)
|
||||
expect(user.is_active).toBe(true)
|
||||
wrapper.find(htmlElement(2, 4)).trigger('click')
|
||||
|
||||
const updatedUser = store.state.users.fetchedUsers[1]
|
||||
expect(updatedUser.deactivated).toBe(true)
|
||||
expect(updatedUser.is_active).toBe(false)
|
||||
done()
|
||||
})
|
||||
|
||||
|
@ -172,13 +172,13 @@ describe('Users actions', () => {
|
|||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(store.state.users.fetchedUsers[1].deactivated).toBe(false)
|
||||
expect(store.state.users.fetchedUsers[1].is_active).toBe(true)
|
||||
|
||||
wrapper.find(htmlElement(2, 5)).trigger('click')
|
||||
store.dispatch('DeleteUsers', { users: [{ active: true, deactivated: false, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'] }] })
|
||||
store.dispatch('DeleteUsers', { users: [{ active: true, is_active: true, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'] }] })
|
||||
|
||||
await flushPromises()
|
||||
expect(store.state.users.fetchedUsers[1].deactivated).toBe(true)
|
||||
expect(store.state.users.fetchedUsers[1].is_active).toBe(false)
|
||||
done()
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue