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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<script>
import { GlButton, GlLink, GlTableLite } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
import { __, s__ } from '~/locale';
import { createAlert } from '~/flash';
import { redirectTo } from '~/lib/utils/url_utility';
import CiBadgeLink from '~/vue_shared/components/ci_badge_link.vue';
import RetryFailedJobMutation from '../../graphql/mutations/retry_failed_job.mutation.graphql';
import { DEFAULT_FIELDS } from '../../constants';
export default {
fields: DEFAULT_FIELDS,
retry: __('Retry'),
components: {
CiBadgeLink,
GlButton,
GlLink,
GlTableLite,
},
directives: {
SafeHtml,
},
props: {
failedJobs: {
type: Array,
required: true,
},
},
methods: {
async retryJob(id) {
try {
const {
data: {
jobRetry: { errors, job },
},
} = await this.$apollo.mutate({
mutation: RetryFailedJobMutation,
variables: { id },
});
if (errors.length > 0) {
this.showErrorMessage();
} else {
redirectTo(job.detailedStatus.detailsPath);
}
} catch {
this.showErrorMessage();
}
},
canRetryJob(job) {
return job.retryable && job.userPermissions.updateBuild;
},
showErrorMessage() {
createAlert({ message: s__('Job|There was a problem retrying the failed job.') });
},
},
};
</script>
<template>
<gl-table-lite
:items="failedJobs"
:fields="$options.fields"
stacked="lg"
fixed
data-testId="tab-failures"
>
<template #table-colgroup="{ fields }">
<col v-for="field in fields" :key="field.key" :class="field.columnClass" />
</template>
<template #cell(name)="{ item }">
<div
class="gl-display-flex gl-align-items-center gl-lg-justify-content-start gl-justify-content-end"
>
<ci-badge-link :status="item.detailedStatus" :show-text="false" class="gl-mr-3" />
<div class="gl-text-truncate">
<gl-link
:href="item.detailedStatus.detailsPath"
class="gl-font-weight-bold gl-text-gray-900!"
>
{{ item.name }}
</gl-link>
</div>
</div>
</template>
<template #cell(stage)="{ item }">
<div class="gl-text-truncate">
<span>{{ item.stage.name }}</span>
</div>
</template>
<template #cell(failure)="{ item }">
<span>{{ item.failure }}</span>
</template>
<template #cell(actions)="{ item }">
<gl-button
v-if="canRetryJob(item)"
icon="retry"
:title="$options.retry"
:aria-label="$options.retry"
@click="retryJob(item.id)"
/>
</template>
<template #row-details="{ item }">
<pre
v-if="item.userPermissions.readBuild"
class="gl-w-full gl-text-left gl-border-none"
data-testid="job-log"
>
<code v-safe-html="item.failureSummary" class="gl-reset-bg gl-p-0" >
</code>
</pre>
</template>
</gl-table-lite>
</template>
|