logo

pleroma-fe

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

buttons_definitions.js (5933B)


  1. const PRIVATE_SCOPES = new Set(['private', 'direct'])
  2. const PUBLIC_SCOPES = new Set(['public', 'unlisted'])
  3. export const BUTTONS = [{
  4. // =========
  5. // REPLY
  6. // =========
  7. name: 'reply',
  8. label: 'tool_tip.reply',
  9. icon: 'reply',
  10. active: ({ replying }) => replying,
  11. counter: ({ status }) => status.replies_count,
  12. anon: true,
  13. anonLink: true,
  14. toggleable: true,
  15. closeIndicator: 'times',
  16. activeIndicator: 'none',
  17. action ({ emit }) {
  18. emit('toggleReplying')
  19. return Promise.resolve()
  20. }
  21. }, {
  22. // =========
  23. // REPEAT
  24. // =========
  25. name: 'retweet',
  26. label: ({ status }) => status.repeated
  27. ? 'tool_tip.unrepeat'
  28. : 'tool_tip.repeat',
  29. icon ({ status }) {
  30. if (PRIVATE_SCOPES.has(status.visibility)) {
  31. return 'lock'
  32. }
  33. return 'retweet'
  34. },
  35. animated: true,
  36. active: ({ status }) => status.repeated,
  37. counter: ({ status }) => status.repeat_num,
  38. anonLink: true,
  39. interactive: ({ status, loggedIn }) => loggedIn && !PRIVATE_SCOPES.has(status.visibility),
  40. toggleable: true,
  41. confirm: ({ status, getters }) => !status.repeated && getters.mergedConfig.modalOnRepeat,
  42. confirmStrings: {
  43. title: 'status.repeat_confirm_title',
  44. body: 'status.repeat_confirm',
  45. confirm: 'status.repeat_confirm_accept_button',
  46. cancel: 'status.repeat_confirm_cancel_button'
  47. },
  48. action ({ status, dispatch }) {
  49. if (!status.repeated) {
  50. return dispatch('retweet', { id: status.id })
  51. } else {
  52. return dispatch('unretweet', { id: status.id })
  53. }
  54. }
  55. }, {
  56. // =========
  57. // FAVORITE
  58. // =========
  59. name: 'favorite',
  60. label: ({ status }) => status.favorited
  61. ? 'tool_tip.unfavorite'
  62. : 'tool_tip.favorite',
  63. icon: ({ status }) => status.favorited
  64. ? ['fas', 'star']
  65. : ['far', 'star'],
  66. animated: true,
  67. active: ({ status }) => status.favorited,
  68. counter: ({ status }) => status.fave_num,
  69. anonLink: true,
  70. toggleable: true,
  71. action ({ status, dispatch }) {
  72. if (!status.favorited) {
  73. return dispatch('favorite', { id: status.id })
  74. } else {
  75. return dispatch('unfavorite', { id: status.id })
  76. }
  77. }
  78. }, {
  79. // =========
  80. // EMOJI REACTIONS
  81. // =========
  82. name: 'emoji',
  83. label: 'tool_tip.add_reaction',
  84. icon: ['far', 'smile-beam'],
  85. anonLink: true
  86. }, {
  87. // =========
  88. // MUTE
  89. // =========
  90. name: 'mute',
  91. icon: 'eye-slash',
  92. label: 'status.mute_ellipsis',
  93. if: ({ loggedIn }) => loggedIn,
  94. toggleable: true,
  95. dropdown: true
  96. // action ({ status, dispatch, emit }) {
  97. // }
  98. }, {
  99. // =========
  100. // PIN STATUS
  101. // =========
  102. name: 'pin',
  103. icon: 'thumbtack',
  104. label: ({ status }) => status.pinned
  105. ? 'status.unpin'
  106. : 'status.pin',
  107. if ({ status, loggedIn, currentUser }) {
  108. return loggedIn &&
  109. status.user.id === currentUser.id &&
  110. PUBLIC_SCOPES.has(status.visibility)
  111. },
  112. action ({ status, dispatch, emit }) {
  113. if (status.pinned) {
  114. return dispatch('unpinStatus', { id: status.id })
  115. } else {
  116. return dispatch('pinStatus', { id: status.id })
  117. }
  118. }
  119. }, {
  120. // =========
  121. // BOOKMARK
  122. // =========
  123. name: 'bookmark',
  124. icon: ({ status }) => status.bookmarked
  125. ? ['fas', 'bookmark']
  126. : ['far', 'bookmark'],
  127. toggleable: true,
  128. active: ({ status }) => status.bookmarked,
  129. label: ({ status }) => status.bookmarked
  130. ? 'status.unbookmark'
  131. : 'status.bookmark',
  132. if: ({ loggedIn }) => loggedIn,
  133. action ({ status, dispatch, emit }) {
  134. if (status.bookmarked) {
  135. return dispatch('unbookmark', { id: status.id })
  136. } else {
  137. return dispatch('bookmark', { id: status.id })
  138. }
  139. }
  140. }, {
  141. // =========
  142. // EDIT
  143. // =========
  144. name: 'edit',
  145. icon: 'pen',
  146. label: 'status.edit',
  147. if ({ status, loggedIn, currentUser, state }) {
  148. return loggedIn &&
  149. state.instance.editingAvailable &&
  150. status.user.id === currentUser.id
  151. },
  152. action ({ dispatch, status }) {
  153. return dispatch('fetchStatusSource', { id: status.id })
  154. .then(data => dispatch('openEditStatusModal', {
  155. statusId: status.id,
  156. subject: data.spoiler_text,
  157. statusText: data.text,
  158. statusIsSensitive: status.nsfw,
  159. statusPoll: status.poll,
  160. statusFiles: [...status.attachments],
  161. visibility: status.visibility,
  162. statusContentType: data.content_type
  163. }))
  164. }
  165. }, {
  166. // =========
  167. // DELETE
  168. // =========
  169. name: 'delete',
  170. icon: 'times',
  171. label: 'status.delete',
  172. if ({ status, loggedIn, currentUser }) {
  173. return loggedIn && (
  174. status.user.id === currentUser.id ||
  175. currentUser.privileges.includes('messages_delete')
  176. )
  177. },
  178. confirm: ({ status, getters }) => getters.mergedConfig.modalOnDelete,
  179. confirmStrings: {
  180. title: 'status.delete_confirm_title',
  181. body: 'status.delete_confirm',
  182. confirm: 'status.delete_confirm_accept_button',
  183. cancel: 'status.delete_confirm_cancel_button'
  184. },
  185. action ({ dispatch, status }) {
  186. return dispatch('deleteStatus', { id: status.id })
  187. }
  188. }, {
  189. // =========
  190. // SHARE/COPY
  191. // =========
  192. name: 'share',
  193. icon: 'share-alt',
  194. label: 'status.copy_link',
  195. action ({ state, status, router }) {
  196. navigator.clipboard.writeText([
  197. state.instance.server,
  198. router.resolve({ name: 'conversation', params: { id: status.id } }).href
  199. ].join(''))
  200. return Promise.resolve()
  201. }
  202. }, {
  203. // =========
  204. // EXTERNAL
  205. // =========
  206. name: 'external',
  207. icon: 'external-link-alt',
  208. label: 'status.external_source',
  209. link: ({ status }) => status.external_url
  210. }, {
  211. // =========
  212. // REPORT
  213. // =========
  214. name: 'report',
  215. icon: 'flag',
  216. label: 'user_card.report',
  217. if: ({ loggedIn }) => loggedIn,
  218. action ({ dispatch, status }) {
  219. dispatch('openUserReportingModal', { userId: status.user.id, statusIds: [status.id] })
  220. }
  221. }].map(button => {
  222. return Object.fromEntries(
  223. Object.entries(button).map(([k, v]) => [
  224. k,
  225. (typeof v === 'function' || k === 'name') ? v : () => v
  226. ])
  227. )
  228. })