1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<template>
<button class="action-button pull-right"
:class="{ primary: primary }"
:data-type="type"
:data-href="link"
@click="onClickActionButton">
{{ label }}
</button>
</template>
<script>
import axios from '@nextcloud/axios'
export default {
name: 'Action',
props: {
label: {
type: String,
default: '',
required: true,
},
link: {
type: String,
default: '',
required: true,
},
type: {
type: String,
default: '',
required: true,
},
primary: {
type: Boolean,
default: false,
required: true,
},
},
methods: {
onClickActionButton: function() {
const type = this.type || 'GET'
if (type === 'WEB') {
OC.redirect(this.link)
return
}
axios({
method: type,
url: this.link,
})
.then(() => {
this.$parent._$el.fadeOut(OC.menuSpeed)
this.$parent.$emit('remove')
$('body').trigger(new $.Event('OCA.Notification.Action', {
notification: this.$parent,
action: {
url: this.link,
type: type,
},
}))
})
.catch(() => {
OC.Notification.showTemporary(t('notifications', 'Failed to perform action'))
})
},
},
}
</script>
|