logo

pleroma-fe

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

extra_buttons.js (5450B)


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