aboutsummaryrefslogtreecommitdiff
path: root/src/components/extra_buttons/extra_buttons.js
diff options
context:
space:
mode:
authordave <starpumadev@gmail.com>2019-04-12 15:35:29 -0400
committertaehoon <th.dev91@gmail.com>2019-05-15 12:04:25 -0400
commit9fc997500e33d561a1aa5d26c8ed8f4446a0248e (patch)
treed1daa83cde1270556446cfec32b5c8a671b69abd /src/components/extra_buttons/extra_buttons.js
parent80ef855a639f00a827be24e4cac411bd349f423e (diff)
#468 - add extra buttons for status actions
Diffstat (limited to 'src/components/extra_buttons/extra_buttons.js')
-rw-r--r--src/components/extra_buttons/extra_buttons.js51
1 files changed, 51 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..40bab2ab
--- /dev/null
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -0,0 +1,51 @@
+import Popper from 'vue-popperjs/src/component/popper.js.vue'
+
+const ExtraButtons = {
+ props: [ 'status' ],
+ components: {
+ Popper
+ },
+ data () {
+ return {
+ showDropDown: false
+ }
+ },
+ methods: {
+ deleteStatus () {
+ 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.$store.state.api.backendInteractor.pinOwnStatus(this.status.id).then((status) => {
+ if (status.error) {
+ this.$emit('onError', status.error)
+ } else {
+ this.$store.dispatch('updatePinned', status)
+ }
+ })
+ },
+ unpinStatus () {
+ this.$store.state.api.backendInteractor.unpinOwnStatus(this.status.id).then((status) => {
+ this.$store.dispatch('updatePinned', status)
+ })
+ }
+ },
+ 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
+ }
+ }
+}
+
+export default ExtraButtons