logo

pleroma-fe

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

extra_buttons.js (5214B)


  1. import Popover from '../popover/popover.vue'
  2. import genRandomSeed from '../../services/random_seed/random_seed.service.js'
  3. import ConfirmModal from '../confirm_modal/confirm_modal.vue'
  4. import { library } from '@fortawesome/fontawesome-svg-core'
  5. import {
  6. faEllipsisH,
  7. faBookmark,
  8. faEyeSlash,
  9. faThumbtack,
  10. faShareAlt,
  11. faExternalLinkAlt,
  12. faHistory,
  13. faPlus,
  14. faTimes
  15. } from '@fortawesome/free-solid-svg-icons'
  16. import {
  17. faBookmark as faBookmarkReg,
  18. faFlag
  19. } from '@fortawesome/free-regular-svg-icons'
  20. library.add(
  21. faEllipsisH,
  22. faBookmark,
  23. faBookmarkReg,
  24. faEyeSlash,
  25. faThumbtack,
  26. faShareAlt,
  27. faExternalLinkAlt,
  28. faFlag,
  29. faHistory,
  30. faPlus,
  31. faTimes
  32. )
  33. const ExtraButtons = {
  34. props: ['status'],
  35. components: {
  36. Popover,
  37. ConfirmModal
  38. },
  39. data () {
  40. return {
  41. expanded: false,
  42. showingDeleteDialog: false,
  43. randomSeed: genRandomSeed()
  44. }
  45. },
  46. methods: {
  47. onShow () {
  48. this.expanded = true
  49. },
  50. onClose () {
  51. this.expanded = false
  52. },
  53. deleteStatus () {
  54. if (this.shouldConfirmDelete) {
  55. this.showDeleteStatusConfirmDialog()
  56. } else {
  57. this.doDeleteStatus()
  58. }
  59. },
  60. doDeleteStatus () {
  61. this.$store.dispatch('deleteStatus', { id: this.status.id })
  62. this.hideDeleteStatusConfirmDialog()
  63. },
  64. showDeleteStatusConfirmDialog () {
  65. this.showingDeleteDialog = true
  66. },
  67. hideDeleteStatusConfirmDialog () {
  68. this.showingDeleteDialog = false
  69. },
  70. pinStatus () {
  71. this.$store.dispatch('pinStatus', this.status.id)
  72. .then(() => this.$emit('onSuccess'))
  73. .catch(err => this.$emit('onError', err.error.error))
  74. },
  75. unpinStatus () {
  76. this.$store.dispatch('unpinStatus', this.status.id)
  77. .then(() => this.$emit('onSuccess'))
  78. .catch(err => this.$emit('onError', err.error.error))
  79. },
  80. muteConversation () {
  81. this.$store.dispatch('muteConversation', this.status.id)
  82. .then(() => this.$emit('onSuccess'))
  83. .catch(err => this.$emit('onError', err.error.error))
  84. },
  85. unmuteConversation () {
  86. this.$store.dispatch('unmuteConversation', this.status.id)
  87. .then(() => this.$emit('onSuccess'))
  88. .catch(err => this.$emit('onError', err.error.error))
  89. },
  90. copyLink () {
  91. navigator.clipboard.writeText(this.statusLink)
  92. .then(() => this.$emit('onSuccess'))
  93. .catch(err => this.$emit('onError', err.error.error))
  94. },
  95. bookmarkStatus () {
  96. this.$store.dispatch('bookmark', { id: this.status.id })
  97. .then(() => this.$emit('onSuccess'))
  98. .catch(err => this.$emit('onError', err.error.error))
  99. },
  100. unbookmarkStatus () {
  101. this.$store.dispatch('unbookmark', { id: this.status.id })
  102. .then(() => this.$emit('onSuccess'))
  103. .catch(err => this.$emit('onError', err.error.error))
  104. },
  105. reportStatus () {
  106. this.$store.dispatch('openUserReportingModal', { userId: this.status.user.id, statusIds: [this.status.id] })
  107. },
  108. editStatus () {
  109. this.$store.dispatch('fetchStatusSource', { id: this.status.id })
  110. .then(data => this.$store.dispatch('openEditStatusModal', {
  111. statusId: this.status.id,
  112. subject: data.spoiler_text,
  113. statusText: data.text,
  114. statusIsSensitive: this.status.nsfw,
  115. statusPoll: this.status.poll,
  116. statusFiles: [...this.status.attachments],
  117. visibility: this.status.visibility,
  118. statusContentType: data.content_type
  119. }))
  120. },
  121. showStatusHistory () {
  122. const originalStatus = { ...this.status }
  123. const stripFieldsList = ['attachments', 'created_at', 'emojis', 'text', 'raw_html', 'nsfw', 'poll', 'summary', 'summary_raw_html']
  124. stripFieldsList.forEach(p => delete originalStatus[p])
  125. this.$store.dispatch('openStatusHistoryModal', originalStatus)
  126. }
  127. },
  128. computed: {
  129. currentUser () { return this.$store.state.users.currentUser },
  130. canDelete () {
  131. if (!this.currentUser) { return }
  132. return this.currentUser.privileges.includes('messages_delete') || this.status.user.id === this.currentUser.id
  133. },
  134. ownStatus () {
  135. return this.status.user.id === this.currentUser.id
  136. },
  137. canPin () {
  138. return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
  139. },
  140. canMute () {
  141. return !!this.currentUser
  142. },
  143. canBookmark () {
  144. return !!this.currentUser
  145. },
  146. statusLink () {
  147. return `${this.$store.state.instance.server}${this.$router.resolve({ name: 'conversation', params: { id: this.status.id } }).href}`
  148. },
  149. isEdited () {
  150. return this.status.edited_at !== null
  151. },
  152. editingAvailable () { return this.$store.state.instance.editingAvailable },
  153. shouldConfirmDelete () {
  154. return this.$store.getters.mergedConfig.modalOnDelete
  155. },
  156. triggerAttrs () {
  157. return {
  158. title: this.$t('status.more_actions'),
  159. id: `popup-trigger-${this.randomSeed}`,
  160. 'aria-controls': `popup-menu-${this.randomSeed}`,
  161. 'aria-expanded': this.expanded,
  162. 'aria-haspopup': 'menu'
  163. }
  164. }
  165. }
  166. }
  167. export default ExtraButtons