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

35 lines
994 B
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'
2019-11-08 23:21:07 -06:00
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
const StaffPanel = {
2026-01-06 16:22:52 +02:00
created() {
const nicknames = this.$store.state.instance.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({
2026-01-06 16:22:52 +02:00
staffAccounts: (state) => state.instance.staffAccounts,
}),
},
2019-11-08 23:21:07 -06:00
}
export default StaffPanel