Commit 6a2daeb8 authored by Nick Kipling's avatar Nick Kipling

Adds branch ref to package details title

Updated title component to include ref
Updated package presenter to include ref
Updated tests to test displaying
parent 5c32fdaf
---
title: Adds branch information to the package details title section
merge_request: 27488
author:
type: added
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
mixins: [timeagoMixin], mixins: [timeagoMixin],
computed: { computed: {
...mapState(['packageEntity', 'packageFiles']), ...mapState(['packageEntity', 'packageFiles']),
...mapGetters(['packageTypeDisplay']), ...mapGetters(['packageTypeDisplay', 'packagePipeline']),
hasTagsToDisplay() { hasTagsToDisplay() {
return Boolean(this.packageEntity.tags && this.packageEntity.tags.length); return Boolean(this.packageEntity.tags && this.packageEntity.tags.length);
}, },
...@@ -58,6 +58,11 @@ export default { ...@@ -58,6 +58,11 @@ export default {
<package-tags :tag-display-limit="1" :tags="packageEntity.tags" /> <package-tags :tag-display-limit="1" :tags="packageEntity.tags" />
</div> </div>
<div v-if="packagePipeline" class="d-flex align-items-center append-right-default">
<gl-icon name="branch" class="text-secondary append-right-8" />
<span ref="package-ref" class="font-weight-bold">{{ packagePipeline.ref }}</span>
</div>
<div class="d-flex align-items-center append-right-default"> <div class="d-flex align-items-center append-right-default">
<gl-icon name="disk" class="text-secondary append-right-8" /> <gl-icon name="disk" class="text-secondary append-right-8" />
<span ref="package-size" class="font-weight-bold">{{ totalSize }}</span> <span ref="package-size" class="font-weight-bold">{{ totalSize }}</span>
......
...@@ -39,6 +39,7 @@ module Packages ...@@ -39,6 +39,7 @@ module Packages
created_at: pipeline_info.created_at, created_at: pipeline_info.created_at,
id: pipeline_info.id, id: pipeline_info.id,
sha: pipeline_info.sha, sha: pipeline_info.sha,
ref: pipeline_info.ref,
git_commit_message: pipeline_info.git_commit_message, git_commit_message: pipeline_info.git_commit_message,
user: build_user_info(pipeline_info.user) user: build_user_info(pipeline_info.user)
} }
......
...@@ -52,6 +52,8 @@ exports[`PackageTitle renders with tags 1`] = ` ...@@ -52,6 +52,8 @@ exports[`PackageTitle renders with tags 1`] = `
/> />
</div> </div>
<!---->
<div <div
class="d-flex align-items-center append-right-default" class="d-flex align-items-center append-right-default"
> >
...@@ -116,6 +118,8 @@ exports[`PackageTitle renders without tags 1`] = ` ...@@ -116,6 +118,8 @@ exports[`PackageTitle renders without tags 1`] = `
<!----> <!---->
<!---->
<div <div
class="d-flex align-items-center append-right-default" class="d-flex align-items-center append-right-default"
> >
......
...@@ -27,6 +27,7 @@ describe('PackageTitle', () => { ...@@ -27,6 +27,7 @@ describe('PackageTitle', () => {
}, },
getters: { getters: {
packageTypeDisplay: ({ packageEntity: { package_type: type } }) => type, packageTypeDisplay: ({ packageEntity: { package_type: type } }) => type,
packagePipeline: ({ packageEntity: { pipeline = null } }) => pipeline,
}, },
}); });
...@@ -38,6 +39,7 @@ describe('PackageTitle', () => { ...@@ -38,6 +39,7 @@ describe('PackageTitle', () => {
const packageType = () => wrapper.find({ ref: 'package-type' }); const packageType = () => wrapper.find({ ref: 'package-type' });
const packageSize = () => wrapper.find({ ref: 'package-size' }); const packageSize = () => wrapper.find({ ref: 'package-size' });
const packageRef = () => wrapper.find({ ref: 'package-ref' });
const packageTags = () => wrapper.find(PackageTags); const packageTags = () => wrapper.find(PackageTags);
afterEach(() => { afterEach(() => {
...@@ -102,4 +104,18 @@ describe('PackageTitle', () => { ...@@ -102,4 +104,18 @@ describe('PackageTitle', () => {
expect(packageTags().exists()).toBe(false); 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().text()).toBe(npmPackage.pipeline.ref);
});
});
}); });
...@@ -53,10 +53,7 @@ export const npmPackage = { ...@@ -53,10 +53,7 @@ export const npmPackage = {
updated_at: '2015-12-10', updated_at: '2015-12-10',
version: '', version: '',
_links, _links,
build_info: { pipeline: mockPipelineInfo,
pipeline_id: 1,
pipeline: mockPipelineInfo,
},
}; };
export const npmFiles = [ export const npmFiles = [
......
...@@ -24,6 +24,7 @@ describe ::Packages::Detail::PackagePresenter do ...@@ -24,6 +24,7 @@ describe ::Packages::Detail::PackagePresenter do
created_at: pipeline.created_at, created_at: pipeline.created_at,
id: pipeline.id, id: pipeline.id,
sha: pipeline.sha, sha: pipeline.sha,
ref: pipeline.ref,
git_commit_message: pipeline.git_commit_message, git_commit_message: pipeline.git_commit_message,
user: user_info 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