debian-mirror-gitlab/app/assets/javascripts/jobs/components/sidebar_job_details_container.vue

109 lines
3 KiB
Vue
Raw Normal View History

2021-01-29 00:20:46 +05:30
<script>
import { mapState } from 'vuex';
2022-03-02 08:16:31 +05:30
import { GlBadge } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { helpPagePath } from '~/helpers/help_page_helper';
import { timeIntervalInWords } from '~/lib/utils/datetime_utility';
2021-01-29 00:20:46 +05:30
import { __, sprintf } from '~/locale';
import timeagoMixin from '~/vue_shared/mixins/timeago';
2021-03-11 19:13:27 +05:30
import DetailRow from './sidebar_detail_row.vue';
2021-01-29 00:20:46 +05:30
export default {
name: 'JobSidebarDetailsContainer',
components: {
DetailRow,
2022-03-02 08:16:31 +05:30
GlBadge,
2021-01-29 00:20:46 +05:30
},
mixins: [timeagoMixin],
computed: {
...mapState(['job']),
coverage() {
return `${this.job.coverage}%`;
},
duration() {
return timeIntervalInWords(this.job.duration);
},
2022-01-26 12:08:38 +05:30
durationTitle() {
return this.job.finished_at ? __('Duration') : __('Elapsed time');
},
2021-01-29 00:20:46 +05:30
erasedAt() {
return this.timeFormatted(this.job.erased_at);
},
finishedAt() {
return this.timeFormatted(this.job.finished_at);
},
hasTags() {
return this.job?.tags?.length;
},
hasTimeout() {
return this.job?.metadata?.timeout_human_readable ?? false;
},
hasAnyDetail() {
return Boolean(
this.job.duration ||
this.job.finished_at ||
this.job.erased_at ||
this.job.queued ||
this.job.runner ||
this.job.coverage,
);
},
queued() {
return timeIntervalInWords(this.job.queued);
},
2021-03-11 19:13:27 +05:30
runnerHelpUrl() {
2021-10-27 15:23:28 +05:30
return helpPagePath('ci/runners/configure_runners.html', {
2021-03-11 19:13:27 +05:30
anchor: 'set-maximum-job-timeout-for-a-runner',
});
},
2021-01-29 00:20:46 +05:30
runnerId() {
2021-04-29 21:17:54 +05:30
const { id, short_sha: token, description } = this.job?.runner;
return `#${id} (${token}) ${description}`;
2021-01-29 00:20:46 +05:30
},
shouldRenderBlock() {
return Boolean(this.hasAnyDetail || this.hasTimeout || this.hasTags);
},
timeout() {
return `${this.job?.metadata?.timeout_human_readable}${this.timeoutSource}`;
},
timeoutSource() {
if (!this.job?.metadata?.timeout_source) {
return '';
}
return sprintf(__(` (from %{timeoutSource})`), {
timeoutSource: this.job.metadata.timeout_source,
});
},
},
};
</script>
<template>
2021-04-17 20:07:23 +05:30
<div v-if="shouldRenderBlock">
2022-01-26 12:08:38 +05:30
<detail-row v-if="job.duration" :value="duration" :title="durationTitle" />
2021-01-29 00:20:46 +05:30
<detail-row
v-if="job.finished_at"
:value="finishedAt"
data-testid="job-finished"
title="Finished"
/>
<detail-row v-if="job.erased_at" :value="erasedAt" title="Erased" />
<detail-row v-if="job.queued" :value="queued" title="Queued" />
<detail-row
v-if="hasTimeout"
:help-url="runnerHelpUrl"
:value="timeout"
data-testid="job-timeout"
title="Timeout"
/>
<detail-row v-if="job.runner" :value="runnerId" title="Runner" />
<detail-row v-if="job.coverage" :value="coverage" title="Coverage" />
<p v-if="hasTags" class="build-detail-row" data-testid="job-tags">
<span class="font-weight-bold">{{ __('Tags:') }}</span>
2022-03-02 08:16:31 +05:30
<gl-badge v-for="(tag, i) in job.tags" :key="i" variant="info">{{ tag }}</gl-badge>
2021-01-29 00:20:46 +05:30
</p>
</div>
</template>