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 (6525B)


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