2020-10-24 23:57:45 +05:30
|
|
|
<script>
|
2021-01-29 00:20:46 +05:30
|
|
|
/* eslint-disable vue/v-slot-style */
|
2020-10-24 23:57:45 +05:30
|
|
|
import { mapState, mapGetters } from 'vuex';
|
2021-01-29 00:20:46 +05:30
|
|
|
import { GlIcon, GlSprintf, GlTooltipDirective, GlBadge } from '@gitlab/ui';
|
|
|
|
import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
|
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,
|
2021-01-29 00:20:46 +05:30
|
|
|
GlBadge,
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
|
|
|
mixins: [timeagoMixin],
|
2021-01-29 00:20:46 +05:30
|
|
|
i18n: {
|
|
|
|
packageInfo: __('v%{version} published %{timeAgo}'),
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isDesktop: true,
|
|
|
|
};
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
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));
|
|
|
|
},
|
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
mounted() {
|
|
|
|
this.isDesktop = GlBreakpointInstance.isDesktop();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
dynamicSlotName(index) {
|
|
|
|
return `metadata-tag${index}`;
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</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)">
|
|
|
|
{{ 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-29 00:20:46 +05:30
|
|
|
<template v-if="isDesktop && 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
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
<!-- we need to duplicate the package tags on mobile to ensure proper styling inside the flex wrap -->
|
|
|
|
<template
|
|
|
|
v-for="(tag, index) in packageEntity.tags"
|
|
|
|
v-else-if="hasTagsToDisplay"
|
|
|
|
v-slot:[dynamicSlotName(index)]
|
|
|
|
>
|
|
|
|
<gl-badge :key="index" class="gl-my-1" data-testid="tag-badge" variant="info" size="sm">
|
|
|
|
{{ tag.name }}
|
|
|
|
</gl-badge>
|
|
|
|
</template>
|
|
|
|
|
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>
|