logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

staff_panel.js (966B)


  1. import map from 'lodash/map'
  2. import groupBy from 'lodash/groupBy'
  3. import { mapGetters, mapState } from 'vuex'
  4. import BasicUserCard from '../basic_user_card/basic_user_card.vue'
  5. const StaffPanel = {
  6. created () {
  7. const nicknames = this.$store.state.instance.staffAccounts
  8. nicknames.forEach(nickname => this.$store.dispatch('fetchUserIfMissing', nickname))
  9. },
  10. components: {
  11. BasicUserCard
  12. },
  13. computed: {
  14. groupedStaffAccounts () {
  15. const staffAccounts = map(this.staffAccounts, this.findUserByName).filter(_ => _)
  16. const groupedStaffAccounts = groupBy(staffAccounts, 'role')
  17. return [
  18. { role: 'admin', users: groupedStaffAccounts.admin },
  19. { role: 'moderator', users: groupedStaffAccounts.moderator }
  20. ].filter(group => group.users)
  21. },
  22. ...mapGetters([
  23. 'findUserByName'
  24. ]),
  25. ...mapState({
  26. staffAccounts: state => state.instance.staffAccounts
  27. })
  28. }
  29. }
  30. export default StaffPanel