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
|
<script>
import { GlButton, GlAlert } from '@gitlab/ui';
import createWorkItemMutation from '../graphql/create_work_item.mutation.graphql';
import ItemTitle from '../components/item_title.vue';
export default {
components: {
GlButton,
GlAlert,
ItemTitle,
},
data() {
return {
title: '',
error: false,
};
},
methods: {
async createWorkItem() {
try {
const response = await this.$apollo.mutate({
mutation: createWorkItemMutation,
variables: {
input: {
title: this.title,
},
},
});
const {
data: {
localCreateWorkItem: {
workItem: { id },
},
},
} = response;
this.$router.push({ name: 'workItem', params: { id } });
} catch {
this.error = true;
}
},
handleTitleInput(title) {
this.title = title;
},
},
};
</script>
<template>
<form @submit.prevent="createWorkItem">
<gl-alert v-if="error" variant="danger" @dismiss="error = false">{{
__('Something went wrong when creating a work item. Please try again')
}}</gl-alert>
<item-title data-testid="title-input" @title-input="handleTitleInput" />
<div class="gl-bg-gray-10 gl-py-5 gl-px-6">
<gl-button
variant="confirm"
:disabled="title.length === 0"
class="gl-mr-3"
data-testid="create-button"
type="submit"
>
{{ __('Create') }}
</gl-button>
<gl-button type="button" data-testid="cancel-button" @click="$router.go(-1)">
{{ __('Cancel') }}
</gl-button>
</div>
</form>
</template>
|