diff --git a/CHANGELOG.md b/CHANGELOG.md index 45eb0a9b..ecf9c913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added + +- Allow managing user's actor_type field via Admin API + ### Fixed - Fix following and unfollowing relays from Admin-FE, update mobile UI diff --git a/src/api/__mocks__/status.js b/src/api/__mocks__/status.js index b24142d2..e77f0a0b 100644 --- a/src/api/__mocks__/status.js +++ b/src/api/__mocks__/status.js @@ -55,11 +55,11 @@ export async function fetchStatusesByInstance({ instance, authHost, token, pageS 'nickname': 'sky', 'url': 'http://localhost:4000/users/sky' }, - 'content': 'A nice young couple contacted us from Brazil to decorate their newly acquired apartment.', - 'created_at': '2020-01-31T18:20:01.000Z', - 'id': '9rZIr0Jzao5Gjgfmro', + 'content': 'i love parks&rec', + 'created_at': '2020-04-12T18:20:01.000Z', + 'id': 'o5Gjgfmro9rZIr0Jza', 'sensitive': false, - 'url': 'http://localhost:4000/objects/7af9abbd-fb6c-4318-aeb7-6636c138ac98', + 'url': 'http://localhost:4000/objects/7af9abbd-aeb7-6636c138ac98-fb6c-4318', 'visibility': 'unlisted' }, { diff --git a/src/api/__mocks__/users.js b/src/api/__mocks__/users.js index b21cac33..f6b9c3fe 100644 --- a/src/api/__mocks__/users.js +++ b/src/api/__mocks__/users.js @@ -1,8 +1,8 @@ export let users = [ - { active: true, approval_pending: false, deactivated: false, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [] }, - { active: true, approval_pending: false, deactivated: false, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'] }, - { active: false, approval_pending: false, deactivated: true, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:media-strip'] }, - { active: true, approval_pending: true, deactivated: false, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [] } + { active: true, approval_pending: false, deactivated: false, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [], actor_type: 'Person' }, + { active: true, approval_pending: false, deactivated: false, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'], actor_type: 'Person' }, + { active: false, approval_pending: false, 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, approval_pending: true, deactivated: false, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Service' } ] const userProfile = { avatar: 'avatar.jpg', nickname: 'allis', id: '2', tags: [], roles: { admin: true, moderator: false }, local: true, external: false } @@ -119,3 +119,7 @@ export async function createNewAccount(nickname, email, password, authHost, toke users = [...users, newUser] return Promise.resolve() } + +export async function updateUserCredentials(nickname, credentials, authHost, token) { + return Promise.resolve() +} diff --git a/src/lang/en.js b/src/lang/en.js index 8e9629b2..399f7ec2 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -271,7 +271,9 @@ export default { invalidNickname: 'invalid nickname', passwordResetTokenGenerated: 'Password reset token was generated:', linkToResetPassword: 'You can also use this link to reset password:', - registrationReason: 'Registration Reason' + registrationReason: 'Registration Reason', + service: 'Service', + person: 'Person' }, statuses: { statuses: 'Statuses', @@ -292,7 +294,8 @@ export default { admin: 'Admin', local: 'Local', external: 'External', - accountType: 'Account type', + accountType: 'Account Type', + actorType: 'Actor Type', nickname: 'Nickname', recentStatuses: 'Recent Statuses', roles: 'Roles', diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 760a4afa..631bff8e 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -16,7 +16,8 @@ import { forcePasswordReset, approveUserAccount, confirmUserEmail, - resendConfirmationEmail + resendConfirmationEmail, + updateUserCredentials } from '@/api/users' const users = { @@ -277,6 +278,14 @@ const users = { const currentFilters = { ...defaultFilters, ...filters } commit('SET_USERS_FILTERS', currentFilters) dispatch('SearchUsers', { query: state.searchQuery, page: 1 }) + }, + async UpdateActorType({ dispatch, getters }, { user, type, _userId, _statusId }) { + const updatedUsers = [{ ...user, actor_type: type }] + const credentials = { actor_type: type } + + const callApiFn = async() => await updateUserCredentials(user.nickname, credentials, getters.authHost, getters.token) + + dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId, statusId: _statusId }) } } } diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue index 4ae3d7f2..fd6ba5a3 100644 --- a/src/views/users/components/ModerationDropdown.vue +++ b/src/views/users/components/ModerationDropdown.vue @@ -16,8 +16,16 @@ + + + + + + {{ user.roles.admin ? $t('users.revokeAdmin') : $t('users.grantAdmin') }} @@ -138,6 +146,19 @@ export default { } }, computed: { + actorType: { + get() { + return this.user.actor_type + }, + set(type) { + this.$store.dispatch('UpdateActorType', { + user: this.user, + type, + _userId: this.user.id, + _statusId: this.statusId + }) + } + }, isDesktop() { return this.$store.state.app.device === 'desktop' } @@ -225,6 +246,39 @@ export default {