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
|
<script>
import { GlBadge, GlTabs, GlTab } from '@gitlab/ui';
import { __ } from '~/locale';
import {
failedJobsTabName,
jobsTabName,
needsTabName,
pipelineTabName,
testReportTabName,
} from '../constants';
export default {
i18n: {
tabs: {
failedJobsTitle: __('Failed Jobs'),
jobsTitle: __('Jobs'),
needsTitle: __('Needs'),
pipelineTitle: __('Pipeline'),
testsTitle: __('Tests'),
},
},
tabNames: {
pipeline: pipelineTabName,
needs: needsTabName,
jobs: jobsTabName,
failures: failedJobsTabName,
tests: testReportTabName,
},
components: {
GlBadge,
GlTab,
GlTabs,
},
inject: ['defaultTabValue', 'failedJobsCount', 'totalJobCount', 'testsCount'],
data() {
return {
activeTab: this.defaultTabValue,
};
},
computed: {
showFailedJobsTab() {
return this.failedJobsCount > 0;
},
},
watch: {
$route(to) {
this.activeTab = to.name;
},
},
methods: {
isActive(tabName) {
return tabName === this.activeTab;
},
navigateTo(tabName) {
if (this.isActive(tabName)) return;
this.$router.push({ name: tabName });
},
},
};
</script>
<template>
<gl-tabs>
<gl-tab
ref="pipelineTab"
:title="$options.i18n.tabs.pipelineTitle"
:active="isActive($options.tabNames.pipeline)"
data-testid="pipeline-tab"
lazy
@click="navigateTo($options.tabNames.pipeline)"
>
<router-view />
</gl-tab>
<gl-tab
ref="dagTab"
:title="$options.i18n.tabs.needsTitle"
:active="isActive($options.tabNames.needs)"
data-testid="dag-tab"
lazy
@click="navigateTo($options.tabNames.needs)"
>
<router-view />
</gl-tab>
<gl-tab
:active="isActive($options.tabNames.jobs)"
data-testid="jobs-tab"
lazy
@click="navigateTo($options.tabNames.jobs)"
>
<template #title>
<span class="gl-mr-2">{{ $options.i18n.tabs.jobsTitle }}</span>
<gl-badge size="sm" data-testid="builds-counter">{{ totalJobCount }}</gl-badge>
</template>
<router-view />
</gl-tab>
<gl-tab
v-if="showFailedJobsTab"
:title="$options.i18n.tabs.failedJobsTitle"
:active="isActive($options.tabNames.failures)"
data-testid="failed-jobs-tab"
lazy
@click="navigateTo($options.tabNames.failures)"
>
<template #title>
<span class="gl-mr-2">{{ $options.i18n.tabs.failedJobsTitle }}</span>
<gl-badge size="sm" data-testid="failed-builds-counter">{{ failedJobsCount }}</gl-badge>
</template>
<router-view />
</gl-tab>
<gl-tab
:active="isActive($options.tabNames.tests)"
data-testid="tests-tab"
lazy
@click="navigateTo($options.tabNames.tests)"
>
<template #title>
<span class="gl-mr-2">{{ $options.i18n.tabs.testsTitle }}</span>
<gl-badge size="sm" data-testid="tests-counter">{{ testsCount }}</gl-badge>
</template>
<router-view />
</gl-tab>
<slot></slot>
</gl-tabs>
</template>
|