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
|
<script>
import { GlAlert } from '@gitlab/ui';
import { TYPE_WORK_ITEM } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import { visitUrl } from '~/lib/utils/url_utility';
import { s__ } from '~/locale';
import ZenMode from '~/zen_mode';
import WorkItemDetail from '../components/work_item_detail.vue';
import deleteWorkItemMutation from '../graphql/delete_work_item.mutation.graphql';
export default {
components: {
GlAlert,
WorkItemDetail,
},
inject: ['issuesListPath'],
props: {
id: {
type: String,
required: true,
},
},
data() {
return {
error: '',
};
},
computed: {
gid() {
return convertToGraphQLId(TYPE_WORK_ITEM, this.id);
},
},
mounted() {
this.ZenMode = new ZenMode();
},
methods: {
deleteWorkItem() {
this.$apollo
.mutate({
mutation: deleteWorkItemMutation,
variables: {
input: {
id: this.gid,
},
},
})
.then(({ data: { workItemDelete, errors } }) => {
if (errors?.length) {
throw new Error(errors[0].message);
}
if (workItemDelete?.errors.length) {
throw new Error(workItemDelete.errors[0]);
}
this.$toast.show(s__('WorkItem|Work item deleted'));
visitUrl(this.issuesListPath);
})
.catch((e) => {
this.error =
e.message ||
s__('WorkItem|Something went wrong when deleting the work item. Please try again.');
});
},
},
};
</script>
<template>
<div>
<gl-alert v-if="error" variant="danger" @dismiss="error = ''">{{ error }}</gl-alert>
<work-item-detail :work-item-id="gid" @deleteWorkItem="deleteWorkItem" />
</div>
</template>
|