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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
<script>
import { GlBadge, GlIcon, GlLink, GlTooltipDirective } from '@gitlab/ui';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { s__ } from '~/locale';
import { SUCCESS_STATUS } from '../../../constants';
export default {
iconSize: 12,
badgeSize: 'sm',
i18n: {
stuckText: s__('Jobs|Job is stuck. Check runners.'),
},
directives: {
GlTooltip: GlTooltipDirective,
},
components: {
GlBadge,
GlIcon,
GlLink,
},
props: {
job: {
type: Object,
required: true,
},
},
computed: {
jobId() {
const id = getIdFromGraphQLId(this.job.id);
return `#${id}`;
},
jobPath() {
return this.job.detailedStatus?.detailsPath;
},
jobRef() {
return this.job?.refName;
},
jobRefPath() {
return this.job?.refPath;
},
jobTags() {
return this.job.tags;
},
createdByTag() {
return this.job.createdByTag;
},
triggered() {
return this.job.triggered;
},
isManualJob() {
return this.job.manualJob;
},
successfulJob() {
return this.job.status === SUCCESS_STATUS;
},
showAllowedToFailBadge() {
return this.job.allowFailure && !this.successfulJob;
},
isScheduledJob() {
return Boolean(this.job.scheduledAt);
},
canReadJob() {
return this.job?.userPermissions?.readBuild;
},
jobStuck() {
return this.job?.stuck;
},
},
};
</script>
<template>
<div>
<div class="gl-text-truncate gl-mb-2">
<gl-link
v-if="canReadJob"
class="gl-text-blue-600!"
:href="jobPath"
data-testid="job-id-link"
>
{{ jobId }}
</gl-link>
<span v-else data-testid="job-id-limited-access">{{ jobId }}</span>
<gl-icon
v-if="jobStuck"
v-gl-tooltip="$options.i18n.stuckText"
name="warning"
:size="$options.iconSize"
data-testid="stuck-icon"
/>
<div
class="gl-display-flex gl-text-gray-700 gl-align-items-center gl-lg-justify-content-start gl-justify-content-end gl-mt-2"
>
<div
v-if="jobRef"
class="gl-px-2 gl-rounded-base gl-bg-gray-50 gl-max-w-15 gl-text-truncate"
>
<gl-icon
v-if="createdByTag"
name="label"
:size="$options.iconSize"
data-testid="label-icon"
/>
<gl-icon v-else name="fork" :size="$options.iconSize" data-testid="fork-icon" />
<gl-link
class="gl-font-sm gl-font-monospace gl-text-gray-700 gl-hover-text-gray-900"
:href="job.refPath"
data-testid="job-ref"
>{{ job.refName }}</gl-link
>
</div>
<span v-else>{{ __('none') }}</span>
<div class="gl-ml-2 gl-rounded-base gl-px-2 gl-bg-gray-50">
<gl-icon class="gl-mx-2" name="commit" :size="$options.iconSize" />
<gl-link
class="gl-font-sm gl-font-monospace gl-text-gray-700 gl-hover-text-gray-900"
:href="job.commitPath"
data-testid="job-sha"
>{{ job.shortSha }}</gl-link
>
</div>
</div>
</div>
<div>
<gl-badge
v-for="tag in jobTags"
:key="tag"
variant="info"
:size="$options.badgeSize"
data-testid="job-tag-badge"
>
{{ tag }}
</gl-badge>
<gl-badge
v-if="triggered"
variant="info"
:size="$options.badgeSize"
data-testid="triggered-job-badge"
>{{ s__('Job|triggered') }}
</gl-badge>
<gl-badge
v-if="showAllowedToFailBadge"
variant="warning"
:size="$options.badgeSize"
data-testid="fail-job-badge"
>{{ s__('Job|allowed to fail') }}
</gl-badge>
<gl-badge
v-if="isScheduledJob"
variant="info"
:size="$options.badgeSize"
data-testid="delayed-job-badge"
>{{ s__('Job|delayed') }}
</gl-badge>
<gl-badge
v-if="isManualJob"
variant="info"
:size="$options.badgeSize"
data-testid="manual-job-badge"
>
{{ s__('Job|manual') }}
</gl-badge>
</div>
</div>
</template>
|