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
|
<script>
import { GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui';
import { createAlert } from '~/flash';
import runnerJobsQuery from '../graphql/show/runner_jobs.query.graphql';
import { I18N_FETCH_ERROR, I18N_NO_JOBS_FOUND, RUNNER_DETAILS_JOBS_PAGE_SIZE } from '../constants';
import { captureException } from '../sentry_utils';
import { getPaginationVariables } from '../utils';
import RunnerJobsTable from './runner_jobs_table.vue';
import RunnerPagination from './runner_pagination.vue';
export default {
name: 'RunnerJobs',
components: {
GlSkeletonLoading,
RunnerJobsTable,
RunnerPagination,
},
props: {
runner: {
type: Object,
required: true,
},
},
data() {
return {
jobs: {
items: [],
pageInfo: {},
},
pagination: {
page: 1,
},
};
},
apollo: {
jobs: {
query: runnerJobsQuery,
variables() {
return this.variables;
},
update({ runner }) {
return {
items: runner?.jobs?.nodes || [],
pageInfo: runner?.jobs?.pageInfo || {},
};
},
error(error) {
createAlert({ message: I18N_FETCH_ERROR });
captureException({ error, component: this.$options.name });
},
},
},
computed: {
variables() {
const { id } = this.runner;
return {
id,
...getPaginationVariables(this.pagination, RUNNER_DETAILS_JOBS_PAGE_SIZE),
};
},
loading() {
return this.$apollo.queries.jobs.loading;
},
},
I18N_NO_JOBS_FOUND,
};
</script>
<template>
<div class="gl-pt-3">
<gl-skeleton-loading v-if="loading" class="gl-py-5" />
<runner-jobs-table v-else-if="jobs.items.length" :jobs="jobs.items" />
<p v-else>{{ $options.I18N_NO_JOBS_FOUND }}</p>
<runner-pagination v-model="pagination" :disabled="loading" :page-info="jobs.pageInfo" />
</div>
</template>
|