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

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

108 lines
2.7 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';
2022-04-04 11:22:00 +05:30
import { sprintf, formatNumber } from '~/locale';
import { createAlert } from '~/flash';
2022-07-16 23:28:13 +05:30
import runnerProjectsQuery from '../graphql/show/runner_projects.query.graphql';
2022-04-04 11:22:00 +05:30
import {
I18N_ASSIGNED_PROJECTS,
I18N_NONE,
I18N_FETCH_ERROR,
RUNNER_DETAILS_PROJECTS_PAGE_SIZE,
} from '../constants';
import { getPaginationVariables } from '../utils';
import { captureException } from '../sentry_utils';
import RunnerAssignedItem from './runner_assigned_item.vue';
import RunnerPagination from './runner_pagination.vue';
export default {
name: 'RunnerProjects',
components: {
2022-07-23 23:45:48 +05:30
GlSkeletonLoader,
2022-04-04 11:22:00 +05:30
RunnerAssignedItem,
RunnerPagination,
},
props: {
runner: {
type: Object,
required: true,
},
},
data() {
return {
projects: {
items: [],
pageInfo: {},
count: 0,
},
pagination: {
page: 1,
},
};
},
apollo: {
projects: {
2022-05-07 20:08:51 +05:30
query: runnerProjectsQuery,
2022-04-04 11:22:00 +05:30
variables() {
return this.variables;
},
update(data) {
const { runner } = data;
return {
count: runner?.projectCount || 0,
items: runner?.projects?.nodes || [],
pageInfo: runner?.projects?.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_PROJECTS_PAGE_SIZE),
};
},
loading() {
return this.$apollo.queries.projects.loading;
},
heading() {
return sprintf(I18N_ASSIGNED_PROJECTS, {
projectCount: formatNumber(this.projects.count),
});
},
},
I18N_NONE,
};
</script>
<template>
<div class="gl-border-t-gray-100 gl-border-t-1 gl-border-t-solid">
<h3 class="gl-font-lg gl-mt-5 gl-mb-0">
{{ heading }}
</h3>
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
<template v-else-if="projects.items.length">
<runner-assigned-item
v-for="(project, i) in projects.items"
:key="project.id"
:class="{ 'gl-border-t-gray-100 gl-border-t-1 gl-border-t-solid': i !== 0 }"
:href="project.webUrl"
:name="project.name"
:full-name="project.nameWithNamespace"
:avatar-url="project.avatarUrl"
/>
</template>
<span v-else class="gl-text-gray-500">{{ $options.I18N_NONE }}</span>
<runner-pagination v-model="pagination" :disabled="loading" :page-info="projects.pageInfo" />
</div>
</template>