2019-04-12 19:35:29 +00:00
|
|
|
import Popper from 'vue-popperjs/src/component/popper.js.vue'
|
|
|
|
|
|
|
|
const ExtraButtons = {
|
|
|
|
props: [ 'status' ],
|
|
|
|
components: {
|
|
|
|
Popper
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2019-04-15 02:27:16 +00:00
|
|
|
showDropDown: false,
|
|
|
|
showPopper: true
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
deleteStatus () {
|
2019-04-15 02:27:16 +00:00
|
|
|
this.refreshPopper()
|
2019-04-12 19:35:29 +00:00
|
|
|
const confirmed = window.confirm(this.$t('status.delete_confirm'))
|
|
|
|
if (confirmed) {
|
|
|
|
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
|
|
|
}
|
|
|
|
},
|
|
|
|
toggleMenu () {
|
|
|
|
this.showDropDown = !this.showDropDown
|
|
|
|
},
|
|
|
|
pinStatus () {
|
2019-04-15 02:27:16 +00:00
|
|
|
this.refreshPopper()
|
2019-04-24 19:34:30 +00:00
|
|
|
this.$store.dispatch('pinStatus', this.status.id).then((status) => {
|
2019-04-12 19:35:29 +00:00
|
|
|
if (status.error) {
|
|
|
|
this.$emit('onError', status.error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
unpinStatus () {
|
2019-04-15 02:27:16 +00:00
|
|
|
this.refreshPopper()
|
2019-04-24 19:34:30 +00:00
|
|
|
this.$store.dispatch('unpinStatus', this.status.id)
|
2019-04-15 02:27:16 +00:00
|
|
|
},
|
|
|
|
refreshPopper () {
|
|
|
|
this.showPopper = false
|
|
|
|
this.showDropDown = false
|
|
|
|
setTimeout(() => {
|
|
|
|
this.showPopper = true
|
|
|
|
})
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
currentUser () { return this.$store.state.users.currentUser },
|
|
|
|
canDelete () {
|
|
|
|
if (!this.currentUser) { return }
|
|
|
|
const superuser = this.currentUser.rights.moderator || this.currentUser.rights.admin
|
|
|
|
return superuser || this.status.user.id === this.currentUser.id
|
|
|
|
},
|
|
|
|
ownStatus () {
|
|
|
|
return this.status.user.id === this.currentUser.id
|
2019-04-14 17:18:56 +00:00
|
|
|
},
|
|
|
|
canPin () {
|
|
|
|
return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExtraButtons
|