1
0

PostMenu.vue 7.1 KB

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