From f5b4845aa24df1a1da9f8967184073b9e3dcfb98 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 13 Nov 2020 02:11:52 +0300 Subject: [PATCH] Revert "Merge branch 'feature/edit-tags-manually' into 'develop'" This reverts commit fd9f0542ce17e26fa7459ad816b7b20c003786ef, reversing changes made to acfe0dd6a3e600eaf0bb2000ccca6202542c9144. --- CHANGELOG.md | 1 - src/api/__mocks__/users.js | 4 - src/api/users.js | 133 ++++++++--------- src/lang/en.js | 8 +- src/store/modules/users.js | 19 +-- .../components/ModerateUserDropdown.vue | 73 ++++++---- src/views/reports/index.vue | 1 - .../users/components/ModerationDropdown.vue | 91 ++++++++++-- .../users/components/MultipleUsersMenu.vue | 131 ++++++++++------- src/views/users/index.vue | 136 ++---------------- test/views/users/index.test.js | 41 +----- 11 files changed, 290 insertions(+), 348 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5451a00e..bb1790cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 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 -- Move tag moderation from Moderation menu to separate column in the Users table, add ability to add custom tags ### Fixed diff --git a/src/api/__mocks__/users.js b/src/api/__mocks__/users.js index 8e637ebe..a389d7f4 100644 --- a/src/api/__mocks__/users.js +++ b/src/api/__mocks__/users.js @@ -121,10 +121,6 @@ export async function deleteUsers(nicknames, authHost, token) { }) } -export async function listAllTags(authHost, token) { - return Promise.resolve({ data: ['verify', 'mrf_tag:media-force-nsfw'] }) -} - export async function tagUser(nickname, tag, authHost, token) { return Promise.resolve() } diff --git a/src/api/users.js b/src/api/users.js index d45aa701..41c6b9b4 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -22,35 +22,6 @@ export async function addRight(nicknames, right, authHost, token) { }) } -export async function fetchUserChats(id, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/${id}/chats`, - method: 'get', - headers: authHeaders(token) - }) -} - -export async function approveUserAccount(nicknames, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: '/api/pleroma/admin/users/approve', - method: 'patch', - headers: authHeaders(token), - data: { nicknames } - }) -} - -export async function confirmUserEmail(nicknames, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: '/api/pleroma/admin/users/confirm_email', - method: 'patch', - headers: authHeaders(token), - data: { nicknames } - }) -} - export async function createNewAccount(nickname, email, password, authHost, token) { return await request({ baseURL: baseName(authHost), @@ -110,6 +81,25 @@ export async function fetchUser(id, authHost, token) { }) } +export async function fetchUserCredentials(nickname, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/${nickname}/credentials`, + method: 'get', + headers: authHeaders(token) + }) +} + +export async function updateUserCredentials(nickname, credentials, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/${nickname}/credentials`, + method: 'patch', + headers: authHeaders(token), + data: credentials + }) +} + export async function fetchUsers(filters, actorTypeFilters, authHost, token, page = 1) { const url = actorTypeFilters.length === 0 ? `/api/pleroma/admin/users?page=${page}&filters=${filters}` @@ -126,34 +116,6 @@ export async function fetchUsers(filters, actorTypeFilters, authHost, token, pag }) } -export async function fetchUserCredentials(nickname, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/${nickname}/credentials`, - method: 'get', - headers: authHeaders(token) - }) -} - -export async function fetchUserStatuses(id, authHost, godmode, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`, - method: 'get', - headers: authHeaders(token) - }) -} - -export async function forcePasswordReset(nicknames, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/force_password_reset`, - method: 'patch', - headers: authHeaders(token), - data: { nicknames } - }) -} - export async function getPasswordResetToken(nickname, authHost, token) { return await request({ baseURL: baseName(authHost), @@ -163,19 +125,10 @@ export async function getPasswordResetToken(nickname, authHost, token) { }) } -export async function listAllTags(authHost, token) { +export async function forcePasswordReset(nicknames, authHost, token) { return await request({ baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/tag`, - method: 'get', - headers: authHeaders(token) - }) -} - -export async function resendConfirmationEmail(nicknames, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: '/api/pleroma/admin/users/resend_confirmation_email', + url: `/api/pleroma/admin/users/force_password_reset`, method: 'patch', headers: authHeaders(token), data: { nicknames } @@ -218,13 +171,51 @@ export async function untagUser(nicknames, tags, authHost, token) { }) } -export async function updateUserCredentials(nickname, credentials, authHost, token) { +export async function fetchUserStatuses(id, authHost, godmode, token) { return await request({ baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/${nickname}/credentials`, + url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`, + method: 'get', + headers: authHeaders(token) + }) +} + +export async function fetchUserChats(id, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/${id}/chats`, + method: 'get', + headers: authHeaders(token) + }) +} + +export async function approveUserAccount(nicknames, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: '/api/pleroma/admin/users/approve', method: 'patch', headers: authHeaders(token), - data: credentials + data: { nicknames } + }) +} + +export async function confirmUserEmail(nicknames, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: '/api/pleroma/admin/users/confirm_email', + method: 'patch', + headers: authHeaders(token), + data: { nicknames } + }) +} + +export async function resendConfirmationEmail(nicknames, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: '/api/pleroma/admin/users/resend_confirmation_email', + method: 'patch', + headers: authHeaders(token), + data: { nicknames } }) } diff --git a/src/lang/en.js b/src/lang/en.js index 7bc59811..e21a156d 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -192,7 +192,6 @@ export default { search: 'Search', id: 'ID', name: 'Name', - label: 'Label', status: 'Status', local: 'Local', external: 'External', @@ -280,12 +279,9 @@ export default { registrationReason: 'Registration Reason', service: 'Service', person: 'Person', - enableTagPolicy: 'Enable MRF TagPolicy to manage tags', + enableTagPolicy: 'Enable MRF TagPolicy to manage user tags', confirmEnablingTagPolicy: 'Are you sure you want to add TagPolicy to the list of enabled MRF policies?', - enableTagPolicySuccessMessage: 'MRF TagPolicy was enabled', - customTags: 'Custom Tags', - defaultTags: 'Default Tags', - tags: 'Tags' + enableTagPolicySuccessMessage: 'MRF TagPolicy was enabled' }, statuses: { statuses: 'Statuses', diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 7bacb907..29b98fcf 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -3,21 +3,20 @@ import i18n from '@/lang' import { activateUsers, addRight, - approveUserAccount, - confirmUserEmail, createNewAccount, deactivateUsers, deleteRight, deleteUsers, disableMfa, fetchUsers, - forcePasswordReset, getPasswordResetToken, - listAllTags, - resendConfirmationEmail, searchUsers, tagUser, untagUser, + forcePasswordReset, + approveUserAccount, + confirmUserEmail, + resendConfirmationEmail, updateUserCredentials } from '@/api/users' import { fetchSettings, updateSettings } from '@/api/settings' @@ -36,8 +35,7 @@ const users = { passwordResetToken: { token: '', link: '' - }, - tags: [] + } }, mutations: { SET_ACTOR_TYPE_FILTERS: (state, actorTypeFilters) => { @@ -83,9 +81,6 @@ const users = { SET_TAG_POLICY: (state, mrfPolicies) => { state.mrfPolicies = mrfPolicies }, - SET_TAGS: (state, tags) => { - state.tags = tags - }, SET_USERS_FILTERS: (state, filters) => { state.filters = filters } @@ -249,10 +244,6 @@ const users = { RemovePasswordToken({ commit }) { commit('SET_PASSWORD_RESET_TOKEN', { link: '', token: '' }) }, - async ListTags({ commit, getters }) { - const { data } = await listAllTags(getters.authHost, getters.token) - commit('SET_TAGS', data) - }, async RemoveTag({ dispatch, getters }, { users, tag, _userId, _statusId }) { const updatedUsers = users.map(user => { return { ...user, tags: user.tags.filter(userTag => userTag !== tag) } diff --git a/src/views/reports/components/ModerateUserDropdown.vue b/src/views/reports/components/ModerateUserDropdown.vue index 922c5a56..3d5618f1 100644 --- a/src/views/reports/components/ModerateUserDropdown.vue +++ b/src/views/reports/components/ModerateUserDropdown.vue @@ -15,17 +15,49 @@ @click.native="handleDeletion(account)"> {{ $t('users.deleteAccount') }} - -
- - {{ option.label }} - - -
+ + {{ $t('users.forceNsfw') }} + + + + {{ $t('users.stripMedia') }} + + + + {{ $t('users.forceUnlisted') }} + + + + {{ $t('users.sandbox') }} + + + + {{ $t('users.disableRemoteSubscription') }} + + + + {{ $t('users.disableAnySubscription') }} + + { - if (this.mapTags[tag]) { - return { tag, label: this.mapTags[tag] } - } else { - return { tag, label: tag.charAt(0).toUpperCase() + tag.slice(1) } - } - }, {}) + return this.account.tags || [] } }, methods: { diff --git a/src/views/reports/index.vue b/src/views/reports/index.vue index c9a03b2e..a5ab431a 100644 --- a/src/views/reports/index.vue +++ b/src/views/reports/index.vue @@ -43,7 +43,6 @@ export default { this.$store.dispatch('NeedReboot') this.$store.dispatch('FetchTagPolicySetting') this.$store.dispatch('FetchReports', 1) - this.$store.dispatch('ListTags') } } diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue index 0cd1fea0..d54efe43 100644 --- a/src/views/users/components/ModerationDropdown.vue +++ b/src/views/users/components/ModerationDropdown.vue @@ -67,6 +67,56 @@ @click.native="handleConfirmationResend(user)"> {{ $t('users.resendConfirmation') }} + + {{ $t('users.forceNsfw') }} + + + + {{ $t('users.stripMedia') }} + + + + {{ $t('users.forceUnlisted') }} + + + + {{ $t('users.sandbox') }} + + + + {{ $t('users.disableRemoteSubscription') }} + + + + {{ $t('users.disableAnySubscription') }} + + + + {{ $t('users.enableTagPolicy') }} + { + this.$message({ + type: 'success', + message: this.$t('users.enableTagPolicySuccessMessage') + }) + this.$store.dispatch('EnableTagPolicy') + }).catch(() => { + this.$message({ + type: 'info', + message: 'Canceled' + }) + }) + }, getPasswordResetToken(nickname) { this.$emit('open-reset-token-dialog') this.$store.dispatch('GetPasswordResetToken', nickname) @@ -192,6 +265,11 @@ export default { ? this.$store.dispatch('ActivateUsers', { users: [user], _userId: user.id }) : this.$store.dispatch('DeactivateUsers', { users: [user], _userId: user.id }) }, + toggleTag(user, tag) { + user.tags.includes(tag) + ? this.$store.dispatch('RemoveTag', { users: [user], tag, _userId: user.id, _statusId: this.statusId }) + : this.$store.dispatch('AddTag', { users: [user], tag, _userId: user.id, _statusId: this.statusId }) + }, toggleUserRight(user, right) { user.roles[right] ? this.$store.dispatch('DeleteRight', { users: [user], right, _userId: user.id, _statusId: this.statusId }) @@ -233,14 +311,8 @@ export default { } } .actor-type-select .el-input.is-focus .el-input__inner { - border-color: transparent; - } - .custom-tags-titile { - padding-left: 20px; - font-size: 12px; - color: #909399; - line-height: 30px; - } + border-color: transparent; + } .moderate-user-button { text-align: left; width: 350px; @@ -252,9 +324,6 @@ export default { } .moderation-dropdown-menu { width: 350px; - .el-dropdown-menu--small .el-dropdown-menu__item.el-dropdown-menu__item--divided { - margin-top: 0; - } } @media only screen and (max-width:480px) { .moderate-user-button { diff --git a/src/views/users/components/MultipleUsersMenu.vue b/src/views/users/components/MultipleUsersMenu.vue index a0224645..bdf65006 100644 --- a/src/views/users/components/MultipleUsersMenu.vue +++ b/src/views/users/components/MultipleUsersMenu.vue @@ -61,27 +61,83 @@ @click.native="requirePasswordReset"> {{ $t('users.requirePasswordReset') }} - - -
- {{ $t('users.tags') }} -
- - -
- {{ option.label }} - - - {{ $t('users.apply') }} - - - {{ $t('users.remove') }} - - -
-
-
-
+ +
+ {{ $t('users.forceNsfw') }} + + + {{ $t('users.apply') }} + + + {{ $t('users.remove') }} + + +
+
+ +
+ {{ $t('users.stripMedia') }} + + + {{ $t('users.apply') }} + + + {{ $t('users.remove') }} + + +
+
+ +
+ {{ $t('users.forceUnlisted') }} + + + {{ $t('users.apply') }} + + + {{ $t('users.remove') }} + + +
+
+ +
+ {{ $t('users.sandbox') }} + + + {{ $t('users.apply') }} + + + {{ $t('users.remove') }} + + +
+
+ +
+ {{ $t('users.disableRemoteSubscriptionForMultiple') }} + + + {{ $t('users.apply') }} + + + {{ $t('users.remove') }} + + +
+
+ +
+ {{ $t('users.disableAnySubscriptionForMultiple') }} + + + {{ $t('users.apply') }} + + + {{ $t('users.remove') }} + + +
0 }, tagPolicyEnabled() { return this.$store.state.users.mrfPolicies.includes('Pleroma.Web.ActivityPub.MRF.TagPolicy') - }, - tags() { - return this.$store.state.users.tags.map(tag => { - if (this.mapTags[tag]) { - return { tag, label: this.mapTags[tag] } - } else { - return { tag, label: tag.charAt(0).toUpperCase() + tag.slice(1) } - } - }, {}) } }, methods: { @@ -370,14 +406,6 @@ export default { .el-icon-edit { margin-right: 5px; } - .multiple-tags-moderation { - width: 100%; - } - .no-hover:hover { - color: #606266; - background-color: white; - cursor: auto; - } .tag-container { display: flex; justify-content: space-between; @@ -386,4 +414,9 @@ export default { .tag-text { padding-right: 20px; } + .no-hover:hover { + color: #606266; + background-color: white; + cursor: auto; + } diff --git a/src/views/users/index.vue b/src/views/users/index.vue index 2ea7fa7f..4baaed01 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -54,7 +54,7 @@ - + - - -