PostMenu.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div>
  3. <div v-if="modal != 'true'" class="dropdown">
  4. <button class="btn btn-link text-dark no-caret dropdown-toggle py-0" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  5. <span v-bind:class="[size =='lg' ? 'fas fa-ellipsis-v fa-lg text-muted' : 'fas fa-ellipsis-v fa-sm text-lighter']"></span>
  6. </button>
  7. <div class="dropdown-menu dropdown-menu-right">
  8. <a class="dropdown-item font-weight-bold text-decoration-none" :href="status.url">Go to post</a>
  9. <!-- <a class="dropdown-item font-weight-bold text-decoration-none" href="#">Share</a>
  10. <a class="dropdown-item font-weight-bold text-decoration-none" href="#">Embed</a> -->
  11. <span v-if="activeSession == true && statusOwner(status) == false">
  12. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  13. </span>
  14. <span v-if="activeSession == true && statusOwner(status) == true">
  15. <a class="dropdown-item font-weight-bold text-decoration-none" @click.prevent="muteProfile(status)">Mute Profile</a>
  16. <a class="dropdown-item font-weight-bold text-decoration-none" @click.prevent="blockProfile(status)">Block Profile</a>
  17. </span>
  18. <span v-if="activeSession == true && profile.is_admin == true">
  19. <div class="dropdown-divider"></div>
  20. <a class="dropdown-item font-weight-bold text-danger text-decoration-none" v-on:click="deletePost(status)">Delete</a>
  21. <div class="dropdown-divider"></div>
  22. <h6 class="dropdown-header">Mod Tools</h6>
  23. <a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'autocw')">
  24. <p class="mb-0">Enforce CW</p>
  25. <p class="mb-0 small text-muted">Adds a CW to every post <br> made by this account.</p>
  26. </a>
  27. <a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'noautolink')">
  28. <p class="mb-0">No Autolinking</p>
  29. <p class="mb-0 small text-muted">Do not transform mentions, <br> hashtags or urls into HTML.</p>
  30. </a>
  31. <a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'unlisted')">
  32. <p class="mb-0">Unlisted Posts</p>
  33. <p class="mb-0 small text-muted">Removes account from <br> public/network timelines.</p>
  34. </a>
  35. <a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'disable')">
  36. <p class="mb-0">Disable Account</p>
  37. <p class="mb-0 small text-muted">Temporarily disable account <br> until next time user log in.</p>
  38. </a>
  39. <a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'suspend')">
  40. <p class="mb-0">Suspend Account</p>
  41. <p class="mb-0 small text-muted">This prevents any new interactions, <br> without deleting existing data.</p>
  42. </a>
  43. </span>
  44. </div>
  45. </div>
  46. <div v-if="modal == 'true'">
  47. <span data-toggle="modal" :data-target="'#mt_pid_'+status.id">
  48. <span v-bind:class="[size =='lg' ? 'fas fa-ellipsis-v fa-lg text-muted' : 'fas fa-ellipsis-v fa-sm text-lighter']"></span>
  49. </span>
  50. <div class="modal" tabindex="-1" role="dialog" :id="'mt_pid_'+status.id">
  51. <div class="modal-dialog modal-sm" role="document">
  52. <div class="modal-content">
  53. <div class="modal-body text-center">
  54. <div class="list-group text-dark">
  55. <a class="list-group-item text-dark text-decoration-none" :href="status.url">Go to post</a>
  56. <!-- a class="list-group-item font-weight-bold text-decoration-none" :href="status.url">Share</a>
  57. <a class="list-group-item font-weight-bold text-decoration-none" :href="status.url">Embed</a> -->
  58. <a class="list-group-item text-dark text-decoration-none" href="#" @click="hidePost(status)">Hide</a>
  59. <a v-if="activeSession == true && !statusOwner(status)" class="list-group-item text-dark text-decoration-none" :href="reportUrl(status)">Report</a>
  60. <a v-if="activeSession == true && !statusOwner(status)" class="list-group-item text-dark text-decoration-none" v-on:click="muteProfile(status)" href="#">Mute Profile</a>
  61. <a v-if="activeSession == true && !statusOwner(status)" class="list-group-item text-dark text-decoration-none" v-on:click="blockProfile(status)" href="#">Block Profile</a>
  62. <span v-if="activeSession == true && statusOwner(status) == true || profile.is_admin == true">
  63. <a class="list-group-item text-danger text-decoration-none" v-on:click="deletePost">Delete</a>
  64. </span>
  65. <span v-if="activeSession == true && profile.is_admin == true">
  66. <a class="list-group-item text-dark text-decoration-none" v-on:click="moderatePost(status, 'autocw')" href="#">
  67. <p class="mb-0">Enforce CW</p>
  68. <p class="mb-0 small text-muted">Adds a CW to every post <br> made by this account.</p>
  69. </a>
  70. <a class="list-group-item text-dark text-decoration-none" v-on:click="moderatePost(status, 'noautolink')" href="#">
  71. <p class="mb-0">No Autolinking</p>
  72. <p class="mb-0 small text-muted">Do not transform mentions, <br> hashtags or urls into HTML.</p>
  73. </a>
  74. <a class="list-group-item text-dark text-decoration-none" v-on:click="moderatePost(status, 'unlisted')" href="#">
  75. <p class="mb-0">Unlisted Posts</p>
  76. <p class="mb-0 small text-muted">Removes account from <br> public/network timelines.</p>
  77. </a>
  78. <a class="list-group-item text-dark text-decoration-none" v-on:click="moderatePost(status, 'disable')" href="#">
  79. <p class="mb-0">Disable Account</p>
  80. <p class="mb-0 small text-muted">Temporarily disable account <br> until next time user log in.</p>
  81. </a>
  82. <a class="list-group-item text-dark text-decoration-none" v-on:click="moderatePost(status, 'suspend')" href="#">
  83. <p class="mb-0">Suspend Account</p>
  84. <p class="mb-0 small text-muted">This prevents any new interactions, <br> without deleting existing data.</p>
  85. </a>
  86. </span>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </template>
  95. <style type="text/css" scoped>
  96. .text-lighter {
  97. color:#B8C2CC !important;
  98. }
  99. .modal-body {
  100. padding: 0;
  101. }
  102. </style>
  103. <script type="text/javascript">
  104. export default {
  105. props: ['feed', 'status', 'profile', 'size', 'modal'],
  106. data() {
  107. return {
  108. activeSession: false
  109. };
  110. },
  111. mounted() {
  112. let el = document.querySelector('body');
  113. this.activeSession = el.classList.contains('loggedIn') ? true : false;
  114. },
  115. methods: {
  116. reportUrl(status) {
  117. let type = status.in_reply_to ? 'comment' : 'post';
  118. let id = status.id;
  119. return '/i/report?type=' + type + '&id=' + id;
  120. },
  121. timestampFormat(timestamp) {
  122. let ts = new Date(timestamp);
  123. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  124. },
  125. editUrl(status) {
  126. return status.url + '/edit';
  127. },
  128. redirect(url) {
  129. window.location.href = url;
  130. return;
  131. },
  132. replyUrl(status) {
  133. let username = this.profile.username;
  134. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  135. return '/p/' + username + '/' + id;
  136. },
  137. mentionUrl(status) {
  138. let username = status.account.username;
  139. let id = status.id;
  140. return '/p/' + username + '/' + id;
  141. },
  142. statusOwner(status) {
  143. let sid = parseInt(status.account.id);
  144. let uid = parseInt(this.profile.id);
  145. if(sid == uid) {
  146. return true;
  147. } else {
  148. return false;
  149. }
  150. },
  151. deletePost() {
  152. this.$emit('deletePost');
  153. $('#mt_pid_'+this.status.id).modal('hide');
  154. },
  155. hidePost(status) {
  156. status.sensitive = true;
  157. $('#mt_pid_'+status.id).modal('hide');
  158. },
  159. moderatePost(status, action, $event) {
  160. let username = status.account.username;
  161. switch(action) {
  162. case 'autocw':
  163. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  164. swal({
  165. title: 'Confirm',
  166. text: msg,
  167. icon: 'warning',
  168. buttons: true,
  169. dangerMode: true
  170. });
  171. break;
  172. case 'suspend':
  173. msg = 'Are you sure you want to suspend the account of ' + username + ' ?';
  174. swal({
  175. title: 'Confirm',
  176. text: msg,
  177. icon: 'warning',
  178. buttons: true,
  179. dangerMode: true
  180. });
  181. break;
  182. }
  183. },
  184. muteProfile(status) {
  185. if($('body').hasClass('loggedIn') == false) {
  186. return;
  187. }
  188. axios.post('/i/mute', {
  189. type: 'user',
  190. item: status.account.id
  191. }).then(res => {
  192. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  193. }).catch(err => {
  194. swal('Error', 'Something went wrong. Please try again later.', 'error');
  195. });
  196. },
  197. blockProfile(status) {
  198. if($('body').hasClass('loggedIn') == false) {
  199. return;
  200. }
  201. axios.post('/i/block', {
  202. type: 'user',
  203. item: status.account.id
  204. }).then(res => {
  205. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  206. }).catch(err => {
  207. swal('Error', 'Something went wrong. Please try again later.', 'error');
  208. });
  209. }
  210. }
  211. }
  212. </script>