Commit 8ed14575 authored by Filipa Lacerda's avatar Filipa Lacerda

Renders pre-release tag for pre-releases

When a release is a pre release, we render
an orange badge with `pre-release` label
parent e999e1de
<script> <script>
import _ from 'underscore'; import _ from 'underscore';
import { GlTooltipDirective, GlLink } from '@gitlab/ui'; import { GlTooltipDirective, GlLink, GlBadge } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue'; import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
...@@ -10,6 +10,7 @@ export default { ...@@ -10,6 +10,7 @@ export default {
name: 'ReleaseBlock', name: 'ReleaseBlock',
components: { components: {
GlLink, GlLink,
GlBadge,
Icon, Icon,
UserAvatarLink, UserAvatarLink,
}, },
...@@ -53,7 +54,12 @@ export default { ...@@ -53,7 +54,12 @@ export default {
<template> <template>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h2 class="card-title mt-0">{{ release.name }}</h2> <h2 class="card-title mt-0">
{{ release.name }}
<gl-badge v-if="release.pre_release" variant="warning" class="align-middle">{{
__('Pre-release')
}}</gl-badge>
</h2>
<div class="card-subtitle d-flex flex-wrap text-secondary"> <div class="card-subtitle d-flex flex-wrap text-secondary">
<div class="append-right-8"> <div class="append-right-8">
...@@ -68,9 +74,9 @@ export default { ...@@ -68,9 +74,9 @@ export default {
<div class="append-right-4"> <div class="append-right-4">
&bull; &bull;
<span v-gl-tooltip.bottom :title="tooltipTitle(release.created_at)">{{ <span v-gl-tooltip.bottom :title="tooltipTitle(release.created_at)">
releasedTimeAgo {{ releasedTimeAgo }}
}}</span> </span>
</div> </div>
<div v-if="hasAuthor" class="d-flex"> <div v-if="hasAuthor" class="d-flex">
...@@ -98,7 +104,8 @@ export default { ...@@ -98,7 +104,8 @@ export default {
<li v-for="link in assets.links" :key="link.name" class="append-bottom-8"> <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"> <gl-link v-gl-tooltip.bottom :title="__('Download asset')" :href="link.url">
<icon name="package" class="align-middle append-right-4 align-text-bottom" /> <icon name="package" class="align-middle append-right-4 align-text-bottom" />
{{ link.name }} <span v-if="link.external"> {{ __('(external source)') }}</span> {{ link.name }}
<span v-if="link.external">{{ __('(external source)') }}</span>
</gl-link> </gl-link>
</li> </li>
</ul> </ul>
...@@ -111,7 +118,8 @@ export default { ...@@ -111,7 +118,8 @@ export default {
aria-haspopup="true" aria-haspopup="true"
aria-expanded="false" aria-expanded="false"
> >
<icon name="doc-code" class="align-top append-right-4" /> {{ __('Source code') }} <icon name="doc-code" class="align-top append-right-4" />
{{ __('Source code') }}
<icon name="arrow-down" /> <icon name="arrow-down" />
</button> </button>
...@@ -123,7 +131,9 @@ export default { ...@@ -123,7 +131,9 @@ export default {
</div> </div>
</div> </div>
<div class="card-text prepend-top-default"><div v-html="release.description_html"></div></div> <div class="card-text prepend-top-default">
<div v-html="release.description_html"></div>
</div>
</div> </div>
</div> </div>
</template> </template>
---
title: Renders a pre-release tag for releases
merge_request: 29797
author:
type: changed
...@@ -7330,6 +7330,9 @@ msgstr "" ...@@ -7330,6 +7330,9 @@ msgstr ""
msgid "Please wait while we import the repository for you. Refresh at will." msgid "Please wait while we import the repository for you. Refresh at will."
msgstr "" msgstr ""
msgid "Pre-release"
msgstr ""
msgid "Preferences" msgid "Preferences"
msgstr "" msgstr ""
......
...@@ -78,8 +78,10 @@ describe('Release block', () => { ...@@ -78,8 +78,10 @@ describe('Release block', () => {
}; };
let vm; let vm;
const factory = props => mountComponent(Component, { release: props });
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, { release }); vm = factory(release);
}); });
afterEach(() => { afterEach(() => {
...@@ -149,4 +151,14 @@ describe('Release block', () => { ...@@ -149,4 +151,14 @@ describe('Release block', () => {
); );
}); });
}); });
describe('with pre_release flag', () => {
beforeEach(() => {
vm = factory(Object.assign({}, release, { pre_release: true }));
});
it('renders pre-release badge', () => {
expect(vm.$el.textContent).toContain('Pre-release');
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment