debian-mirror-gitlab/app/assets/javascripts/releases/components/release_block_metadata.vue

92 lines
2.4 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
import { GlTooltipDirective, GlLink } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import ReleaseBlockAuthor from './release_block_author.vue';
import ReleaseBlockMilestones from './release_block_milestones.vue';
export default {
name: 'ReleaseBlockMetadata',
components: {
Icon,
GlLink,
ReleaseBlockAuthor,
ReleaseBlockMilestones,
},
directives: {
GlTooltip: GlTooltipDirective,
},
mixins: [timeagoMixin],
props: {
release: {
type: Object,
required: true,
},
},
computed: {
author() {
return this.release.author;
},
commit() {
return this.release.commit || {};
},
commitUrl() {
2020-04-08 14:13:33 +05:30
return this.release.commitPath;
2020-03-13 15:44:24 +05:30
},
hasAuthor() {
return Boolean(this.author);
},
releasedTimeAgo() {
2020-05-24 23:13:21 +05:30
const now = new Date();
const isFuture = now < new Date(this.release.releasedAt);
const time = this.timeFormatted(this.release.releasedAt);
return isFuture
? sprintf(__('will be released %{time}'), { time })
: sprintf(__('released %{time}'), { time });
2020-03-13 15:44:24 +05:30
},
shouldRenderMilestones() {
return Boolean(this.release.milestones?.length);
},
tagUrl() {
2020-04-08 14:13:33 +05:30
return this.release.tagPath;
2020-03-13 15:44:24 +05:30
},
},
};
</script>
<template>
<div class="card-subtitle d-flex flex-wrap text-secondary">
2020-06-23 00:09:42 +05:30
<div class="gl-mr-3">
2020-03-13 15:44:24 +05:30
<icon name="commit" class="align-middle" />
<gl-link v-if="commitUrl" v-gl-tooltip.bottom :title="commit.title" :href="commitUrl">
2020-04-08 14:13:33 +05:30
{{ commit.shortId }}
2020-03-13 15:44:24 +05:30
</gl-link>
2020-04-08 14:13:33 +05:30
<span v-else v-gl-tooltip.bottom :title="commit.title">{{ commit.shortId }}</span>
2020-03-13 15:44:24 +05:30
</div>
2020-06-23 00:09:42 +05:30
<div class="gl-mr-3">
2020-03-13 15:44:24 +05:30
<icon name="tag" class="align-middle" />
<gl-link v-if="tagUrl" v-gl-tooltip.bottom :title="__('Tag')" :href="tagUrl">
2020-04-08 14:13:33 +05:30
{{ release.tagName }}
2020-03-13 15:44:24 +05:30
</gl-link>
2020-04-08 14:13:33 +05:30
<span v-else v-gl-tooltip.bottom :title="__('Tag')">{{ release.tagName }}</span>
2020-03-13 15:44:24 +05:30
</div>
<release-block-milestones v-if="shouldRenderMilestones" :milestones="release.milestones" />
2020-07-28 23:09:34 +05:30
<div class="gl-mr-2">
2020-03-13 15:44:24 +05:30
&bull;
2020-05-24 23:13:21 +05:30
<span
v-gl-tooltip.bottom
class="js-release-date-info"
:title="tooltipTitle(release.releasedAt)"
>
2020-03-13 15:44:24 +05:30
{{ releasedTimeAgo }}
</span>
</div>
<release-block-author v-if="hasAuthor" :author="author" />
</div>
</template>