2019-04-12 12:35:29 -07:00
|
|
|
import Popper from 'vue-popperjs/src/component/popper.js.vue'
|
|
|
|
|
|
|
|
const ExtraButtons = {
|
|
|
|
props: [ 'status' ],
|
|
|
|
components: {
|
|
|
|
Popper
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2019-04-14 19:27:16 -07:00
|
|
|
showDropDown: false,
|
|
|
|
showPopper: true
|
2019-04-12 12:35:29 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
deleteStatus () {
|
2019-04-14 19:27:16 -07:00
|
|
|
this.refreshPopper()
|
2019-04-12 12:35:29 -07: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-14 19:27:16 -07:00
|
|
|
this.refreshPopper()
|
2019-04-24 13:19:27 -07:00
|
|
|
this.$store.dispatch('pinStatus', this.status.id)
|
2019-04-27 06:36:10 -07:00
|
|
|
.then(() => this.$emit('onSuccess'))
|
2019-04-24 13:19:27 -07:00
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-12 12:35:29 -07:00
|
|
|
},
|
|
|
|
unpinStatus () {
|
2019-04-14 19:27:16 -07:00
|
|
|
this.refreshPopper()
|
2019-04-24 12:34:30 -07:00
|
|
|
this.$store.dispatch('unpinStatus', this.status.id)
|
2019-04-27 06:36:10 -07:00
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-14 19:27:16 -07:00
|
|
|
},
|
|
|
|
refreshPopper () {
|
|
|
|
this.showPopper = false
|
|
|
|
this.showDropDown = false
|
|
|
|
setTimeout(() => {
|
|
|
|
this.showPopper = true
|
|
|
|
})
|
2019-04-12 12:35:29 -07: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 10:18:56 -07:00
|
|
|
},
|
|
|
|
canPin () {
|
|
|
|
return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
|
2019-05-16 10:45:18 -07:00
|
|
|
},
|
|
|
|
enabled () {
|
|
|
|
return this.canPin || this.canDelete
|
2019-04-12 12:35:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExtraButtons
|