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
|
<script>
import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import { createAlert } from '~/alert';
import { TYPENAME_COMMIT_STATUS } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import { __, s__ } from '~/locale';
import { JOB_GRAPHQL_ERRORS, forwardDeploymentFailureModalId, PASSED_STATUS } from '~/ci/constants';
import GetJob from '../../graphql/queries/get_job.query.graphql';
import JobSidebarRetryButton from './job_sidebar_retry_button.vue';
export default {
name: 'SidebarHeader',
i18n: {
cancelJobButtonLabel: s__('Job|Cancel'),
debug: __('Debug'),
eraseLogButtonLabel: s__('Job|Erase job log and artifacts'),
eraseLogConfirmText: s__('Job|Are you sure you want to erase this job log and artifacts?'),
newIssue: __('New issue'),
retryJobLabel: s__('Job|Retry'),
runAgainJobButtonLabel: s__('Job|Run again'),
},
forwardDeploymentFailureModalId,
directives: {
GlTooltip: GlTooltipDirective,
},
components: {
GlButton,
JobSidebarRetryButton,
},
inject: ['projectPath'],
apollo: {
job: {
query: GetJob,
variables() {
return {
fullPath: this.projectPath,
id: convertToGraphQLId(TYPENAME_COMMIT_STATUS, this.jobId),
};
},
update(data) {
const { name, manualJob } = data?.project?.job || {};
return {
name,
manualJob,
};
},
error() {
createAlert({ message: JOB_GRAPHQL_ERRORS.jobQueryErrorText });
},
},
},
props: {
jobId: {
type: Number,
required: true,
},
restJob: {
type: Object,
required: true,
default: () => ({}),
},
},
data() {
return {
job: {},
};
},
computed: {
buttonTitle() {
return this.restJob.status?.text === PASSED_STATUS
? this.$options.i18n.runAgainJobButtonLabel
: this.$options.i18n.retryJobLabel;
},
canShowJobRetryButton() {
return this.restJob.retry_path && !this.$apollo.queries.job.loading;
},
isManualJob() {
return this.job?.manualJob;
},
retryButtonCategory() {
return this.restJob.status && this.restJob.recoverable ? 'primary' : 'secondary';
},
},
};
</script>
<template>
<div>
<div class="gl-display-flex gl-gap-3">
<gl-button
v-if="restJob.erase_path"
v-gl-tooltip.bottom
:title="$options.i18n.eraseLogButtonLabel"
:aria-label="$options.i18n.eraseLogButtonLabel"
:href="restJob.erase_path"
:data-confirm="$options.i18n.eraseLogConfirmText"
data-testid="job-log-erase-link"
data-confirm-btn-variant="danger"
data-method="post"
icon="remove"
/>
<gl-button
v-if="restJob.new_issue_path"
v-gl-tooltip.bottom
:href="restJob.new_issue_path"
:title="$options.i18n.newIssue"
:aria-label="$options.i18n.newIssue"
category="secondary"
variant="confirm"
data-testid="job-new-issue"
icon="issue-new"
/>
<gl-button
v-if="restJob.terminal_path"
v-gl-tooltip.bottom
:href="restJob.terminal_path"
:title="$options.i18n.debug"
:aria-label="$options.i18n.debug"
target="_blank"
icon="external-link"
data-testid="terminal-link"
/>
<job-sidebar-retry-button
v-if="canShowJobRetryButton"
v-gl-tooltip.bottom
:title="buttonTitle"
:aria-label="buttonTitle"
:is-manual-job="isManualJob"
:category="retryButtonCategory"
:href="restJob.retry_path"
:modal-id="$options.forwardDeploymentFailureModalId"
variant="confirm"
data-testid="retry-button"
@updateVariablesClicked="$emit('updateVariables')"
/>
<gl-button
v-if="restJob.cancel_path"
v-gl-tooltip.bottom
:title="$options.i18n.cancelJobButtonLabel"
:aria-label="$options.i18n.cancelJobButtonLabel"
:href="restJob.cancel_path"
variant="danger"
icon="cancel"
data-method="post"
data-testid="cancel-button"
rel="nofollow"
/>
</div>
</div>
</template>
|