pleroma-fe/src/components/staff_panel/staff_panel.js

38 lines
1 KiB
JavaScript
Raw Normal View History

import groupBy from 'lodash/groupBy'
2026-01-06 16:23:17 +02:00
import map from 'lodash/map'
import { mapGetters, mapState } from 'vuex'
2026-01-08 17:26:52 +02:00
2019-11-08 23:21:07 -06:00
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
2026-01-29 20:40:00 +02:00
import { useInstanceStore } from 'src/stores/instance.js'
2019-11-08 23:21:07 -06:00
const StaffPanel = {
2026-01-06 16:22:52 +02:00
created() {
const nicknames = useInstanceStore().staffAccounts
2026-01-06 16:22:52 +02:00
nicknames.forEach((nickname) =>
this.$store.dispatch('fetchUserIfMissing', nickname),
)
},
2019-11-08 23:21:07 -06:00
components: {
2026-01-06 16:22:52 +02:00
BasicUserCard,
2019-11-08 23:21:07 -06:00
},
computed: {
2026-01-06 16:22:52 +02:00
groupedStaffAccounts() {
const staffAccounts = map(this.staffAccounts, this.findUserByName).filter(
(_) => _,
)
const groupedStaffAccounts = groupBy(staffAccounts, 'role')
return [
2022-07-31 12:35:48 +03:00
{ role: 'admin', users: groupedStaffAccounts.admin },
2026-01-06 16:22:52 +02:00
{ role: 'moderator', users: groupedStaffAccounts.moderator },
].filter((group) => group.users)
},
2026-01-06 16:22:52 +02:00
...mapGetters(['findUserByName']),
...mapState({
staffAccounts: (state) => useInstanceStore().staffAccounts,
2026-01-06 16:22:52 +02:00
}),
},
2019-11-08 23:21:07 -06:00
}
export default StaffPanel