PostMenu.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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="statusOwner(status) == false">
  12. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  13. </span>
  14. <span v-if="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="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="!statusOwner(status)" class="list-group-item text-dark text-decoration-none" :href="reportUrl(status)">Report</a>
  60. <a v-if="!statusOwner(status)" class="list-group-item text-dark text-decoration-none" v-on:click="muteProfile(status)" href="#">Mute Profile</a>
  61. <a v-if="!statusOwner(status)" class="list-group-item text-dark text-decoration-none" v-on:click="blockProfile(status)" href="#">Block Profile</a>
  62. <span v-if="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="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. methods: {
  107. reportUrl(status) {
  108. let type = status.in_reply_to ? 'comment' : 'post';
  109. let id = status.id;
  110. return '/i/report?type=' + type + '&id=' + id;
  111. },
  112. timestampFormat(timestamp) {
  113. let ts = new Date(timestamp);
  114. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  115. },
  116. editUrl(status) {
  117. return status.url + '/edit';
  118. },
  119. redirect(url) {
  120. window.location.href = url;
  121. return;
  122. },
  123. replyUrl(status) {
  124. let username = this.profile.username;
  125. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  126. return '/p/' + username + '/' + id;
  127. },
  128. mentionUrl(status) {
  129. let username = status.account.username;
  130. let id = status.id;
  131. return '/p/' + username + '/' + id;
  132. },
  133. statusOwner(status) {
  134. let sid = parseInt(status.account.id);
  135. let uid = parseInt(this.profile.id);
  136. if(sid == uid) {
  137. return true;
  138. } else {
  139. return false;
  140. }
  141. },
  142. deletePost() {
  143. this.$emit('deletePost');
  144. $('#mt_pid_'+this.status.id).modal('hide');
  145. },
  146. hidePost(status) {
  147. status.sensitive = true;
  148. $('#mt_pid_'+status.id).modal('hide');
  149. },
  150. moderatePost(status, action, $event) {
  151. let username = status.account.username;
  152. switch(action) {
  153. case 'autocw':
  154. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  155. swal({
  156. title: 'Confirm',
  157. text: msg,
  158. icon: 'warning',
  159. buttons: true,
  160. dangerMode: true
  161. });
  162. break;
  163. case 'suspend':
  164. msg = 'Are you sure you want to suspend the account of ' + username + ' ?';
  165. swal({
  166. title: 'Confirm',
  167. text: msg,
  168. icon: 'warning',
  169. buttons: true,
  170. dangerMode: true
  171. });
  172. break;
  173. }
  174. },
  175. muteProfile(status) {
  176. if($('body').hasClass('loggedIn') == false) {
  177. return;
  178. }
  179. axios.post('/i/mute', {
  180. type: 'user',
  181. item: status.account.id
  182. }).then(res => {
  183. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  184. }).catch(err => {
  185. swal('Error', 'Something went wrong. Please try again later.', 'error');
  186. });
  187. },
  188. blockProfile(status) {
  189. if($('body').hasClass('loggedIn') == false) {
  190. return;
  191. }
  192. axios.post('/i/block', {
  193. type: 'user',
  194. item: status.account.id
  195. }).then(res => {
  196. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  197. }).catch(err => {
  198. swal('Error', 'Something went wrong. Please try again later.', 'error');
  199. });
  200. }
  201. }
  202. }
  203. </script>