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

242 lines
5.9 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2018-11-20 20:47:30 +05:30
import LoadingIcon from '~/vue_shared/components/loading_icon.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import { timeIntervalInWords } from '~/lib/utils/datetime_utility';
import Icon from '~/vue_shared/components/icon.vue';
import DetailRow from './sidebar_detail_row.vue';
2017-09-10 17:25:29 +05:30
2018-10-15 14:42:47 +05:30
export default {
name: 'SidebarDetailsBlock',
components: {
2018-11-20 20:47:30 +05:30
DetailRow,
LoadingIcon,
Icon,
2018-10-15 14:42:47 +05:30
},
mixins: [timeagoMixin],
props: {
job: {
type: Object,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
isLoading: {
type: Boolean,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
runnerHelpUrl: {
type: String,
required: false,
default: '',
},
2018-11-20 20:47:30 +05:30
terminalPath: {
type: String,
required: false,
default: null,
},
2018-10-15 14:42:47 +05:30
},
computed: {
shouldRenderContent() {
return !this.isLoading && Object.keys(this.job).length > 0;
},
coverage() {
return `${this.job.coverage}%`;
},
duration() {
return timeIntervalInWords(this.job.duration);
},
queued() {
return timeIntervalInWords(this.job.queued);
},
runnerId() {
return `${this.job.runner.description} (#${this.job.runner.id})`;
},
retryButtonClass() {
2018-11-08 19:23:39 +05:30
let className =
'js-retry-button float-right btn btn-retry d-none d-md-block d-lg-block d-xl-block';
2018-10-15 14:42:47 +05:30
className +=
2018-11-08 19:23:39 +05:30
this.job.status && this.job.recoverable ? ' btn-primary' : ' btn-inverted-secondary';
2018-10-15 14:42:47 +05:30
return className;
},
hasTimeout() {
return this.job.metadata != null && this.job.metadata.timeout_human_readable !== null;
},
timeout() {
if (this.job.metadata == null) {
return '';
}
2018-05-09 12:01:36 +05:30
2018-10-15 14:42:47 +05:30
let t = this.job.metadata.timeout_human_readable;
if (this.job.metadata.timeout_source !== '') {
t += ` (from ${this.job.metadata.timeout_source})`;
}
2018-05-09 12:01:36 +05:30
2018-10-15 14:42:47 +05:30
return t;
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
renderBlock() {
return (
this.job.merge_request ||
this.job.duration ||
this.job.finished_data ||
this.job.erased_at ||
this.job.queued ||
this.job.runner ||
this.job.coverage ||
this.job.tags.length ||
this.job.cancel_path
);
},
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
<div>
2018-10-15 14:42:47 +05:30
<div class="block">
<strong class="inline prepend-top-8">
{{ job.name }}
</strong>
<a
2018-11-20 20:47:30 +05:30
v-if="job.retry_path"
2018-10-15 14:42:47 +05:30
:class="retryButtonClass"
:href="job.retry_path"
data-method="post"
rel="nofollow"
>
{{ __('Retry') }}
</a>
2018-11-20 20:47:30 +05:30
<a
v-if="terminalPath"
:href="terminalPath"
class="js-terminal-link pull-right btn btn-primary
btn-inverted visible-md-block visible-lg-block"
target="_blank"
>
{{ __('Debug') }}
<icon name="external-link" />
</a>
2018-10-15 14:42:47 +05:30
<button
:aria-label="__('Toggle Sidebar')"
2018-11-08 19:23:39 +05:30
type="button"
class="btn btn-blank gutter-toggle float-right d-block d-md-none js-sidebar-build-toggle"
2018-10-15 14:42:47 +05:30
>
<i
aria-hidden="true"
data-hidden="true"
class="fa fa-angle-double-right"
></i>
</button>
</div>
2017-09-10 17:25:29 +05:30
<template v-if="shouldRenderContent">
<div
2018-03-17 18:26:18 +05:30
v-if="job.retry_path || job.new_issue_path"
2018-11-08 19:23:39 +05:30
class="block retry-link"
2018-03-17 18:26:18 +05:30
>
2017-09-10 17:25:29 +05:30
<a
v-if="job.new_issue_path"
2018-03-17 18:26:18 +05:30
:href="job.new_issue_path"
2018-11-08 19:23:39 +05:30
class="js-new-issue btn btn-new btn-inverted"
2018-03-17 18:26:18 +05:30
>
2018-10-15 14:42:47 +05:30
{{ __('New issue') }}
2017-09-10 17:25:29 +05:30
</a>
<a
2018-11-20 20:47:30 +05:30
v-if="job.retry_path"
2017-09-10 17:25:29 +05:30
:href="job.retry_path"
2018-11-08 19:23:39 +05:30
class="js-retry-job btn btn-inverted-secondary"
2017-09-10 17:25:29 +05:30
data-method="post"
2018-03-17 18:26:18 +05:30
rel="nofollow"
>
2018-10-15 14:42:47 +05:30
{{ __('Retry') }}
2017-09-10 17:25:29 +05:30
</a>
</div>
<div :class="{block : renderBlock }">
<p
2018-03-17 18:26:18 +05:30
v-if="job.merge_request"
2018-11-08 19:23:39 +05:30
class="build-detail-row js-job-mr"
2018-03-17 18:26:18 +05:30
>
<span class="build-light-text">
2018-10-15 14:42:47 +05:30
{{ __('Merge Request:') }}
2017-09-10 17:25:29 +05:30
</span>
<a :href="job.merge_request.path">
2018-03-17 18:26:18 +05:30
!{{ job.merge_request.iid }}
2017-09-10 17:25:29 +05:30
</a>
</p>
<detail-row
v-if="job.duration"
:value="duration"
2018-11-08 19:23:39 +05:30
class="js-job-duration"
title="Duration"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
<detail-row
v-if="job.finished_at"
:value="timeFormated(job.finished_at)"
2018-11-08 19:23:39 +05:30
class="js-job-finished"
title="Finished"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
<detail-row
v-if="job.erased_at"
:value="timeFormated(job.erased_at)"
2018-11-08 19:23:39 +05:30
class="js-job-erased"
title="Erased"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
<detail-row
v-if="job.queued"
:value="queued"
2018-11-08 19:23:39 +05:30
class="js-job-queued"
title="Queued"
2018-03-17 18:26:18 +05:30
/>
2018-05-09 12:01:36 +05:30
<detail-row
v-if="hasTimeout"
:help-url="runnerHelpUrl"
:value="timeout"
2018-11-08 19:23:39 +05:30
class="js-job-timeout"
title="Timeout"
2018-05-09 12:01:36 +05:30
/>
2017-09-10 17:25:29 +05:30
<detail-row
v-if="job.runner"
:value="runnerId"
2018-11-08 19:23:39 +05:30
class="js-job-runner"
title="Runner"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
<detail-row
v-if="job.coverage"
:value="coverage"
2018-11-08 19:23:39 +05:30
class="js-job-coverage"
title="Coverage"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
<p
2018-03-17 18:26:18 +05:30
v-if="job.tags.length"
2018-11-08 19:23:39 +05:30
class="build-detail-row js-job-tags"
2018-03-17 18:26:18 +05:30
>
<span class="build-light-text">
2018-10-15 14:42:47 +05:30
{{ __('Tags:') }}
2017-09-10 17:25:29 +05:30
</span>
<span
2018-03-17 18:26:18 +05:30
v-for="(tag, i) in job.tags"
:key="i"
2017-09-10 17:25:29 +05:30
class="label label-primary">
2018-03-17 18:26:18 +05:30
{{ tag }}
2017-09-10 17:25:29 +05:30
</span>
</p>
<div
v-if="job.cancel_path"
class="btn-group prepend-top-5"
role="group">
<a
:href="job.cancel_path"
2018-11-08 19:23:39 +05:30
class="js-cancel-job btn btn-sm btn-default"
2017-09-10 17:25:29 +05:30
data-method="post"
2018-03-17 18:26:18 +05:30
rel="nofollow"
>
2018-10-15 14:42:47 +05:30
{{ __('Cancel') }}
2017-09-10 17:25:29 +05:30
</a>
</div>
</div>
</template>
<loading-icon
v-if="isLoading"
2018-11-08 19:23:39 +05:30
class="prepend-top-10"
2017-09-10 17:25:29 +05:30
size="2"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
</div>
</template>