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
|
<script>
import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import Tracking from '~/tracking';
import { BUTTON_TOOLTIP_RETRY, BUTTON_TOOLTIP_CANCEL, TRACKING_CATEGORIES } from '~/ci/constants';
import PipelineMultiActions from './pipeline_multi_actions.vue';
import PipelinesManualActions from './pipelines_manual_actions.vue';
import PipelineStopModal from './pipeline_stop_modal.vue';
export default {
BUTTON_TOOLTIP_RETRY,
BUTTON_TOOLTIP_CANCEL,
directives: {
GlTooltip: GlTooltipDirective,
},
components: {
GlButton,
PipelineMultiActions,
PipelinesManualActions,
PipelineStopModal,
},
mixins: [Tracking.mixin()],
props: {
pipeline: {
type: Object,
required: true,
},
},
data() {
return {
isCanceling: false,
isRetrying: false,
showConfirmationModal: false,
};
},
computed: {
hasActions() {
return (
this.pipeline?.details?.has_manual_actions || this.pipeline?.details?.has_scheduled_actions
);
},
},
watch: {
pipeline() {
if (this.isCanceling || this.isRetrying) {
this.isCanceling = false;
this.isRetrying = false;
}
},
},
methods: {
onCloseModal() {
this.showConfirmationModal = false;
},
onConfirmCancelPipeline() {
this.isCanceling = true;
this.showConfirmationModal = false;
this.$emit('cancel-pipeline', this.pipeline);
},
handleCancelClick() {
this.showConfirmationModal = true;
this.trackClick('click_cancel_button');
},
handleRetryClick() {
this.isRetrying = true;
this.trackClick('click_retry_button');
this.$emit('retry-pipeline', this.pipeline);
},
trackClick(action) {
this.track(action, { label: TRACKING_CATEGORIES.table });
},
},
};
</script>
<template>
<div class="gl-text-right">
<pipeline-stop-modal
:pipeline="pipeline"
:show-confirmation-modal="showConfirmationModal"
@submit="onConfirmCancelPipeline"
@close-modal="onCloseModal"
/>
<div class="btn-group">
<pipelines-manual-actions
v-if="hasActions"
:iid="pipeline.iid"
@refresh-pipeline-table="$emit('refresh-pipelines-table')"
/>
<gl-button
v-if="pipeline.flags.retryable"
v-gl-tooltip.hover
:aria-label="$options.BUTTON_TOOLTIP_RETRY"
:title="$options.BUTTON_TOOLTIP_RETRY"
:disabled="isRetrying"
:loading="isRetrying"
class="js-pipelines-retry-button"
data-testid="pipelines-retry-button"
icon="retry"
variant="default"
category="secondary"
@click="handleRetryClick"
/>
<gl-button
v-if="pipeline.flags.cancelable"
v-gl-tooltip.hover
:aria-label="$options.BUTTON_TOOLTIP_CANCEL"
:title="$options.BUTTON_TOOLTIP_CANCEL"
:loading="isCanceling"
:disabled="isCanceling"
icon="cancel"
variant="danger"
category="primary"
class="js-pipelines-cancel-button gl-ml-1"
data-testid="pipelines-cancel-button"
@click="handleCancelClick"
/>
<pipeline-multi-actions :pipeline-id="pipeline.id" />
</div>
</div>
</template>
|