aboutsummaryrefslogtreecommitdiff
path: root/src/components/delete_button/delete_button.js
blob: 22f24625722e6908345381cf872733c7071351b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const DeleteButton = {
  props: [ 'status' ],
  methods: {
    deleteStatus () {
      const confirmed = window.confirm('Do you really want to delete this status?')
      if (confirmed) {
        this.$store.dispatch('deleteStatus', { id: this.status.id })
      }
    }
  },
  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
    }
  }
}

export default DeleteButton