PostMenu.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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" v-on:click="muteProfile(status)">Mute Profile</a>
  16. <a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="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">
  54. <div class="list-group">
  55. <a class="list-group-item font-weight-bold 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 font-weight-bold text-decoration-none" href="#" @click="hidePost(status)">Hide</a>
  59. <span v-if="statusOwner(status) == false">
  60. <a class="list-group-item font-weight-bold text-decoration-none" :href="reportUrl(status)">Report</a>
  61. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="muteProfile(status)" href="#">Mute Profile</a>
  62. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="blockProfile(status)" href="#">Block Profile</a>
  63. </span>
  64. <span v-if="statusOwner(status) == true || profile.is_admin == true">
  65. <a class="list-group-item font-weight-bold text-danger text-decoration-none" v-on:click="deletePost">Delete</a>
  66. </span>
  67. <span v-if="profile.is_admin == true">
  68. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'autocw')" href="#">
  69. <p class="mb-0">Enforce CW</p>
  70. <p class="mb-0 small text-muted">Adds a CW to every post <br> made by this account.</p>
  71. </a>
  72. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'noautolink')" href="#">
  73. <p class="mb-0">No Autolinking</p>
  74. <p class="mb-0 small text-muted">Do not transform mentions, <br> hashtags or urls into HTML.</p>
  75. </a>
  76. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'unlisted')" href="#">
  77. <p class="mb-0">Unlisted Posts</p>
  78. <p class="mb-0 small text-muted">Removes account from <br> public/network timelines.</p>
  79. </a>
  80. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'disable')" href="#">
  81. <p class="mb-0">Disable Account</p>
  82. <p class="mb-0 small text-muted">Temporarily disable account <br> until next time user log in.</p>
  83. </a>
  84. <a class="list-group-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'suspend')" href="#">
  85. <p class="mb-0">Suspend Account</p>
  86. <p class="mb-0 small text-muted">This prevents any new interactions, <br> without deleting existing data.</p>
  87. </a>
  88. </span>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </template>
  97. <style type="text/css" scoped>
  98. .text-lighter {
  99. color:#B8C2CC !important;
  100. }
  101. .modal-body {
  102. padding: 0;
  103. }
  104. </style>
  105. <script type="text/javascript">
  106. export default {
  107. props: ['feed', 'status', 'profile', 'size', 'modal'],
  108. methods: {
  109. reportUrl(status) {
  110. let type = status.in_reply_to ? 'comment' : 'post';
  111. let id = status.id;
  112. return '/i/report?type=' + type + '&id=' + id;
  113. },
  114. timestampFormat(timestamp) {
  115. let ts = new Date(timestamp);
  116. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  117. },
  118. editUrl(status) {
  119. return status.url + '/edit';
  120. },
  121. redirect(url) {
  122. window.location.href = url;
  123. return;
  124. },
  125. replyUrl(status) {
  126. let username = this.profile.username;
  127. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  128. return '/p/' + username + '/' + id;
  129. },
  130. mentionUrl(status) {
  131. let username = status.account.username;
  132. let id = status.id;
  133. return '/p/' + username + '/' + id;
  134. },
  135. statusOwner(status) {
  136. let sid = parseInt(status.account.id);
  137. let uid = parseInt(this.profile.id);
  138. if(sid == uid) {
  139. return true;
  140. } else {
  141. return false;
  142. }
  143. },
  144. deletePost() {
  145. this.$emit('deletePost');
  146. $('#mt_pid_'+this.status.id).modal('hide');
  147. },
  148. hidePost(status) {
  149. status.sensitive = true;
  150. $('#mt_pid_'+status.id).modal('hide');
  151. },
  152. moderatePost(status, action, $event) {
  153. let username = status.account.username;
  154. switch(action) {
  155. case 'autocw':
  156. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  157. swal({
  158. title: 'Confirm',
  159. text: msg,
  160. icon: 'warning',
  161. buttons: true,
  162. dangerMode: true
  163. });
  164. break;
  165. case 'suspend':
  166. msg = 'Are you sure you want to suspend the account of ' + username + ' ?';
  167. swal({
  168. title: 'Confirm',
  169. text: msg,
  170. icon: 'warning',
  171. buttons: true,
  172. dangerMode: true
  173. });
  174. break;
  175. }
  176. }
  177. }
  178. }
  179. </script>