1
0

PostMenu.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 modal-dialog-centered" role="document">
  52. <div class="modal-content">
  53. <div class="modal-body text-center">
  54. <div class="list-group">
  55. <a class="list-group-item text-dark text-decoration-none" :href="statusUrl(status)">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.prevent="hidePost(status)">Hide</a>
  59. <a v-if="activeSession == true && !statusOwner(status)" class="list-group-item text-danger font-weight-bold text-decoration-none" :href="reportUrl(status)">Report</a>
  60. <div v-if="activeSession == true && statusOwner(status) == true || profile.is_admin == true" class="list-group-item text-danger font-weight-bold cursor-pointer" @click.prevent="deletePost">Delete</div>
  61. <a class="list-group-item text-lighter text-decoration-none" href="#" @click.prevent="closeModal()">Close</a>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <style type="text/css" scoped>
  71. .text-lighter {
  72. color:#B8C2CC !important;
  73. }
  74. .modal-body {
  75. padding: 0;
  76. }
  77. </style>
  78. <script type="text/javascript">
  79. export default {
  80. props: ['feed', 'status', 'profile', 'size', 'modal'],
  81. data() {
  82. return {
  83. activeSession: false
  84. };
  85. },
  86. mounted() {
  87. let el = document.querySelector('body');
  88. this.activeSession = el.classList.contains('loggedIn') ? true : false;
  89. },
  90. methods: {
  91. reportUrl(status) {
  92. let type = status.in_reply_to ? 'comment' : 'post';
  93. let id = status.id;
  94. return '/i/report?type=' + type + '&id=' + id;
  95. },
  96. timestampFormat(timestamp) {
  97. let ts = new Date(timestamp);
  98. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  99. },
  100. editUrl(status) {
  101. return status.url + '/edit';
  102. },
  103. redirect(url) {
  104. window.location.href = url;
  105. return;
  106. },
  107. replyUrl(status) {
  108. let username = this.profile.username;
  109. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  110. return '/p/' + username + '/' + id;
  111. },
  112. mentionUrl(status) {
  113. let username = status.account.username;
  114. let id = status.id;
  115. return '/p/' + username + '/' + id;
  116. },
  117. statusOwner(status) {
  118. let sid = parseInt(status.account.id);
  119. let uid = parseInt(this.profile.id);
  120. if(sid == uid) {
  121. return true;
  122. } else {
  123. return false;
  124. }
  125. },
  126. deletePost() {
  127. this.$emit('deletePost');
  128. $('#mt_pid_'+this.status.id).modal('hide');
  129. },
  130. hidePost(status) {
  131. status.sensitive = true;
  132. $('#mt_pid_'+status.id).modal('hide');
  133. },
  134. moderatePost(status, action, $event) {
  135. let username = status.account.username;
  136. switch(action) {
  137. case 'autocw':
  138. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  139. swal({
  140. title: 'Confirm',
  141. text: msg,
  142. icon: 'warning',
  143. buttons: true,
  144. dangerMode: true
  145. });
  146. break;
  147. case 'suspend':
  148. msg = 'Are you sure you want to suspend the account of ' + username + ' ?';
  149. swal({
  150. title: 'Confirm',
  151. text: msg,
  152. icon: 'warning',
  153. buttons: true,
  154. dangerMode: true
  155. });
  156. break;
  157. }
  158. },
  159. muteProfile(status) {
  160. if($('body').hasClass('loggedIn') == false) {
  161. return;
  162. }
  163. axios.post('/i/mute', {
  164. type: 'user',
  165. item: status.account.id
  166. }).then(res => {
  167. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  168. }).catch(err => {
  169. swal('Error', 'Something went wrong. Please try again later.', 'error');
  170. });
  171. },
  172. blockProfile(status) {
  173. if($('body').hasClass('loggedIn') == false) {
  174. return;
  175. }
  176. axios.post('/i/block', {
  177. type: 'user',
  178. item: status.account.id
  179. }).then(res => {
  180. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  181. }).catch(err => {
  182. swal('Error', 'Something went wrong. Please try again later.', 'error');
  183. });
  184. },
  185. statusUrl(status) {
  186. if(status.local == true) {
  187. return status.url;
  188. }
  189. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  190. },
  191. profileUrl(status) {
  192. if(status.local == true) {
  193. return status.account.url;
  194. }
  195. return '/i/web/profile/_/' + status.account.id;
  196. },
  197. closeModal() {
  198. $('#mt_pid_'+this.status.id).modal('hide');
  199. }
  200. }
  201. }
  202. </script>