Welcome to mirror list, hosted at ThFree Co, Russian Federation.

runner_jobs_table.vue « components « runner « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: efa7909c913ba86b4bf6e5e03ed22e193e7ed877 (plain)
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
<script>
import { GlTableLite } from '@gitlab/ui';
import { __, s__ } from '~/locale';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { durationTimeFormatted } from '~/lib/utils/datetime_utility';
import CiBadge from '~/vue_shared/components/ci_badge_link.vue';
import RunnerTags from '~/ci/runner/components/runner_tags.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import { tableField } from '../utils';
import LinkCell from './cells/link_cell.vue';

export default {
  components: {
    CiBadge,
    GlTableLite,
    LinkCell,
    RunnerTags,
    TimeAgo,
  },
  props: {
    jobs: {
      type: Array,
      required: true,
    },
  },
  methods: {
    trAttr(job) {
      if (job?.id) {
        return { 'data-testid': `job-row-${getIdFromGraphQLId(job.id)}` };
      }
      return {};
    },
    jobId(job) {
      return getIdFromGraphQLId(job.id);
    },
    jobPath(job) {
      return job.detailedStatus?.detailsPath;
    },
    projectName(job) {
      return job.pipeline?.project?.name;
    },
    projectWebUrl(job) {
      return job.pipeline?.project?.webUrl;
    },
    commitShortSha(job) {
      return job.shortSha;
    },
    commitPath(job) {
      return job.commitPath;
    },
    duration(job) {
      const { duration } = job;
      return duration ? durationTimeFormatted(duration) : '';
    },
    queued(job) {
      const { queuedDuration } = job;
      return queuedDuration ? durationTimeFormatted(queuedDuration) : '';
    },
  },
  fields: [
    tableField({ key: 'status', label: s__('Job|Status') }),
    tableField({ key: 'job', label: __('Job') }),
    tableField({ key: 'project', label: __('Project') }),
    tableField({ key: 'commit', label: __('Commit') }),
    tableField({ key: 'finished_at', label: s__('Job|Finished at') }),
    tableField({ key: 'duration', label: s__('Job|Duration') }),
    tableField({ key: 'queued', label: s__('Job|Queued') }),
    tableField({ key: 'tags', label: s__('Runners|Tags') }),
  ],
};
</script>

<template>
  <gl-table-lite
    :items="jobs"
    :fields="$options.fields"
    :tbody-tr-attr="trAttr"
    primary-key="id"
    stacked="md"
    fixed
  >
    <template #cell(status)="{ item = {} }">
      <ci-badge v-if="item.detailedStatus" :status="item.detailedStatus" />
    </template>

    <template #cell(job)="{ item = {} }">
      <link-cell :href="jobPath(item)"> #{{ jobId(item) }} </link-cell>
    </template>

    <template #cell(project)="{ item = {} }">
      <link-cell :href="projectWebUrl(item)">{{ projectName(item) }}</link-cell>
    </template>

    <template #cell(commit)="{ item = {} }">
      <link-cell :href="commitPath(item)"> {{ commitShortSha(item) }}</link-cell>
    </template>

    <template #cell(finished_at)="{ item = {} }">
      <time-ago v-if="item.finishedAt" :time="item.finishedAt" />
    </template>

    <template #cell(duration)="{ item = {} }">
      {{ duration(item) }}
    </template>

    <template #cell(queued)="{ item = {} }">
      {{ queued(item) }}
    </template>

    <template #cell(tags)="{ item = {} }">
      <runner-tags :tag-list="item.tags" />
    </template>
  </gl-table-lite>
</template>