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
85
86
87
88
89
90
91
92
93
|
<script>
import { GlDropdown, GlDropdownItem, GlModal, GlModalDirective } from '@gitlab/ui';
import { s__ } from '~/locale';
import deleteWorkItemMutation from '../graphql/delete_work_item.mutation.graphql';
export default {
i18n: {
deleteWorkItem: s__('WorkItem|Delete work item'),
},
components: {
GlDropdown,
GlDropdownItem,
GlModal,
},
directives: {
GlModal: GlModalDirective,
},
props: {
workItemId: {
type: String,
required: false,
default: null,
},
canUpdate: {
type: Boolean,
required: false,
default: false,
},
},
emits: ['workItemDeleted', 'error'],
methods: {
deleteWorkItem() {
this.$apollo
.mutate({
mutation: deleteWorkItemMutation,
variables: {
input: {
id: this.workItemId,
},
},
})
.then(({ data: { workItemDelete, errors } }) => {
if (errors?.length) {
throw new Error(errors[0].message);
}
if (workItemDelete?.errors.length) {
throw new Error(workItemDelete.errors[0]);
}
this.$emit('workItemDeleted');
})
.catch((e) => {
this.$emit(
'error',
e.message ||
s__('WorkItem|Something went wrong when deleting the work item. Please try again.'),
);
});
},
},
};
</script>
<template>
<div v-if="canUpdate">
<gl-dropdown
icon="ellipsis_v"
text-sr-only
:text="__('More actions')"
category="tertiary"
no-caret
right
>
<gl-dropdown-item v-gl-modal="'work-item-confirm-delete'">{{
$options.i18n.deleteWorkItem
}}</gl-dropdown-item>
</gl-dropdown>
<gl-modal
modal-id="work-item-confirm-delete"
:title="$options.i18n.deleteWorkItem"
:ok-title="$options.i18n.deleteWorkItem"
ok-variant="danger"
@ok="deleteWorkItem"
>
{{
s__(
'WorkItem|Are you sure you want to delete the work item? This action cannot be reversed.',
)
}}
</gl-modal>
</div>
</template>
|