2021-10-19 12:12:07 +00:00
|
|
|
<script>
|
2022-05-11 15:07:26 +00:00
|
|
|
import { GlAlert } from '@gitlab/ui';
|
2022-03-23 12:07:27 +00:00
|
|
|
import { TYPE_WORK_ITEM } from '~/graphql_shared/constants';
|
2022-03-10 06:09:00 +00:00
|
|
|
import { convertToGraphQLId } from '~/graphql_shared/utils';
|
2022-05-11 15:07:26 +00:00
|
|
|
import { visitUrl } from '~/lib/utils/url_utility';
|
2022-06-15 21:10:04 +00:00
|
|
|
import ZenMode from '~/zen_mode';
|
2022-03-24 12:07:26 +00:00
|
|
|
import WorkItemDetail from '../components/work_item_detail.vue';
|
2022-08-25 06:11:18 +00:00
|
|
|
import {
|
|
|
|
sprintfWorkItem,
|
|
|
|
I18N_WORK_ITEM_ERROR_DELETING,
|
|
|
|
I18N_WORK_ITEM_DELETED,
|
|
|
|
} from '../constants';
|
2022-05-11 15:07:26 +00:00
|
|
|
import deleteWorkItemMutation from '../graphql/delete_work_item.mutation.graphql';
|
2022-01-13 18:16:51 +00:00
|
|
|
|
2021-10-19 12:12:07 +00:00
|
|
|
export default {
|
2021-12-08 12:13:04 +00:00
|
|
|
components: {
|
2022-05-11 15:07:26 +00:00
|
|
|
GlAlert,
|
2022-03-24 12:07:26 +00:00
|
|
|
WorkItemDetail,
|
2021-12-08 12:13:04 +00:00
|
|
|
},
|
2022-05-11 15:07:26 +00:00
|
|
|
inject: ['issuesListPath'],
|
2021-10-19 12:12:07 +00:00
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2022-05-11 15:07:26 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
error: '',
|
|
|
|
};
|
|
|
|
},
|
2021-10-19 12:12:07 +00:00
|
|
|
computed: {
|
2022-03-10 06:09:00 +00:00
|
|
|
gid() {
|
2022-03-23 12:07:27 +00:00
|
|
|
return convertToGraphQLId(TYPE_WORK_ITEM, this.id);
|
2021-10-19 12:12:07 +00:00
|
|
|
},
|
2021-12-08 12:13:04 +00:00
|
|
|
},
|
2022-06-15 21:10:04 +00:00
|
|
|
mounted() {
|
|
|
|
this.ZenMode = new ZenMode();
|
|
|
|
},
|
2022-04-28 09:08:26 +00:00
|
|
|
methods: {
|
2022-11-04 15:07:23 +00:00
|
|
|
deleteWorkItem({ workItemType, workItemId: id }) {
|
2022-05-11 15:07:26 +00:00
|
|
|
this.$apollo
|
|
|
|
.mutate({
|
|
|
|
mutation: deleteWorkItemMutation,
|
|
|
|
variables: {
|
2022-11-04 15:07:23 +00:00
|
|
|
input: { id },
|
2022-05-11 15:07:26 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data: { workItemDelete, errors } }) => {
|
|
|
|
if (errors?.length) {
|
|
|
|
throw new Error(errors[0].message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (workItemDelete?.errors.length) {
|
|
|
|
throw new Error(workItemDelete.errors[0]);
|
|
|
|
}
|
|
|
|
|
2022-08-25 06:11:18 +00:00
|
|
|
const msg = sprintfWorkItem(I18N_WORK_ITEM_DELETED, workItemType);
|
|
|
|
this.$toast.show(msg);
|
2022-05-11 15:07:26 +00:00
|
|
|
visitUrl(this.issuesListPath);
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
2022-08-25 06:11:18 +00:00
|
|
|
this.error = e.message || sprintfWorkItem(I18N_WORK_ITEM_ERROR_DELETING, workItemType);
|
2022-05-11 15:07:26 +00:00
|
|
|
});
|
2022-04-28 09:08:26 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-19 12:12:07 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-05-11 15:07:26 +00:00
|
|
|
<div>
|
|
|
|
<gl-alert v-if="error" variant="danger" @dismiss="error = ''">{{ error }}</gl-alert>
|
2022-11-04 15:07:23 +00:00
|
|
|
<work-item-detail :work-item-id="gid" :iid="id" @deleteWorkItem="deleteWorkItem($event)" />
|
2022-05-11 15:07:26 +00:00
|
|
|
</div>
|
2021-10-19 12:12:07 +00:00
|
|
|
</template>
|