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
|
<script>
import { GlBadge, GlTabs, GlTab } from '@gitlab/ui';
import VueRouter from 'vue-router';
import HelpPopover from '~/vue_shared/components/help_popover.vue';
import { JOBS_ROUTE_PATH, I18N_DETAILS, I18N_JOBS } from '../constants';
import { formatJobCount } from '../utils';
import RunnerDetails from './runner_details.vue';
import RunnerJobs from './runner_jobs.vue';
const ROUTE_DETAILS = 'details';
const ROUTE_JOBS = 'jobs';
const routes = [
{
path: '/',
name: ROUTE_DETAILS,
component: RunnerDetails,
},
{
path: JOBS_ROUTE_PATH,
name: ROUTE_JOBS,
component: RunnerJobs,
},
{ path: '*', redirect: { name: ROUTE_DETAILS } },
];
export default {
name: 'RunnerDetailsTabs',
components: {
GlBadge,
GlTabs,
GlTab,
HelpPopover,
},
router: new VueRouter({
routes,
}),
props: {
runner: {
type: Object,
required: false,
default: null,
},
showAccessHelp: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
jobCount() {
return formatJobCount(this.runner?.jobCount);
},
tabIndex() {
return routes.findIndex(({ name }) => name === this.$route.name);
},
},
methods: {
goTo(name) {
if (this.$route.name !== name) {
this.$router.push({ name });
}
},
},
ROUTE_DETAILS,
ROUTE_JOBS,
I18N_DETAILS,
I18N_JOBS,
};
</script>
<template>
<gl-tabs :value="tabIndex">
<gl-tab @click="goTo($options.ROUTE_DETAILS)">
<template #title>{{ $options.I18N_DETAILS }}</template>
</gl-tab>
<gl-tab @click="goTo($options.ROUTE_JOBS)">
<template #title>
{{ $options.I18N_JOBS }}
<gl-badge
v-if="jobCount"
data-testid="job-count-badge"
class="gl-tab-counter-badge"
size="sm"
>
{{ jobCount }}
</gl-badge>
<help-popover v-if="showAccessHelp" class="gl-ml-3">
{{ s__('Runners|Jobs in projects you have access to.') }}
</help-popover>
</template>
</gl-tab>
<router-view v-if="runner" :runner="runner" />
</gl-tabs>
</template>
|