From d491bccec47f0788ecfa45eafbac021adfb9cc75 Mon Sep 17 00:00:00 2001 From: luce Date: Sun, 27 Jul 2025 22:40:21 +0200 Subject: [PATCH] using snake case now, cleaned up some code and style --- src/components/page_list/page_list.js | 26 +- src/components/page_list/page_list.vue | 6 +- .../settings_modal/admin_tabs/admin_card.js | 36 +-- .../settings_modal/admin_tabs/admin_card.vue | 273 +++++++++--------- .../admin_tabs/admin_status_card.js | 14 +- .../admin_tabs/admin_status_card.vue | 16 +- .../settings_modal/admin_tabs/users_tab.js | 266 ++++++++--------- .../settings_modal/admin_tabs/users_tab.scss | 7 + .../settings_modal/admin_tabs/users_tab.vue | 50 ++-- src/i18n/en.json | 8 +- src/services/api/api.service.js | 4 +- 11 files changed, 354 insertions(+), 352 deletions(-) diff --git a/src/components/page_list/page_list.js b/src/components/page_list/page_list.js index 830d2bfb2..7e96473c4 100644 --- a/src/components/page_list/page_list.js +++ b/src/components/page_list/page_list.js @@ -5,44 +5,44 @@ const PageList = { SelectableList }, props: { - boxOnly: { + box_only: { type: Boolean, default: false }, - pageSize: { + page_size: { type: Number, default: 50 }, - fetchPage: { + fetch_page: { type: Function, default: async () => [] }, - singlePage: { + single_page: { type: Boolean, default: false } }, data () { return { - pageIndex: 1, + page_index: 1, items: [], - canLoadMore: true, + can_load_more: true, gliter: 0, } }, methods: { reset () { - this.canLoadMore = true - this.pageIndex = 1 + this.can_load_more = true + this.page_index = 1 this.items = [] - this.loadMore() // load one page + this.load_more() // load one page }, - loadMore () { + load_more () { this.gliter++ const iter = this.gliter - this.fetchPage(this.$store, { - page: this.pageIndex++, - pageSize: this.pageSize + this.fetch_page(this.$store, { + page: this.page_index++, + page_size: this.page_size }).then((items) => { // ignore if another request was already dispatched if (iter == this.gliter) { diff --git a/src/components/page_list/page_list.vue b/src/components/page_list/page_list.vue index b6a4b6951..8df121955 100644 --- a/src/components/page_list/page_list.vue +++ b/src/components/page_list/page_list.vue @@ -19,12 +19,12 @@ /> -
+
diff --git a/src/components/settings_modal/admin_tabs/admin_card.js b/src/components/settings_modal/admin_tabs/admin_card.js index 00522da76..de736de1d 100644 --- a/src/components/settings_modal/admin_tabs/admin_card.js +++ b/src/components/settings_modal/admin_tabs/admin_card.js @@ -4,7 +4,7 @@ import PageList from 'src/components/page_list/page_list.vue' import AdminStatusCard from 'src/components/settings_modal/admin_tabs/admin_status_card.vue' const AdminCard = { - props: ['userDetails'], + props: ['user_details'], data () { return { progress: false, @@ -21,45 +21,45 @@ const AdminCard = { return typeof(this.user) !== 'undefined' }, user () { - return this.$store.getters.findUser(this.userDetails.id) + return this.$store.getters.findUser(this.user_details.id) }, relationship () { - return this.$store.getters.relationship(this.userDetails.id) + return this.$store.getters.relationship(this.user_details.id) }, is_local () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (typeof(u) !== 'undefined') { return u.is_local === true } return false }, is_admin () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (typeof(u) !== 'undefined') { return u.rights.admin === true } return false }, is_moderator () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (typeof(u) !== 'undefined') { return u.rights.moderator === true } return false }, is_activated () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (typeof(u) !== 'undefined') { return u.deactivated === false } return false }, is_confirmed () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) return (u._original.pleroma.is_confirmed === true) || (this.just_confirmed === true) }, is_approved () { - return (this.userDetails._original.is_approved === true) || (this.just_approved === true) + return (this.user_details._original.is_approved === true) || (this.just_approved === true) } }, components: { @@ -70,7 +70,7 @@ const AdminCard = { }, methods: { toggle_admin (v) { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (v === true) { this.$store.dispatch('adminAddUserToAdminGroup', u) } else { @@ -78,7 +78,7 @@ const AdminCard = { } }, toggle_moderator (v) { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (v === true) { this.$store.dispatch('adminAddUserToModeratorGroup', u) } else { @@ -86,7 +86,7 @@ const AdminCard = { } }, toggle_activation (v) { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) if (v === true) { this.$store.dispatch('adminActivateUser', u) } else { @@ -94,30 +94,30 @@ const AdminCard = { } }, confirm_user () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) this.$store.dispatch('adminConfirmUser', u) this.just_confirmed = true }, resend_confirmation_email () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) this.$store.dispatch('adminResendConfirmationEmail', u) }, toggle_approval () { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) this.$store.dispatch('adminApproveUser', u) }, force_update_user () { - this.$store.dispatch('fetchUser', this.userDetails.id) + this.$store.dispatch('fetchUser', this.user_details.id) }, delete_user () { if (!this.just_deleted) { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) this.$store.dispatch('adminDeleteUser', u) this.just_deleted = true } }, fetch_statuses (store, opts) { - const u = this.$store.getters.findUser(this.userDetails.id) + const u = this.$store.getters.findUser(this.user_details.id) const res = store.dispatch('adminListStatuses', { user: u, opts: { page_size: opts.pageSize, godmode: true, with_reblogs: true}}) return Promise.resolve(res.then(r => r.activities)) } diff --git a/src/components/settings_modal/admin_tabs/admin_card.vue b/src/components/settings_modal/admin_tabs/admin_card.vue index 627296700..f0246cdd0 100644 --- a/src/components/settings_modal/admin_tabs/admin_card.vue +++ b/src/components/settings_modal/admin_tabs/admin_card.vue @@ -1,145 +1,144 @@ - diff --git a/src/components/settings_modal/admin_tabs/admin_status_card.js b/src/components/settings_modal/admin_tabs/admin_status_card.js index 312fe0232..0ea042782 100644 --- a/src/components/settings_modal/admin_tabs/admin_status_card.js +++ b/src/components/settings_modal/admin_tabs/admin_status_card.js @@ -4,27 +4,27 @@ import StatusBody from 'src/components/status_body/status_body.vue' import { parseStatus } from 'src/services/entity_normalizer/entity_normalizer.service.js' const AdminStatusCard = { - props: ['statusDetails'], + props: ['status_details'], data () { return { json_expanded: false, - statusCache: undefined, + status_cache: undefined, } }, computed: { is_sensitive () { - return this.statusDetails.sensitive === true + return this.status_details.sensitive === true }, visibility () { - return this.statusDetails.visibility + return this.status_details.visibility } }, methods: { change_sensitivity (v) { - this.$store.dispatch('adminChangeStatusScope', { opts: { id: this.statusDetails.id, sensitive: v }}).then(res => parseStatus(res)).then(p => p).then(s => this.statusCache = s) + this.$store.dispatch('adminChangeStatusScope', { opts: { id: this.status_details.id, sensitive: v }}).then(res => parseStatus(res)).then(s => this.status_cache = s) }, change_visibility (v) { - this.$store.dispatch('adminChangeStatusScope', { opts: { id: this.statusDetails.id, visibility: v }}).then(res => parseStatus(res)).then(p => p).then(s => this.statusCache = s) + this.$store.dispatch('adminChangeStatusScope', { opts: { id: this.status_details.id, visibility: v }}).then(res => parseStatus(res)).then(s => this.status_cache = s) } }, components: { @@ -33,7 +33,7 @@ const AdminStatusCard = { StatusBody, }, mounted () { - this.$store.dispatch('adminChangeStatusScope', { opts: { id: this.statusDetails.id }}).then(res => parseStatus(res)).then(p => p).then(s => this.statusCache = s) + this.$store.dispatch('adminChangeStatusScope', { opts: { id: this.status_details.id }}).then(res => parseStatus(res)).then(s => this.status_cache = s) } } diff --git a/src/components/settings_modal/admin_tabs/admin_status_card.vue b/src/components/settings_modal/admin_tabs/admin_status_card.vue index 98365b41d..f969b32db 100644 --- a/src/components/settings_modal/admin_tabs/admin_status_card.vue +++ b/src/components/settings_modal/admin_tabs/admin_status_card.vue @@ -1,14 +1,14 @@ diff --git a/src/components/settings_modal/admin_tabs/users_tab.js b/src/components/settings_modal/admin_tabs/users_tab.js index 48a81b2fb..a3d43468d 100644 --- a/src/components/settings_modal/admin_tabs/users_tab.js +++ b/src/components/settings_modal/admin_tabs/users_tab.js @@ -7,147 +7,137 @@ import PageList from 'src/components/page_list/page_list.vue' import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx' const UsersTab = { - provide () { - return { - defaultDraftMode: true, - defaultSource: 'admin' + provide () { + return { + defaultDraftMode: true, + defaultSource: 'admin' + } + }, + data() { + return { + /* filters must match the filter options below initially, or the ui is gonna have a computer moment + * no, i won't fix this + * */ + filters_origin: 'local', + filters_activity: 'all', + filters_permission: 'all', + filters_query: '', + filters_name: '', + filters_email: '', + filters: { + local: false, + external: false, + active: false, + need_approval: false, + unconfirmed: false, + deactivated: false, + is_admin: false, + is_moderator: false, + }, + expandedUser: null, + loading: false + } + }, + components: { + Checkbox, + Select, + BasicUserCard, + PageList, + ProgressButton, + AdminCard, + TabSwitcher, + }, + methods: { + update_origin (v) { + switch (v) { + case 'local': + this.filters.local = true + this.filters.external = false + break; + case 'external': + this.filters.local = false + this.filters.external = true + break; + default: + case 'all': + this.filters.local = false + this.filters.external = false + break; } - }, - data() { - return { - /* filters must match the filter options below initially, or the ui is gonna have a computer moment - * no, i won't fix this - * */ - filters_origin: "all", - filters_activity: "all", - filters_permission: "all", - filters_query: "", - filters_name: "", - filters_email: "", - filters: { - local: false, - external: false, - active: false, - need_approval: false, - unconfirmed: false, - deactivated: false, - is_admin: false, - is_moderator: false, - }, - expandedUser: null, - loading: false + this.reset() + }, + update_activity (v) { + switch (v) { + case 'active': + this.filters.active = true + this.filters.deactivated = false + break; + case 'deactivated': + this.filters.active = false + this.filters.deactivated = true + break; + default: + case 'all': + this.filters.active = false + this.filters.deactivated = false + break; } - }, - components: { - Checkbox, - Select, - BasicUserCard, - PageList, - ProgressButton, - AdminCard, - TabSwitcher, - }, - methods: { - update_origin (v) { - switch (v) { - case 'local': - this.filters.local = true - this.filters.external = false - break; - case 'external': - this.filters.local = false - this.filters.external = true - break; - default: - case 'all': - this.filters.local = false - this.filters.external = false - break; - } - this.reset() - }, - update_activity (v) { - switch (v) { - case 'active': - this.filters.active = true - this.filters.deactivated = false - break; - case 'deactivated': - this.filters.active = false - this.filters.deactivated = true - break; - default: - case 'all': - this.filters.active = false - this.filters.deactivated = false - break; - } - this.reset() - }, - update_permission (v) { - switch (v) { - case 'admin': - this.filters.is_admin = true - this.filters.is_moderator = false - break; - case 'moderator': - this.filters.is_admin = false - this.filters.is_moderator = true - break; - case 'modsnadmins': - this.filters.is_admin = true - this.filters.is_moderator = true - break; - default: - case 'all': - this.filters.is_admin = false - this.filters.is_moderator = false - break; - } - this.reset() - }, - update_query (v) { - this.filters_query = v - this.reset() - }, - update_name (v) { - this.filters_name = v - this.reset() - }, - update_email (v) { - this.filters_email = v - this.reset() - }, - delete_user () {}, - fetch_page (store, opts) { - opts.query = this.filters_query - opts.filters = this.filters - opts.name = this.filters_name - opts.email = this.filters_email - const users = store.dispatch('fetchAdminUsers', opts) - return users - }, - reset () { - this.$refs.userList.reset() - }, - toggleLocal () { - this.filters.local = !this.filters.local - this.reset() - }, - activate_selection () { - const s = this.$refs.userList.selected() - s.forEach(u => this.$store.dispatch('adminActivateUser', this.$store.getters.findUser(u.id))) - }, - deactivate_selection () { - const s = this.$refs.userList.selected() - s.forEach(u => this.$store.dispatch('adminDeactivateUser', this.$store.getters.findUser(u.id))) - }, - delete_selection () { - const s = this.$refs.userList.selected() - s.forEach(u => this.$store.dispatch('adminDeleteUser', this.$store.getters.findUser(u.id))) - this.reset() + this.reset() + }, + update_permission (v) { + switch (v) { + case 'admin': + this.filters.is_admin = true + this.filters.is_moderator = false + break; + case 'moderator': + this.filters.is_admin = false + this.filters.is_moderator = true + break; + case 'modsnadmins': + this.filters.is_admin = true + this.filters.is_moderator = true + break; + default: + case 'all': + this.filters.is_admin = false + this.filters.is_moderator = false + break; } - } + this.reset() + }, + fetch_page (store, opts) { + const users = store.dispatch('fetchAdminUsers', { ...opts, ...{ + query: this.filters_query, + filters: this.filters, + name: this.filters_name, + email: this.filters_email + }}) + return users + }, + reset () { + this.$refs.userList.reset() + }, + activate_selection () { + const s = this.$refs.userList.selected() + s.forEach(u => this.$store.dispatch('adminActivateUser', this.$store.getters.findUser(u.id))) + }, + deactivate_selection () { + const s = this.$refs.userList.selected() + s.forEach(u => this.$store.dispatch('adminDeactivateUser', this.$store.getters.findUser(u.id))) + }, + delete_selection () { + const s = this.$refs.userList.selected() + s.forEach(u => this.$store.dispatch('adminDeleteUser', this.$store.getters.findUser(u.id))) + this.reset() + } + }, + mounted () { + /* make sure init state is correct */ + this.update_origin(this.filters_origin) + this.update_activity(this.filters_activity) + this.update_permission(this.filters_permission) + } } export default UsersTab diff --git a/src/components/settings_modal/admin_tabs/users_tab.scss b/src/components/settings_modal/admin_tabs/users_tab.scss index a42308167..d9fa70d1b 100644 --- a/src/components/settings_modal/admin_tabs/users_tab.scss +++ b/src/components/settings_modal/admin_tabs/users_tab.scss @@ -1,3 +1,10 @@ .user-tab { height: 100%; } + +.stacked-container { + /* vite:stylelint complains about this, saying it's not important. + this is a mistake: it is important, so vite:stylelint should shut up */ + display: flex !important; + flex-direction: column; +} diff --git a/src/components/settings_modal/admin_tabs/users_tab.vue b/src/components/settings_modal/admin_tabs/users_tab.vue index e1a3d026e..308680c50 100644 --- a/src/components/settings_modal/admin_tabs/users_tab.vue +++ b/src/components/settings_modal/admin_tabs/users_tab.vue @@ -2,24 +2,28 @@

filter user search

-
-
-
+
+ + + +