diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-05-15 18:26:09 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-05-15 18:26:09 +0000 |
| commit | fedcc716762339b72f6a99722f2c54a300fdff4f (patch) | |
| tree | 15c89025e846ba322003bc9cb0965d3ed1fac00a /src/components/extra_buttons/extra_buttons.js | |
| parent | 9eac355851b40aa5df9e6b23eca8c0ff1698e670 (diff) | |
| parent | 2ce01863273fdefad7bca945f5d58d50a0e8d77b (diff) | |
Merge branch '468-pin-status' into 'develop'
Add ability to pin posts
Closes #468
See merge request pleroma/pleroma-fe!770
Diffstat (limited to 'src/components/extra_buttons/extra_buttons.js')
| -rw-r--r-- | src/components/extra_buttons/extra_buttons.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js new file mode 100644 index 00000000..f70ecd1d --- /dev/null +++ b/src/components/extra_buttons/extra_buttons.js @@ -0,0 +1,61 @@ +import Popper from 'vue-popperjs/src/component/popper.js.vue' + +const ExtraButtons = { + props: [ 'status' ], + components: { + Popper + }, + data () { + return { + showDropDown: false, + showPopper: true + } + }, + methods: { + deleteStatus () { + this.refreshPopper() + 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 () { + this.refreshPopper() + this.$store.dispatch('pinStatus', this.status.id) + .then(() => this.$emit('onSuccess')) + .catch(err => this.$emit('onError', err.error.error)) + }, + unpinStatus () { + this.refreshPopper() + this.$store.dispatch('unpinStatus', this.status.id) + .then(() => this.$emit('onSuccess')) + .catch(err => this.$emit('onError', err.error.error)) + }, + refreshPopper () { + this.showPopper = false + this.showDropDown = false + setTimeout(() => { + this.showPopper = true + }) + } + }, + 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 + }, + canPin () { + return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted') + } + } +} + +export default ExtraButtons |
