diff --git a/CHANGELOG.md b/CHANGELOG.md index 46f523b1..ac48d297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/api/__mocks__/login.js b/src/api/__mocks__/login.js index 31591f7b..d03d7ca3 100644 --- a/src/api/__mocks__/login.js +++ b/src/api/__mocks__/login.js @@ -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': [], diff --git a/src/api/__mocks__/users.js b/src/api/__mocks__/users.js index 6dec1f5f..b419ff3d 100644 --- a/src/api/__mocks__/users.js +++ b/src/api/__mocks__/users.js @@ -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' } + { 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' }, + { 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' }, + { 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' }, + { 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' }, + { 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' }, + { 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 } @@ -17,26 +17,6 @@ const userStatuses = [ { account: { id: '9n1bySks25olxWrku0', nickname: 'dolin' }, content: 'what is yout favorite pizza?', id: '9jop82OBXeFPYulVjM', created_at: '2020-05-22T17:34:34.000Z', visibility: 'public' } ] -const filterUsers = (str) => { - const filters = str.split(',').filter(item => item.length > 0) - if (filters.length === 0) { - return users - } - const applyFilters = (acc, filters, users) => { - if (filters.length === 0) { - return acc - } - const filteredUsers = users.filter(user => user[filters[0]]) - const newAcc = [...filteredUsers] - return applyFilters(newAcc, filters.slice(1), filteredUsers) - } - return applyFilters([], filters, users) -} - -const filterUsersByActorType = filters => { - return users.filter(user => filters.includes(user.actor_type)) -} - export async function fetchUser(id, authHost, token) { return Promise.resolve({ data: userProfile }) } @@ -46,12 +26,9 @@ export async function fetchUserCredentials(nickname, authHost, token) { } export async function fetchUsers(filters, actorTypeFilters, authHost, token, page = 1) { - const filteredUsers = filterUsers(filters) - const filteredByActorTypeUsers = filterUsersByActorType(actorTypeFilters) - const response = actorTypeFilters.length === 0 ? filteredUsers : filteredByActorTypeUsers return Promise.resolve({ data: { - users: response, - count: response.length, + users, + count: users.length, page_size: 50 }}) } @@ -69,12 +46,10 @@ export async function getPasswordResetToken(nickname, authHost, token) { } export async function searchUsers(query, filters, actorTypeFilters, authHost, token, page = 1) { - const filteredUsers = filterUsers(filters) - const filteredByActorTypeUsers = filterUsersByActorType(actorTypeFilters) - const response = actorTypeFilters.length === 0 ? filteredUsers : filteredByActorTypeUsers + const response = users.filter(user => user.nickname === query) return Promise.resolve({ data: { - users: response.filter(user => user.nickname === query), - count: response.filter(user => user.nickname === query).length, + users: response, + count: response.length, page_size: 50 }}) } @@ -82,7 +57,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 +71,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 +105,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() } diff --git a/src/store/modules/reports.js b/src/store/modules/reports.js index 2589daa4..7c45070b 100644 --- a/src/store/modules/reports.js +++ b/src/store/modules/reports.js @@ -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) diff --git a/src/store/modules/users.js b/src/store/modules/users.js index a1e0f9fe..0ba8c998 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -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) diff --git a/src/views/reports/components/ModerateUserDropdown.vue b/src/views/reports/components/ModerateUserDropdown.vue index 6c93ca82..ae80a3af 100644 --- a/src/views/reports/components/ModerateUserDropdown.vue +++ b/src/views/reports/components/ModerateUserDropdown.vue @@ -8,7 +8,7 @@ - {{ account.deactivated ? $t('users.activateAccount') : $t('users.deactivateAccount') }} + {{ !account.is_active ? $t('users.activateAccount') : $t('users.deactivateAccount') }} - {{ user.deactivated ? $t('users.activateAccount') : $t('users.deactivateAccount') }} + {{ !user.is_active ? $t('users.activateAccount') : $t('users.deactivateAccount') }} { - 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) diff --git a/src/views/users/index.vue b/src/views/users/index.vue index 7ca938d7..510c7b23 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -56,11 +56,11 @@