1
0
Fork 0
pixelfed/resources/assets/js/components/PostMenu.vue

186 lines
7.1 KiB
Vue

<template>
<div>
<div v-if="modal != 'true'" class="dropdown">
<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">
<span v-bind:class="[size =='lg' ? 'fas fa-ellipsis-v fa-lg text-muted' : 'fas fa-ellipsis-v fa-sm text-lighter']"></span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
<a class="dropdown-item font-weight-bold" href="#">Share</a>
<a class="dropdown-item font-weight-bold" href="#">Embed</a>
<span v-if="statusOwner(status) == false">
<a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
</span>
<span v-if="statusOwner(status) == true">
<a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
<a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
</span>
<span v-if="profile.is_admin == true">
<div class="dropdown-divider"></div>
<a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Mod Tools</h6>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')">
<p class="mb-0">Enforce CW</p>
<p class="mb-0 small text-muted">Adds a CW to every post <br> made by this account.</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')">
<p class="mb-0">No Autolinking</p>
<p class="mb-0 small text-muted">Do not transform mentions, <br> hashtags or urls into HTML.</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')">
<p class="mb-0">Unlisted Posts</p>
<p class="mb-0 small text-muted">Removes account from <br> public/network timelines.</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'disable')">
<p class="mb-0">Disable Account</p>
<p class="mb-0 small text-muted">Temporarily disable account <br> until next time user log in.</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')">
<p class="mb-0">Suspend Account</p>
<p class="mb-0 small text-muted">This prevents any new interactions, <br> without deleting existing data.</p>
</a>
</span>
</div>
</div>
<div v-if="modal == 'true'">
<span data-toggle="modal" :data-target="'#mt_pid_'+status.id">
<span v-bind:class="[size =='lg' ? 'fas fa-ellipsis-v fa-lg text-muted' : 'fas fa-ellipsis-v fa-sm text-lighter']"></span>
</span>
<div class="modal" tabindex="-1" role="dialog" :id="'mt_pid_'+status.id">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="list-group">
<a class="list-group-item font-weight-bold" :href="status.url">Go to post</a>
<a class="list-group-item font-weight-bold" :href="status.url">Share</a>
<a class="list-group-item font-weight-bold" :href="status.url">Embed</a>
<span v-if="statusOwner(status) == false">
<a class="list-group-item font-weight-bold" :href="reportUrl(status)">Report</a>
<a class="list-group-item font-weight-bold" v-on:click="muteProfile(status)" href="#">Mute Profile</a>
<a class="list-group-item font-weight-bold" v-on:click="blockProfile(status)" href="#">Block Profile</a>
</span>
<span v-if="statusOwner(status) == true || profile.is_admin == true">
<a class="list-group-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
</span>
<span v-if="profile.is_admin == true">
<a class="list-group-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')" href="#">
<p class="mb-0">Enforce CW</p>
<p class="mb-0 small text-muted">Adds a CW to every post <br> made by this account.</p>
</a>
<a class="list-group-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')" href="#">
<p class="mb-0">No Autolinking</p>
<p class="mb-0 small text-muted">Do not transform mentions, <br> hashtags or urls into HTML.</p>
</a>
<a class="list-group-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')" href="#">
<p class="mb-0">Unlisted Posts</p>
<p class="mb-0 small text-muted">Removes account from <br> public/network timelines.</p>
</a>
<a class="list-group-item font-weight-bold" v-on:click="moderatePost(status, 'disable')" href="#">
<p class="mb-0">Disable Account</p>
<p class="mb-0 small text-muted">Temporarily disable account <br> until next time user log in.</p>
</a>
<a class="list-group-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')" href="#">
<p class="mb-0">Suspend Account</p>
<p class="mb-0 small text-muted">This prevents any new interactions, <br> without deleting existing data.</p>
</a>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style type="text/css" scoped>
.text-lighter {
color:#B8C2CC !important;
}
.modal-body {
padding: 0;
}
</style>
<script type="text/javascript">
export default {
props: ['feed', 'status', 'profile', 'size', 'modal'],
methods: {
reportUrl(status) {
let type = status.in_reply_to ? 'comment' : 'post';
let id = status.id;
return '/i/report?type=' + type + '&id=' + id;
},
timestampFormat(timestamp) {
let ts = new Date(timestamp);
return ts.toDateString() + ' ' + ts.toLocaleTimeString();
},
editUrl(status) {
return status.url + '/edit';
},
redirect(url) {
window.location.href = url;
return;
},
replyUrl(status) {
let username = this.profile.username;
let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
return '/p/' + username + '/' + id;
},
mentionUrl(status) {
let username = status.account.username;
let id = status.id;
return '/p/' + username + '/' + id;
},
statusOwner(status) {
let sid = parseInt(status.account.id);
let uid = parseInt(this.profile.id);
if(sid == uid) {
return true;
} else {
return false;
}
},
deletePost(status, index) {
},
moderatePost(status, action, $event) {
let username = status.account.username;
switch(action) {
case 'autocw':
let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
});
break;
case 'suspend':
msg = 'Are you sure you want to suspend the account of ' + username + ' ?';
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
});
break;
}
}
}
}
</script>