Commit 4404fa9f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch '197926-add-branch-to-package-title' into 'master'

Add branch info to the package details title

See merge request gitlab-org/gitlab!27488
parents ed5dfe62 7c864b64
---
title: Adds branch information to the package details title section
merge_request: 27488
author:
type: added
......@@ -18,7 +18,7 @@ export default {
mixins: [timeagoMixin],
computed: {
...mapState(['packageEntity', 'packageFiles']),
...mapGetters(['packageTypeDisplay']),
...mapGetters(['packageTypeDisplay', 'packagePipeline']),
hasTagsToDisplay() {
return Boolean(this.packageEntity.tags && this.packageEntity.tags.length);
},
......@@ -58,6 +58,20 @@ export default {
<package-tags :tag-display-limit="1" :tags="packageEntity.tags" />
</div>
<div
v-if="packagePipeline"
ref="package-ref"
class="d-flex align-items-center append-right-default"
>
<gl-icon name="branch" class="text-secondary append-right-8" />
<span
v-gl-tooltip
class="font-weight-bold text-truncate mw-xs"
:title="packagePipeline.ref"
>{{ packagePipeline.ref }}</span
>
</div>
<div class="d-flex align-items-center append-right-default">
<gl-icon name="disk" class="text-secondary append-right-8" />
<span ref="package-size" class="font-weight-bold">{{ totalSize }}</span>
......
......@@ -39,6 +39,7 @@ module Packages
created_at: pipeline_info.created_at,
id: pipeline_info.id,
sha: pipeline_info.sha,
ref: pipeline_info.ref,
git_commit_message: pipeline_info.git_commit_message,
user: build_user_info(pipeline_info.user)
}
......
......@@ -52,6 +52,8 @@ exports[`PackageTitle renders with tags 1`] = `
/>
</div>
<!---->
<div
class="d-flex align-items-center append-right-default"
>
......@@ -116,6 +118,8 @@ exports[`PackageTitle renders without tags 1`] = `
<!---->
<!---->
<div
class="d-flex align-items-center append-right-default"
>
......
......@@ -27,6 +27,7 @@ describe('PackageTitle', () => {
},
getters: {
packageTypeDisplay: ({ packageEntity: { package_type: type } }) => type,
packagePipeline: ({ packageEntity: { pipeline = null } }) => pipeline,
},
});
......@@ -38,6 +39,7 @@ describe('PackageTitle', () => {
const packageType = () => wrapper.find({ ref: 'package-type' });
const packageSize = () => wrapper.find({ ref: 'package-size' });
const packageRef = () => wrapper.find({ ref: 'package-ref' });
const packageTags = () => wrapper.find(PackageTags);
afterEach(() => {
......@@ -102,4 +104,19 @@ describe('PackageTitle', () => {
expect(packageTags().exists()).toBe(false);
});
});
describe('package ref', () => {
it('does not display the ref if missing', () => {
createComponent();
expect(packageRef().exists()).toBe(false);
});
it('correctly shows the package ref if there is one', () => {
createComponent(npmPackage);
expect(packageRef().contains('gl-icon-stub')).toBe(true);
expect(packageRef().text()).toBe(npmPackage.pipeline.ref);
});
});
});
......@@ -53,10 +53,7 @@ export const npmPackage = {
updated_at: '2015-12-10',
version: '',
_links,
build_info: {
pipeline_id: 1,
pipeline: mockPipelineInfo,
},
pipeline: mockPipelineInfo,
};
export const npmFiles = [
......
......@@ -24,6 +24,7 @@ describe ::Packages::Detail::PackagePresenter do
created_at: pipeline.created_at,
id: pipeline.id,
sha: pipeline.sha,
ref: pipeline.ref,
git_commit_message: pipeline.git_commit_message,
user: user_info
}
......
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