diff --git a/src/components/list/list.js b/src/components/list/list.js index aac0c4891..d61f9694a 100644 --- a/src/components/list/list.js +++ b/src/components/list/list.js @@ -57,7 +57,7 @@ const List = { return new Set(this.finalItems.map(this.getKey)) }, filteredSelected() { - return [ ...this.allKeys.values().filter((key) => this.selected.has(key))] + return [...this.allKeys.values().filter((key) => this.selected.has(key))] }, allSelected() { return this.selected.size === this.finalItems.length @@ -70,7 +70,7 @@ const List = { }, finalItems() { return this.externalItems || this.items - } + }, }, created() { window.addEventListener('scroll', this.scrollLoad) diff --git a/src/components/mute_card/mute_card.vue b/src/components/mute_card/mute_card.vue index 83520dc22..a9418cffa 100644 --- a/src/components/mute_card/mute_card.vue +++ b/src/components/mute_card/mute_card.vue @@ -1,5 +1,5 @@ diff --git a/src/components/settings_modal/admin_tabs/admin_card.js b/src/components/settings_modal/admin_tabs/admin_card.js index 53525f1cd..f3077bee8 100644 --- a/src/components/settings_modal/admin_tabs/admin_card.js +++ b/src/components/settings_modal/admin_tabs/admin_card.js @@ -1,291 +1,49 @@ -import Checkbox from 'src/components/checkbox/checkbox.vue' -import GenericConfirm from 'src/components/confirm_modal/generic_confirm.vue' -import TextConfirm from 'src/components/confirm_modal/text_confirm.vue' -import Modal from 'src/components/modal/modal.vue' -import List from 'src/components/list/list.vue' -import Popover from 'src/components/popover/popover.vue' -import Select from 'src/components/select/select.vue' -import AdminStatusCard from 'src/components/settings_modal/admin_tabs/admin_status_card.vue' -import BasicUserCard from '../../basic_user_card/basic_user_card.vue' +import { defineAsyncComponent } from 'vue' + +import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue' + +import { useAdminUsersStore } from 'src/stores/adminUsers.js' const AdminCard = { props: { - /** - * minimal user info - * @type {import('vue').PropType<{ - * id: string, - * _original: { - * is_approved: boolean; - * is_confirmed: boolean; - * }; - * }>} - */ - userDetails: { - type: Object, - required: true, - /** - * @param {any} u - * @returns {u is { id: string; _original: { is_approved; is_confirmed: boolean; } } } - */ - validator(u) { - return ( - typeof u.id === 'string' && - typeof u._original === 'object' && - typeof u._original.is_approved === 'boolean' && - typeof u._original.is_confirmed === 'boolean' - ) - }, - }, - }, - data() { - return { - progress: false, - detailsExpanded: false, - topLevelExpanded: false, // REMOVE - jsonExpanded: false, - timelineExpanded: false, - justApproved: false, - justConfirmed: false, - justDeleted: false, - showDirect: false, - showReblogs: false, - timelineSorting: 'des', - } - }, - computed: { - /** - * checks if the user is defined - * @returns {boolean} - */ - isLoaded() { - return typeof this.user !== 'undefined' - }, - /** - * @returns {object} user info - */ - user() { - return this.$store.getters.findUser(this.userDetails.id) - }, - /** - * @returns {object} user relationship - */ - relationship() { - return this.$store.getters.relationship(this.userDetails.id) - }, - /** - * @returns {boolean} is user local - */ - isLocal() { - const u = this.$store.getters.findUser(this.userDetails.id) - if (typeof u !== 'undefined') { - return u.is_local === true - } - return false - }, - /** - * @returns {boolean} is user admin - */ - isAdmin() { - const u = this.$store.getters.findUser(this.userDetails.id) - if (typeof u !== 'undefined') { - return u.rights.admin === true - } - return false - }, - /** - * @returns {boolean} is user moderator - */ - isModerator() { - const u = this.$store.getters.findUser(this.userDetails.id) - if (typeof u !== 'undefined') { - return u.rights.moderator === true - } - return false - }, - /** - * @returns {boolean} is user active - */ - isActivated() { - const u = this.$store.getters.findUser(this.userDetails.id) - if (typeof u !== 'undefined') { - return u.deactivated === false - } - return false - }, - /** - * @returns {boolean} has this user been confirmed - */ - isConfirmed() { - const u = this.$store.getters.findUser(this.userDetails.id) - return u._original.is_confirmed === true || this.justConfirmed === true - }, - /** - * @returns {boolean} has this user been approved - */ - isApproved() { - return ( - this.userDetails._original.is_approved === true || - this.justApproved === true - ) + userId: { + type: String }, }, components: { BasicUserCard, - Checkbox, - List, - AdminStatusCard, - Modal, - Popover, - GenericConfirm, - Select, - TextConfirm, + ModerationTools: defineAsyncComponent( + () => import('src/components/moderation_tools/moderation_tools.vue'), + ), }, - methods: { - /** - * @param {boolean} v set admin status - */ - setAdmin(v) { - const u = this.$store.getters.findUser(this.userDetails.id) - if (v === true) { - this.$store.dispatch('adminAddUserToAdminGroup', u) - } else { - this.$store.dispatch('adminRemoveUserFromAdminGroup', u) - } + computed: { + user() { + return this.$store.getters.findUser(this.userId) }, - /** - * @param {boolean} v set moderator status - */ - setModerator(v) { - const u = this.$store.getters.findUser(this.userDetails.id) - if (v === true) { - this.$store.dispatch('adminAddUserToModeratorGroup', u) - } else { - this.$store.dispatch('adminRemoveUserFromModeratorGroup', u) - } + userAdminData() { + return useAdminUsersStore().getUser(this.userId) }, - /** - * @param {boolean} v set activation status - */ - setActivation(v) { - const u = this.$store.getters.findUser(this.userDetails.id) - if (v === true) { - this.$store.dispatch('adminActivateUser', u) - } else { - this.$store.dispatch('adminDeactivateUser', u) - } + relationship() { + return this.$store.getters.relationship(this.userId) }, - /** - * confirm this user - */ - confirmUser() { - const u = this.$store.getters.findUser(this.userDetails.id) - this.$store.dispatch('adminConfirmUser', u) - this.just_confirmed = true + isLocal() { + return this.user.is_local }, - /** - * try resending the confirmation email - */ - resendConfirmationEmail() { - const u = this.$store.getters.findUser(this.userDetails.id) - this.$store.dispatch('adminResendConfirmationEmail', u) + isAdmin() { + return this.user.rights.admin }, - /** - * approve this user - */ - approveUser() { - const u = this.$store.getters.findUser(this.userDetails.id) - this.$store.dispatch('adminApproveUser', u) + isModerator() { + return this.user.rights.moderator }, - /** - * update user info from server - */ - forceUpdateUser() { - this.$store.dispatch('fetchUser', this.userDetails.id) + isActivated() { + return !this.user.deactivated }, - /** - * delete selected statuses - */ - deleteSelection() { - const l = this.$refs.timelineList - const s = l.getSelected() - s.forEach((p) => this.$store.dispatch('deleteStatus', p)) - l.reset() - }, - /** - * delete this user. keep in mind that user deletion is not intuitive in pleroma backend. - * it actually deletes all content of a user. the user itself will keep showing up in search results. - */ - deleteUser() { - if (!this.justDeleted) { - const u = this.$store.getters.findUser(this.userDetails.id) - this.$store.dispatch('adminDeleteUser', u) - this.justDeleted = true - } - }, - /** - * @param {string} text name of tag to be added to user - */ - addUserTag(text) { - const u = this.$store.getters.findUser(this.userDetails.id) - this.$store - .dispatch('adminTagUser', { user: u, tag: text }) - .then(() => this.$store.dispatch('fetchUser', this.userDetails.id)) - }, - /** - * @param {string} text name of tag to be removed from user - */ - removeUserTag(text) { - const u = this.$store.getters.findUser(this.userDetails.id) - this.$store - .dispatch('adminUntagUser', { user: u, tag: text }) - .then(() => this.$store.dispatch('fetchUser', this.userDetails.id)) - }, - /** - * @param {object} store - * @param {object} opts - * @returns {Promise>} statuses - */ - async fetchStatuses(store, opts) { - const u = this.$store.getters.findUser(this.userDetails.id) - const res = store.dispatch('adminListStatuses', { - user: u, - opts: { - pageSize: opts.pageSize, - godmode: this.showDirect, - withReblogs: this.showReblogs, - }, - }) - return res.then((r) => { - const a = r.activities - console.log(this.timelineSorting) - if (this.timelineSorting === 'des') { - return [...a].sort( - (a, b) => new Date(b.created_at) - new Date(a.created_at), - ) - } else if (this.timelineSorting === 'asc') { - return [...a].sort( - (a, b) => new Date(a.created_at) - new Date(b.created_at), - ) - } else return [] - }) - }, - confirmAction(box) { - this.$refs[box].show() - this.$refs.dropdownuser.hidePopover() - }, - userActionConfirmed(action) { - this.$store.dispatch( - action, - this.$store.getters.findUser(this.userDetails.id), - ) - }, - statusActionConfirmed(action, opts) { - const s = this.$refs.statusList.getSelected() - s.forEach((p) => { - this.$store.dispatch(action, { id: p.id, ...(opts || {}) }) - }) - this.reset() + isApproved() { + return this.userAdminData.is_approved }, + isConfirmed() { + return this.userAdminData.is_confirmed + } }, } diff --git a/src/components/settings_modal/admin_tabs/admin_card.scss b/src/components/settings_modal/admin_tabs/admin_card.scss index b82fb06d7..9ba9a2dd4 100644 --- a/src/components/settings_modal/admin_tabs/admin_card.scss +++ b/src/components/settings_modal/admin_tabs/admin_card.scss @@ -1,19 +1,9 @@ -.inline-layout { - display: flex; - align-items: center; +.AdminCard { width: 100%; - gap: 8px; -} -.alert { - text-shadow: none; -} - -.user-role { - display: inline-block; - vertical-align: baseline; -} - -.modalfix::before { - opacity: 1.0; + .right-side { + align-items: baseline; + justify-content: end; + display: flex; + } } diff --git a/src/components/settings_modal/admin_tabs/admin_card.vue b/src/components/settings_modal/admin_tabs/admin_card.vue index c191e9df1..c2ae295fd 100644 --- a/src/components/settings_modal/admin_tabs/admin_card.vue +++ b/src/components/settings_modal/admin_tabs/admin_card.vue @@ -1,528 +1,56 @@