logo

pleroma-fe

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

user_card.js (6396B)


  1. import UserAvatar from '../user_avatar/user_avatar.vue'
  2. import RemoteFollow from '../remote_follow/remote_follow.vue'
  3. import ProgressButton from '../progress_button/progress_button.vue'
  4. import FollowButton from '../follow_button/follow_button.vue'
  5. import ModerationTools from '../moderation_tools/moderation_tools.vue'
  6. import AccountActions from '../account_actions/account_actions.vue'
  7. import UserNote from '../user_note/user_note.vue'
  8. import Select from '../select/select.vue'
  9. import UserLink from '../user_link/user_link.vue'
  10. import RichContent from 'src/components/rich_content/rich_content.jsx'
  11. import MuteConfirm from '../confirm_modal/mute_confirm.vue'
  12. import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
  13. import { mapGetters } from 'vuex'
  14. import { library } from '@fortawesome/fontawesome-svg-core'
  15. import {
  16. faBell,
  17. faRss,
  18. faSearchPlus,
  19. faExternalLinkAlt,
  20. faEdit,
  21. faTimes,
  22. faExpandAlt
  23. } from '@fortawesome/free-solid-svg-icons'
  24. library.add(
  25. faRss,
  26. faBell,
  27. faSearchPlus,
  28. faExternalLinkAlt,
  29. faEdit,
  30. faTimes,
  31. faExpandAlt
  32. )
  33. export default {
  34. props: [
  35. 'userId',
  36. 'switcher',
  37. 'selected',
  38. 'hideBio',
  39. 'rounded',
  40. 'bordered',
  41. 'avatarAction', // default - open profile, 'zoom' - zoom, function - call function
  42. 'onClose',
  43. 'hasNoteEditor'
  44. ],
  45. data () {
  46. return {
  47. followRequestInProgress: false,
  48. muteExpiryAmount: 0,
  49. muteExpiryUnit: 'minutes'
  50. }
  51. },
  52. created () {
  53. this.$store.dispatch('fetchUserRelationship', this.user.id)
  54. },
  55. computed: {
  56. user () {
  57. return this.$store.getters.findUser(this.userId)
  58. },
  59. relationship () {
  60. return this.$store.getters.relationship(this.userId)
  61. },
  62. classes () {
  63. return [{
  64. '-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius
  65. '-rounded': this.rounded === true, // set border-radius for all sides
  66. '-bordered': this.bordered === true, // set border for all sides
  67. '-popover': !!this.onClose // set popover rounding
  68. }]
  69. },
  70. style () {
  71. return {
  72. backgroundImage: [
  73. 'linear-gradient(to bottom, var(--profileTint), var(--profileTint))',
  74. `url(${this.user.cover_photo})`
  75. ].join(', ')
  76. }
  77. },
  78. isOtherUser () {
  79. return this.user.id !== this.$store.state.users.currentUser.id
  80. },
  81. subscribeUrl () {
  82. // eslint-disable-next-line no-undef
  83. const serverUrl = new URL(this.user.statusnet_profile_url)
  84. return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`
  85. },
  86. loggedIn () {
  87. return this.$store.state.users.currentUser
  88. },
  89. dailyAvg () {
  90. const days = Math.ceil((new Date() - new Date(this.user.created_at)) / (60 * 60 * 24 * 1000))
  91. return Math.round(this.user.statuses_count / days)
  92. },
  93. userHighlightType: {
  94. get () {
  95. const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
  96. return (data && data.type) || 'disabled'
  97. },
  98. set (type) {
  99. const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
  100. if (type !== 'disabled') {
  101. this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type })
  102. } else {
  103. this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: undefined })
  104. }
  105. },
  106. ...mapGetters(['mergedConfig'])
  107. },
  108. userHighlightColor: {
  109. get () {
  110. const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
  111. return data && data.color
  112. },
  113. set (color) {
  114. this.$store.dispatch('setHighlight', { user: this.user.screen_name, color })
  115. }
  116. },
  117. visibleRole () {
  118. const rights = this.user.rights
  119. if (!rights) { return }
  120. const validRole = rights.admin || rights.moderator
  121. const roleTitle = rights.admin ? 'admin' : 'moderator'
  122. return validRole && roleTitle
  123. },
  124. hideFollowsCount () {
  125. return this.isOtherUser && this.user.hide_follows_count
  126. },
  127. hideFollowersCount () {
  128. return this.isOtherUser && this.user.hide_followers_count
  129. },
  130. showModerationMenu () {
  131. const privileges = this.loggedIn.privileges
  132. return this.loggedIn.role === 'admin' || privileges.includes('users_manage_activation_state') || privileges.includes('users_delete') || privileges.includes('users_manage_tags')
  133. },
  134. hasNote () {
  135. return this.relationship.note
  136. },
  137. supportsNote () {
  138. return 'note' in this.relationship
  139. },
  140. ...mapGetters(['mergedConfig'])
  141. },
  142. components: {
  143. UserAvatar,
  144. RemoteFollow,
  145. ModerationTools,
  146. AccountActions,
  147. ProgressButton,
  148. FollowButton,
  149. Select,
  150. RichContent,
  151. UserLink,
  152. UserNote,
  153. MuteConfirm
  154. },
  155. methods: {
  156. muteUser () {
  157. this.$refs.confirmation.optionallyPrompt()
  158. },
  159. unmuteUser () {
  160. this.$store.dispatch('unmuteUser', this.user.id)
  161. },
  162. subscribeUser () {
  163. return this.$store.dispatch('subscribeUser', this.user.id)
  164. },
  165. unsubscribeUser () {
  166. return this.$store.dispatch('unsubscribeUser', this.user.id)
  167. },
  168. setProfileView (v) {
  169. if (this.switcher) {
  170. const store = this.$store
  171. store.commit('setProfileView', { v })
  172. }
  173. },
  174. linkClicked ({ target }) {
  175. if (target.tagName === 'SPAN') {
  176. target = target.parentNode
  177. }
  178. if (target.tagName === 'A') {
  179. window.open(target.href, '_blank')
  180. }
  181. },
  182. userProfileLink (user) {
  183. return generateProfileLink(
  184. user.id, user.screen_name,
  185. this.$store.state.instance.restrictedNicknames
  186. )
  187. },
  188. openProfileTab () {
  189. this.$store.dispatch('openSettingsModalTab', 'profile')
  190. },
  191. zoomAvatar () {
  192. const attachment = {
  193. url: this.user.profile_image_url_original,
  194. mimetype: 'image'
  195. }
  196. this.$store.dispatch('setMedia', [attachment])
  197. this.$store.dispatch('setCurrentMedia', attachment)
  198. },
  199. mentionUser () {
  200. this.$store.dispatch('openPostStatusModal', { profileMention: true, repliedUser: this.user })
  201. },
  202. onAvatarClickHandler (e) {
  203. if (this.onAvatarClick) {
  204. e.preventDefault()
  205. this.onAvatarClick()
  206. }
  207. }
  208. }
  209. }