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

227 lines
7.7 KiB
Vue
Raw Normal View History

2019-01-31 20:22:46 +00:00
<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">
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" :href="status.url">Go to post</a>
2019-07-05 03:19:29 +00:00
<!-- <a class="dropdown-item font-weight-bold text-decoration-none" href="#">Share</a>
<a class="dropdown-item font-weight-bold text-decoration-none" href="#">Embed</a> -->
2020-03-25 04:33:09 +00:00
<span v-if="activeSession == true && statusOwner(status) == false">
2019-01-31 20:22:46 +00:00
<a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
</span>
2020-03-25 04:33:09 +00:00
<span v-if="activeSession == true && statusOwner(status) == true">
2019-07-21 01:56:20 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" @click.prevent="muteProfile(status)">Mute Profile</a>
<a class="dropdown-item font-weight-bold text-decoration-none" @click.prevent="blockProfile(status)">Block Profile</a>
2019-01-31 20:22:46 +00:00
</span>
2020-03-25 04:33:09 +00:00
<span v-if="activeSession == true && profile.is_admin == true">
2019-01-31 20:22:46 +00:00
<div class="dropdown-divider"></div>
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-danger text-decoration-none" v-on:click="deletePost(status)">Delete</a>
2019-01-31 20:22:46 +00:00
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Mod Tools</h6>
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'autocw')">
2019-01-31 20:22:46 +00:00
<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>
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'noautolink')">
2019-01-31 20:22:46 +00:00
<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>
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'unlisted')">
2019-01-31 20:22:46 +00:00
<p class="mb-0">Unlisted Posts</p>
<p class="mb-0 small text-muted">Removes account from <br> public/network timelines.</p>
</a>
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'disable')">
2019-01-31 20:22:46 +00:00
<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>
2019-04-01 05:29:54 +00:00
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="moderatePost(status, 'suspend')">
2019-01-31 20:22:46 +00:00
<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 modal-dialog-centered" role="document">
2019-01-31 20:22:46 +00:00
<div class="modal-content">
<div class="modal-body text-center">
<div class="list-group">
<a class="list-group-item text-dark text-decoration-none" :href="statusUrl(status)">Go to post</a>
<!-- a class="list-group-item font-weight-bold text-decoration-none" :href="status.url">Share</a>
2019-07-05 03:19:29 +00:00
<a class="list-group-item font-weight-bold text-decoration-none" :href="status.url">Embed</a> -->
2020-05-23 07:38:23 +00:00
<a class="list-group-item text-dark text-decoration-none" href="#" @click.prevent="hidePost(status)">Hide</a>
2020-12-14 05:54:24 +00:00
<a v-if="activeSession == true && !statusOwner(status)" class="list-group-item text-danger font-weight-bold text-decoration-none" :href="reportUrl(status)">Report</a>
<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>
<a class="list-group-item text-lighter text-decoration-none" href="#" @click.prevent="closeModal()">Close</a>
2019-01-31 20:22:46 +00:00
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style type="text/css" scoped>
.text-lighter {
color:#B8C2CC !important;
}
2019-02-11 04:13:09 +00:00
.modal-body {
padding: 0;
}
2019-01-31 20:22:46 +00:00
</style>
<script type="text/javascript">
export default {
2019-02-11 04:13:09 +00:00
props: ['feed', 'status', 'profile', 'size', 'modal'],
2019-01-31 20:22:46 +00:00
2020-03-25 04:33:09 +00:00
data() {
return {
activeSession: false
};
},
mounted() {
let el = document.querySelector('body');
this.activeSession = el.classList.contains('loggedIn') ? true : false;
},
2019-01-31 20:22:46 +00:00
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;
}
},
2019-03-07 07:43:12 +00:00
deletePost() {
this.$emit('deletePost');
$('#mt_pid_'+this.status.id).modal('hide');
2019-01-31 20:22:46 +00:00
},
2019-07-05 03:19:29 +00:00
hidePost(status) {
status.sensitive = true;
$('#mt_pid_'+status.id).modal('hide');
},
2019-01-31 20:22:46 +00:00
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;
}
2019-07-21 01:56:20 +00:00
},
muteProfile(status) {
if($('body').hasClass('loggedIn') == false) {
return;
}
axios.post('/i/mute', {
type: 'user',
item: status.account.id
}).then(res => {
swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
}).catch(err => {
swal('Error', 'Something went wrong. Please try again later.', 'error');
});
},
blockProfile(status) {
if($('body').hasClass('loggedIn') == false) {
return;
}
axios.post('/i/block', {
type: 'user',
item: status.account.id
}).then(res => {
swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
}).catch(err => {
swal('Error', 'Something went wrong. Please try again later.', 'error');
});
},
statusUrl(status) {
if(status.local == true) {
return status.url;
}
return '/i/web/post/_/' + status.account.id + '/' + status.id;
},
profileUrl(status) {
if(status.local == true) {
return status.account.url;
}
return '/i/web/profile/_/' + status.account.id;
},
closeModal() {
$('#mt_pid_'+this.status.id).modal('hide');
2019-01-31 20:22:46 +00:00
}
}
}
</script>