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

163 lines
5 KiB
Vue
Raw Normal View History

2019-02-15 15:39:39 +05:30
<script>
2019-10-12 21:52:04 +05:30
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
2019-02-15 15:39:39 +05:30
import _ from 'underscore';
2019-09-30 21:07:59 +05:30
import { GlTooltipDirective, GlLink, GlBadge } from '@gitlab/ui';
2019-02-15 15:39:39 +05:30
import Icon from '~/vue_shared/components/icon.vue';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
2019-12-04 20:38:33 +05:30
import MilestoneList from './milestone_list.vue';
2019-09-30 21:07:59 +05:30
import { __, sprintf } from '../../locale';
2019-02-15 15:39:39 +05:30
export default {
name: 'ReleaseBlock',
components: {
GlLink,
2019-09-30 21:07:59 +05:30
GlBadge,
2019-02-15 15:39:39 +05:30
Icon,
UserAvatarLink,
2019-12-04 20:38:33 +05:30
MilestoneList,
2019-02-15 15:39:39 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
},
mixins: [timeagoMixin],
props: {
release: {
type: Object,
required: true,
default: () => ({}),
},
},
computed: {
releasedTimeAgo() {
2019-09-30 21:07:59 +05:30
return sprintf(__('released %{time}'), {
time: this.timeFormated(this.release.released_at),
2019-02-15 15:39:39 +05:30
});
},
userImageAltDescription() {
return this.author && this.author.username
2019-09-30 21:07:59 +05:30
? sprintf(__("%{username}'s avatar"), { username: this.author.username })
2019-02-15 15:39:39 +05:30
: null;
},
commit() {
return this.release.commit || {};
},
assets() {
return this.release.assets || {};
},
author() {
return this.release.author || {};
},
hasAuthor() {
return !_.isEmpty(this.author);
},
2019-12-04 20:38:33 +05:30
milestones() {
// At the moment, a release can only be associated to
// one milestone. This will be expanded to be many-to-many
// in the near future, so we pass the milestone as an
// array here in anticipation of this change.
return [this.release.milestone];
},
shouldRenderMilestones() {
// Similar to the `milestones` computed above,
// this check will need to be updated once
// the API begins sending an array of milestones
// instead of just a single object.
return Boolean(this.release.milestone);
},
2019-02-15 15:39:39 +05:30
},
};
</script>
<template>
2019-12-04 20:38:33 +05:30
<div :id="release.tag_name" class="card">
2019-02-15 15:39:39 +05:30
<div class="card-body">
2019-09-30 21:07:59 +05:30
<h2 class="card-title mt-0">
{{ release.name }}
<gl-badge v-if="release.upcoming_release" variant="warning" class="align-middle">{{
__('Upcoming Release')
}}</gl-badge>
</h2>
2019-02-15 15:39:39 +05:30
<div class="card-subtitle d-flex flex-wrap text-secondary">
<div class="append-right-8">
<icon name="commit" class="align-middle" />
<span v-gl-tooltip.bottom :title="commit.title">{{ commit.short_id }}</span>
</div>
<div class="append-right-8">
<icon name="tag" class="align-middle" />
<span v-gl-tooltip.bottom :title="__('Tag')">{{ release.tag_name }}</span>
</div>
2019-12-04 20:38:33 +05:30
<milestone-list
v-if="shouldRenderMilestones"
class="append-right-4 js-milestone-list"
:milestones="milestones"
/>
2019-02-15 15:39:39 +05:30
<div class="append-right-4">
&bull;
2019-09-30 21:07:59 +05:30
<span v-gl-tooltip.bottom :title="tooltipTitle(release.released_at)">
{{ releasedTimeAgo }}
</span>
2019-02-15 15:39:39 +05:30
</div>
<div v-if="hasAuthor" class="d-flex">
by
<user-avatar-link
class="prepend-left-4"
:link-href="author.path"
:img-src="author.avatar_url"
:img-alt="userImageAltDescription"
:tooltip-text="author.username"
/>
</div>
</div>
<div
2019-07-31 22:56:46 +05:30
v-if="assets.links.length || (assets.sources && assets.sources.length)"
2019-02-15 15:39:39 +05:30
class="card-text prepend-top-default"
>
<b>
{{ __('Assets') }}
<span class="js-assets-count badge badge-pill">{{ assets.count }}</span>
</b>
<ul v-if="assets.links.length" class="pl-0 mb-0 prepend-top-8 list-unstyled js-assets-list">
<li v-for="link in assets.links" :key="link.name" class="append-bottom-8">
<gl-link v-gl-tooltip.bottom :title="__('Download asset')" :href="link.url">
<icon name="package" class="align-middle append-right-4 align-text-bottom" />
2019-09-30 21:07:59 +05:30
{{ link.name }}
<span v-if="link.external">{{ __('(external source)') }}</span>
2019-02-15 15:39:39 +05:30
</gl-link>
</li>
</ul>
2019-07-31 22:56:46 +05:30
<div v-if="assets.sources && assets.sources.length" class="dropdown">
2019-02-15 15:39:39 +05:30
<button
type="button"
class="btn btn-link"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
2019-09-30 21:07:59 +05:30
<icon name="doc-code" class="align-top append-right-4" />
{{ __('Source code') }}
2019-02-15 15:39:39 +05:30
<icon name="arrow-down" />
</button>
<div class="js-sources-dropdown dropdown-menu">
<li v-for="asset in assets.sources" :key="asset.url">
<gl-link :href="asset.url">{{ __('Download') }} {{ asset.format }}</gl-link>
</li>
</div>
</div>
</div>
2019-09-30 21:07:59 +05:30
<div class="card-text prepend-top-default">
<div v-html="release.description_html"></div>
</div>
2019-02-15 15:39:39 +05:30
</div>
</div>
</template>