2021-04-29 21:17:54 +05:30
|
|
|
<script>
|
|
|
|
import { GlTable } from '@gitlab/ui';
|
2021-09-04 01:27:46 +05:30
|
|
|
import { DEFAULT_TH_CLASSES } from '~/lib/utils/constants';
|
2021-06-08 01:23:25 +05:30
|
|
|
import { s__, __ } from '~/locale';
|
|
|
|
import CiBadge from '~/vue_shared/components/ci_badge_link.vue';
|
|
|
|
import ActionsCell from './cells/actions_cell.vue';
|
|
|
|
import DurationCell from './cells/duration_cell.vue';
|
|
|
|
import JobCell from './cells/job_cell.vue';
|
|
|
|
import PipelineCell from './cells/pipeline_cell.vue';
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
const defaultTableClasses = {
|
|
|
|
tdClass: 'gl-p-5!',
|
2021-09-04 01:27:46 +05:30
|
|
|
thClass: DEFAULT_TH_CLASSES,
|
2021-04-29 21:17:54 +05:30
|
|
|
};
|
2021-06-08 01:23:25 +05:30
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
|
|
|
const coverageTdClasses = `${defaultTableClasses.tdClass} gl-display-none! gl-lg-display-table-cell!`;
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
export default {
|
2021-06-08 01:23:25 +05:30
|
|
|
i18n: {
|
|
|
|
emptyText: s__('Jobs|No jobs to show'),
|
|
|
|
},
|
2021-04-29 21:17:54 +05:30
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
key: 'status',
|
|
|
|
label: __('Status'),
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-10p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'job',
|
|
|
|
label: __('Job'),
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-20p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'pipeline',
|
|
|
|
label: __('Pipeline'),
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-10p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'stage',
|
|
|
|
label: __('Stage'),
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-10p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'name',
|
|
|
|
label: __('Name'),
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-15p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'duration',
|
|
|
|
label: __('Duration'),
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-15p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'coverage',
|
|
|
|
label: __('Coverage'),
|
2021-06-08 01:23:25 +05:30
|
|
|
tdClass: coverageTdClasses,
|
|
|
|
thClass: defaultTableClasses.thClass,
|
|
|
|
columnClass: 'gl-w-10p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'actions',
|
|
|
|
label: '',
|
|
|
|
...defaultTableClasses,
|
2021-06-08 01:23:25 +05:30
|
|
|
columnClass: 'gl-w-10p',
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
],
|
|
|
|
components: {
|
2021-06-08 01:23:25 +05:30
|
|
|
ActionsCell,
|
|
|
|
CiBadge,
|
|
|
|
DurationCell,
|
2021-04-29 21:17:54 +05:30
|
|
|
GlTable,
|
2021-06-08 01:23:25 +05:30
|
|
|
JobCell,
|
|
|
|
PipelineCell,
|
2021-04-29 21:17:54 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
jobs: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2021-06-08 01:23:25 +05:30
|
|
|
methods: {
|
|
|
|
formatCoverage(coverage) {
|
|
|
|
return coverage ? `${coverage}%` : '';
|
|
|
|
},
|
|
|
|
},
|
2021-04-29 21:17:54 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-06-08 01:23:25 +05:30
|
|
|
<gl-table
|
|
|
|
:items="jobs"
|
|
|
|
:fields="$options.fields"
|
|
|
|
:tbody-tr-attr="{ 'data-testid': 'jobs-table-row' }"
|
|
|
|
:empty-text="$options.i18n.emptyText"
|
|
|
|
show-empty
|
|
|
|
stacked="lg"
|
|
|
|
fixed
|
|
|
|
>
|
|
|
|
<template #table-colgroup="{ fields }">
|
|
|
|
<col v-for="field in fields" :key="field.key" :class="field.columnClass" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(status)="{ item }">
|
|
|
|
<ci-badge :status="item.detailedStatus" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(job)="{ item }">
|
|
|
|
<job-cell :job="item" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(pipeline)="{ item }">
|
|
|
|
<pipeline-cell :job="item" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(stage)="{ item }">
|
|
|
|
<div class="gl-text-truncate">
|
|
|
|
<span data-testid="job-stage-name">{{ item.stage.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(name)="{ item }">
|
|
|
|
<div class="gl-text-truncate">
|
|
|
|
<span data-testid="job-name">{{ item.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(duration)="{ item }">
|
|
|
|
<duration-cell :job="item" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(coverage)="{ item }">
|
|
|
|
<span v-if="item.coverage" data-testid="job-coverage">{{
|
|
|
|
formatCoverage(item.coverage)
|
|
|
|
}}</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #cell(actions)="{ item }">
|
2021-11-11 11:23:49 +05:30
|
|
|
<actions-cell class="gl-float-right" :job="item" />
|
2021-06-08 01:23:25 +05:30
|
|
|
</template>
|
|
|
|
</gl-table>
|
2021-04-29 21:17:54 +05:30
|
|
|
</template>
|