debian-mirror-gitlab/app/assets/javascripts/ci/runner/components/runner_jobs.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2 KiB
Vue
Raw Normal View History

2022-04-04 11:22:00 +05:30
<script>
2022-07-23 23:45:48 +05:30
import { GlSkeletonLoader } from '@gitlab/ui';
2023-05-27 22:25:52 +05:30
import { createAlert } from '~/alert';
2022-07-16 23:28:13 +05:30
import runnerJobsQuery from '../graphql/show/runner_jobs.query.graphql';
2022-04-04 11:22:00 +05:30
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: {
2022-07-23 23:45:48 +05:30
GlSkeletonLoader,
2022-04-04 11:22:00 +05:30
RunnerJobsTable,
RunnerPagination,
},
props: {
runner: {
type: Object,
required: true,
},
},
data() {
return {
jobs: {
items: [],
pageInfo: {},
},
2022-08-27 11:52:29 +05:30
pagination: {},
2022-04-04 11:22:00 +05:30
};
},
apollo: {
jobs: {
2022-05-07 20:08:51 +05:30
query: runnerJobsQuery,
2022-04-04 11:22:00 +05:30
variables() {
return this.variables;
},
update({ runner }) {
return {
items: runner?.jobs?.nodes || [],
pageInfo: runner?.jobs?.pageInfo || {},
};
},
error(error) {
createAlert({ message: I18N_FETCH_ERROR });
2022-05-07 20:08:51 +05:30
captureException({ error, component: this.$options.name });
2022-04-04 11:22:00 +05:30
},
},
},
computed: {
variables() {
const { id } = this.runner;
return {
id,
...getPaginationVariables(this.pagination, RUNNER_DETAILS_JOBS_PAGE_SIZE),
};
},
loading() {
return this.$apollo.queries.jobs.loading;
},
},
2022-08-27 11:52:29 +05:30
methods: {
onPaginationInput(value) {
this.pagination = value;
},
},
2022-04-04 11:22:00 +05:30
I18N_NO_JOBS_FOUND,
};
</script>
<template>
<div class="gl-pt-3">
2022-07-23 23:45:48 +05:30
<div v-if="loading" class="gl-py-5">
<gl-skeleton-loader />
</div>
2022-04-04 11:22:00 +05:30
<runner-jobs-table v-else-if="jobs.items.length" :jobs="jobs.items" />
<p v-else>{{ $options.I18N_NO_JOBS_FOUND }}</p>
2022-08-27 11:52:29 +05:30
<runner-pagination :disabled="loading" :page-info="jobs.pageInfo" @input="onPaginationInput" />
2022-04-04 11:22:00 +05:30
</div>
</template>