diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-28 00:11:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-28 00:11:07 +0300 |
commit | 9da482ecb8d25c8b6387f3262cfe983976333eec (patch) | |
tree | e935fe9c9ff42e2a36c854114221d66d47df9b98 /app/assets/javascripts/work_items/components/work_item_detail_modal.vue | |
parent | 3b060a68f3ca685d0676c2a70e3471dc7ee19d6e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/work_items/components/work_item_detail_modal.vue')
-rw-r--r-- | app/assets/javascripts/work_items/components/work_item_detail_modal.vue | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/app/assets/javascripts/work_items/components/work_item_detail_modal.vue b/app/assets/javascripts/work_items/components/work_item_detail_modal.vue index df7c6cab7ef..39a662a6c54 100644 --- a/app/assets/javascripts/work_items/components/work_item_detail_modal.vue +++ b/app/assets/javascripts/work_items/components/work_item_detail_modal.vue @@ -2,9 +2,13 @@ import { GlAlert, GlModal } from '@gitlab/ui'; import { s__ } from '~/locale'; import deleteWorkItemFromTaskMutation from '../graphql/delete_task_from_work_item.mutation.graphql'; +import deleteWorkItemMutation from '../graphql/delete_work_item.mutation.graphql'; import WorkItemDetail from './work_item_detail.vue'; export default { + i18n: { + errorMessage: s__('WorkItem|Something went wrong when deleting the task. Please try again.'), + }, components: { GlAlert, GlModal, @@ -45,6 +49,13 @@ export default { }, methods: { deleteWorkItem() { + if (this.lockVersion != null && this.lineNumberStart && this.lineNumberEnd) { + this.deleteWorkItemWithTaskData(); + } else { + this.deleteWorkItemWithoutTaskData(); + } + }, + deleteWorkItemWithTaskData() { this.$apollo .mutate({ mutation: deleteWorkItemFromTaskMutation, @@ -70,17 +81,33 @@ export default { }, }) => { if (errors?.length) { - throw new Error(errors[0].message); + throw new Error(errors[0]); } this.$emit('workItemDeleted', descriptionHtml); - this.$refs.modal.hide(); + this.hide(); }, ) - .catch((e) => { - this.error = - e.message || - s__('WorkItem|Something went wrong when deleting the task. Please try again.'); + .catch((error) => { + this.setErrorMessage(error.message); + }); + }, + deleteWorkItemWithoutTaskData() { + this.$apollo + .mutate({ + mutation: deleteWorkItemMutation, + variables: { input: { id: this.workItemId } }, + }) + .then(({ data }) => { + if (data.workItemDelete.errors?.length) { + throw new Error(data.workItemDelete.errors[0]); + } + + this.$emit('workItemDeleted', this.workItemId); + this.hide(); + }) + .catch((error) => { + this.setErrorMessage(error.message); }); }, closeModal() { @@ -91,7 +118,7 @@ export default { this.$refs.modal.hide(); }, setErrorMessage(message) { - this.error = message; + this.error = message || this.$options.i18n.errorMessage; }, show() { this.$refs.modal.show(); |