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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<script>
import { GlModal, GlSprintf } from '@gitlab/ui';
import { __ } from '~/locale';
import csrf from '~/lib/utils/csrf';
export default {
components: {
GlModal,
GlSprintf,
},
data() {
return {
name: '',
path: '',
buttons: [],
};
},
mounted() {
this.buttons = document.querySelectorAll('.js-application-delete-button');
this.buttons.forEach((button) => button.addEventListener('click', this.buttonEvent));
},
destroy() {
this.buttons.forEach((button) => button.removeEventListener('click', this.buttonEvent));
},
methods: {
buttonEvent(e) {
e.preventDefault();
this.show(e.target.dataset);
},
show(dataset) {
const { name, path } = dataset;
this.name = name;
this.path = path;
this.$refs.deleteModal.show();
},
deleteApplication() {
this.$refs.deleteForm.submit();
},
},
i18n: {
destroy: __('Destroy'),
title: __('Confirm destroy application'),
body: __('Are you sure that you want to destroy %{application}'),
},
modal: {
actionPrimary: {
text: __('Destroy'),
attributes: {
variant: 'danger',
},
},
actionSecondary: {
text: __('Cancel'),
attributes: {
variant: 'default',
},
},
},
csrf,
};
</script>
<template>
<gl-modal
ref="deleteModal"
:title="$options.i18n.title"
:action-primary="$options.modal.actionPrimary"
:action-secondary="$options.modal.actionSecondary"
modal-id="delete-application-modal"
size="sm"
@primary="deleteApplication"
><gl-sprintf :message="$options.i18n.body">
<template #application>
<strong>{{ name }}</strong>
</template></gl-sprintf
>
<form ref="deleteForm" method="post" :action="path">
<input type="hidden" name="_method" value="delete" />
<input type="hidden" name="authenticity_token" :value="$options.csrf.token" />
</form>
</gl-modal>
</template>
|