debian-mirror-gitlab/app/assets/javascripts/packages/details/components/package_title.vue

87 lines
2.7 KiB
Vue
Raw Normal View History

2020-10-24 23:57:45 +05:30
<script>
import { mapState, mapGetters } from 'vuex';
2020-11-24 15:15:51 +05:30
import { GlIcon, GlSprintf, GlTooltipDirective } from '@gitlab/ui';
2020-10-24 23:57:45 +05:30
import PackageTags from '../../shared/components/package_tags.vue';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import timeagoMixin from '~/vue_shared/mixins/timeago';
2020-11-24 15:15:51 +05:30
import TitleArea from '~/vue_shared/components/registry/title_area.vue';
import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
2020-10-24 23:57:45 +05:30
import { __ } from '~/locale';
export default {
name: 'PackageTitle',
components: {
2020-11-24 15:15:51 +05:30
TitleArea,
2020-10-24 23:57:45 +05:30
GlIcon,
GlSprintf,
PackageTags,
2020-11-24 15:15:51 +05:30
MetadataItem,
2020-10-24 23:57:45 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
},
mixins: [timeagoMixin],
computed: {
...mapState(['packageEntity', 'packageFiles']),
...mapGetters(['packageTypeDisplay', 'packagePipeline', 'packageIcon']),
hasTagsToDisplay() {
return Boolean(this.packageEntity.tags && this.packageEntity.tags.length);
},
totalSize() {
return numberToHumanSize(this.packageFiles.reduce((acc, p) => acc + p.size, 0));
},
},
i18n: {
packageInfo: __('v%{version} published %{timeAgo}'),
},
};
</script>
<template>
2020-11-24 15:15:51 +05:30
<title-area :title="packageEntity.name" :avatar="packageIcon" data-qa-selector="package_title">
<template #sub-header>
<gl-icon name="eye" class="gl-mr-3" />
<gl-sprintf :message="$options.i18n.packageInfo">
<template #version>
{{ packageEntity.version }}
</template>
2020-10-24 23:57:45 +05:30
2020-11-24 15:15:51 +05:30
<template #timeAgo>
<span v-gl-tooltip :title="tooltipTitle(packageEntity.created_at)">
&nbsp;{{ timeFormatted(packageEntity.created_at) }}
</span>
</template>
</gl-sprintf>
</template>
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
<template v-if="packageTypeDisplay" #metadata-type>
2020-11-24 15:15:51 +05:30
<metadata-item data-testid="package-type" icon="package" :text="packageTypeDisplay" />
</template>
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
<template #metadata-size>
2020-11-24 15:15:51 +05:30
<metadata-item data-testid="package-size" icon="disk" :text="totalSize" />
</template>
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
<template v-if="packagePipeline" #metadata-pipeline>
2020-11-24 15:15:51 +05:30
<metadata-item
data-testid="pipeline-project"
icon="review-list"
:text="packagePipeline.project.name"
:link="packagePipeline.project.web_url"
/>
</template>
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
<template v-if="packagePipeline" #metadata-ref>
2020-11-24 15:15:51 +05:30
<metadata-item data-testid="package-ref" icon="branch" :text="packagePipeline.ref" />
</template>
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
<template v-if="hasTagsToDisplay" #metadata-tags>
2020-11-24 15:15:51 +05:30
<package-tags :tag-display-limit="2" :tags="packageEntity.tags" hide-label />
</template>
2020-10-24 23:57:45 +05:30
2020-11-24 15:15:51 +05:30
<template #right-actions>
<slot name="delete-button"></slot>
</template>
</title-area>
2020-10-24 23:57:45 +05:30
</template>