From df0abd99c7e3c44552f06aeb05e4b3c64c1038b6 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 18 Jan 2021 15:16:54 -0600 Subject: [PATCH] Change user.deactivated field to user.is_active --- CHANGELOG.md | 1 + src/api/__mocks__/login.js | 2 +- src/api/__mocks__/users.js | 18 +++++++++--------- src/store/modules/reports.js | 10 +++++----- src/store/modules/users.js | 6 +++--- .../components/ModerateUserDropdown.vue | 6 +++--- .../users/components/ModerationDropdown.vue | 4 ++-- .../users/components/MultipleUsersMenu.vue | 4 ++-- src/views/users/index.vue | 4 ++-- src/views/users/show.vue | 4 ++-- test/views/users/index.test.js | 10 +++++----- 11 files changed, 35 insertions(+), 34 deletions(-) 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..c93b3007 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' } + { 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() } 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 @@