Commit b42fd6f9 authored by Nick Kipling's avatar Nick Kipling

Updated as per new designs

Added manually published display
Updated group/project link
Updated tests
parent ec98ba6c
<script> <script>
import PackageTags from '../../shared/components/package_tags.vue'; import PackageTags from '../../shared/components/package_tags.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import PublishMethod from './publish_method.vue';
import { GlButton, GlIcon, GlLink, GlSprintf, GlTooltipDirective } from '@gitlab/ui'; import { GlDeprecatedButton, GlIcon, GlLink, GlSprintf, GlTooltipDirective } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { getPackageType } from '../../shared/utils'; import { getPackageType } from '../../shared/utils';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
import { mapGetters, mapState } from 'vuex'; import { mapState } from 'vuex';
export default { export default {
name: 'PackagesListRow', name: 'PackagesListRow',
components: { components: {
ClipboardButton, GlDeprecatedButton,
GlButton,
GlIcon, GlIcon,
GlLink, GlLink,
GlSprintf, GlSprintf,
PackageTags, PackageTags,
PublishMethod,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -28,18 +28,11 @@ export default { ...@@ -28,18 +28,11 @@ export default {
}, },
}, },
computed: { computed: {
...mapGetters(['getCommitLink']),
...mapState({ ...mapState({
isGroupPage: state => state.config.isGroupPage, isGroupPage: state => state.config.isGroupPage,
}), }),
author() {
return this.packageEntity.pipeline?.user.name;
},
hasPipeline() {
return Boolean(this.packageEntity.pipeline);
},
createdBy() { createdBy() {
if (this.hasPipeline) { if (this.packageEntity.pipeline) {
return s__('PackageRegistry|%{version} published by %{author}'); return s__('PackageRegistry|%{version} published by %{author}');
} }
...@@ -48,12 +41,6 @@ export default { ...@@ -48,12 +41,6 @@ export default {
packageType() { packageType() {
return getPackageType(this.packageEntity.package_type); return getPackageType(this.packageEntity.package_type);
}, },
packageShaShort() {
return this.packageEntity.pipeline.sha.substring(0, 8);
},
linkToCommit() {
return this.getCommitLink(this.packageEntity);
},
hasProjectLink() { hasProjectLink() {
return Boolean(this.packageEntity.project_path); return Boolean(this.packageEntity.project_path);
}, },
...@@ -80,22 +67,26 @@ export default { ...@@ -80,22 +67,26 @@ export default {
/> />
</div> </div>
<div class="d-flex text-secondary text-truncate"> <div class="d-flex text-secondary text-truncate mt-md-2">
<gl-sprintf :message="createdBy"> <gl-sprintf :message="createdBy">
<template #version> <template #version>
<gl-icon name="eye" class="text-secondary mr-1" />
{{ packageEntity.version }} {{ packageEntity.version }}
</template> </template>
<template #author>{{ packageEntity.pipeline.user.name }}</template> <template #author>{{ packageEntity.pipeline.user.name }}</template>
</gl-sprintf> </gl-sprintf>
<div v-if="hasProjectLink" class="d-flex align-items-center">
<gl-icon name="review-list" class="text-secondary ml-2 mr-1" />
<gl-link <gl-link
v-if="hasProjectLink"
ref="packages-row-project" ref="packages-row-project"
:href="`/${packageEntity.project_path}`" :href="`/${packageEntity.project_path}`"
class="text-secondary ml-2" class="text-secondary"
>{{ packageEntity.projectPathName }}</gl-link >{{ packageEntity.projectPathName }}</gl-link
> >
</div>
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<gl-icon name="package" class="text-secondary ml-2 mr-1" /> <gl-icon name="package" class="text-secondary ml-2 mr-1" />
...@@ -108,26 +99,9 @@ export default { ...@@ -108,26 +99,9 @@ export default {
class="table-section section-40 d-flex flex-md-column justify-content-between align-items-md-end" class="table-section section-40 d-flex flex-md-column justify-content-between align-items-md-end"
:class="{ 'section-50': isGroupPage }" :class="{ 'section-50': isGroupPage }"
> >
<div <publish-method :package-entity="packageEntity" />
v-if="hasPipeline"
class="d-flex align-items-center text-secondary order-1 order-md-0 mb-md-1"
>
<gl-icon name="git-merge" class="mr-1" />
<strong ref="pipeline-ref" class="mr-1 text-dark">{{ packageEntity.pipeline.ref }}</strong>
<gl-icon name="commit" class="mr-1" />
<gl-link ref="pipeline-sha" :href="linkToCommit" class="mr-1">{{
packageShaShort
}}</gl-link>
<clipboard-button
:text="packageEntity.pipeline.sha"
:title="__('Copy commit SHA')"
css-class="border-0 text-secondary py-0 px-1"
/>
</div>
<div class="text-secondary order-0 order-md-1"> <div class="text-secondary order-0 order-md-1 mt-md-2">
<gl-sprintf :message="__('Created %{timestamp}')"> <gl-sprintf :message="__('Created %{timestamp}')">
<template #timestamp> <template #timestamp>
<span v-gl-tooltip :title="tooltipTitle(packageEntity.created_at)"> <span v-gl-tooltip :title="tooltipTitle(packageEntity.created_at)">
...@@ -139,7 +113,7 @@ export default { ...@@ -139,7 +113,7 @@ export default {
</div> </div>
<div v-if="deleteAvailable" class="table-section section-10 d-flex justify-content-end"> <div v-if="deleteAvailable" class="table-section section-10 d-flex justify-content-end">
<gl-button <gl-deprecated-button
ref="action-delete" ref="action-delete"
variant="danger" variant="danger"
:title="s__('PackageRegistry|Remove package')" :title="s__('PackageRegistry|Remove package')"
...@@ -148,7 +122,7 @@ export default { ...@@ -148,7 +122,7 @@ export default {
@click="$emit('packageToDelete', packageEntity)" @click="$emit('packageToDelete', packageEntity)"
> >
<gl-icon name="remove" /> <gl-icon name="remove" />
</gl-button> </gl-deprecated-button>
</div> </div>
</div> </div>
</template> </template>
<script>
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import { GlIcon, GlLink } from '@gitlab/ui';
import { mapGetters } from 'vuex';
export default {
name: 'PublishMethod',
components: {
ClipboardButton,
GlIcon,
GlLink,
},
props: {
packageEntity: {
type: Object,
required: true,
},
},
computed: {
...mapGetters(['getCommitLink']),
hasPipeline() {
return Boolean(this.packageEntity.pipeline);
},
packageShaShort() {
return this.packageEntity.pipeline?.sha.substring(0, 8);
},
linkToCommit() {
return this.getCommitLink(this.packageEntity);
},
},
};
</script>
<template>
<div class="d-flex align-items-center text-secondary order-1 order-md-0 mb-md-1">
<template v-if="hasPipeline">
<gl-icon name="git-merge" class="mr-1" />
<strong ref="pipeline-ref" class="mr-1 text-dark">{{ packageEntity.pipeline.ref }}</strong>
<gl-icon name="commit" class="mr-1" />
<gl-link ref="pipeline-sha" :href="linkToCommit" class="mr-1">{{ packageShaShort }}</gl-link>
<clipboard-button
:text="packageEntity.pipeline.sha"
:title="__('Copy commit SHA')"
css-class="border-0 text-secondary py-0 px-1"
/>
</template>
<template v-else>
<gl-icon name="upload" class="mr-1" />
<strong ref="manual-ref" class="text-dark">{{
s__('PackageRegistry|Manually Published')
}}</strong>
</template>
</div>
</template>
...@@ -22,18 +22,28 @@ exports[`packages_list_row renders 1`] = ` ...@@ -22,18 +22,28 @@ exports[`packages_list_row renders 1`] = `
</div> </div>
<div <div
class="d-flex text-secondary text-truncate" class="d-flex text-secondary text-truncate mt-md-2"
> >
<gl-sprintf-stub <gl-sprintf-stub
message="%{version}" message="%{version}"
/> />
<div
class="d-flex align-items-center"
>
<gl-icon-stub
class="text-secondary ml-2 mr-1"
name="review-list"
size="16"
/>
<gl-link-stub <gl-link-stub
class="text-secondary ml-2" class="text-secondary"
href="/foo/bar/baz" href="/foo/bar/baz"
> >
</gl-link-stub> </gl-link-stub>
</div>
<div <div
class="d-flex align-items-center" class="d-flex align-items-center"
...@@ -54,10 +64,12 @@ exports[`packages_list_row renders 1`] = ` ...@@ -54,10 +64,12 @@ exports[`packages_list_row renders 1`] = `
<div <div
class="table-section section-40 d-flex flex-md-column justify-content-between align-items-md-end" class="table-section section-40 d-flex flex-md-column justify-content-between align-items-md-end"
> >
<!----> <publish-method-stub
packageentity="[object Object]"
/>
<div <div
class="text-secondary order-0 order-md-1" class="text-secondary order-0 order-md-1 mt-md-2"
> >
<gl-sprintf-stub <gl-sprintf-stub
message="Created %{timestamp}" message="Created %{timestamp}"
...@@ -68,7 +80,7 @@ exports[`packages_list_row renders 1`] = ` ...@@ -68,7 +80,7 @@ exports[`packages_list_row renders 1`] = `
<div <div
class="table-section section-10 d-flex justify-content-end" class="table-section section-10 d-flex justify-content-end"
> >
<gl-button-stub <gl-deprecated-button-stub
aria-label="Remove package" aria-label="Remove package"
size="md" size="md"
title="Remove package" title="Remove package"
...@@ -78,7 +90,7 @@ exports[`packages_list_row renders 1`] = ` ...@@ -78,7 +90,7 @@ exports[`packages_list_row renders 1`] = `
name="remove" name="remove"
size="16" size="16"
/> />
</gl-button-stub> </gl-deprecated-button-stub>
</div> </div>
</div> </div>
`; `;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`publish_method renders 1`] = `
<div
class="d-flex align-items-center text-secondary order-1 order-md-0 mb-md-1"
>
<gl-icon-stub
class="mr-1"
name="git-merge"
size="16"
/>
<strong
class="mr-1 text-dark"
>
branch-name
</strong>
<gl-icon-stub
class="mr-1"
name="commit"
size="16"
/>
<gl-link-stub
class="mr-1"
href="commit-link"
>
xxxxxxxx
</gl-link-stub>
<clipboard-button-stub
cssclass="border-0 text-secondary py-0 px-1"
text="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
title="Copy commit SHA"
tooltipplacement="top"
/>
</div>
`;
...@@ -11,17 +11,15 @@ describe('packages_list_row', () => { ...@@ -11,17 +11,15 @@ describe('packages_list_row', () => {
let wrapper; let wrapper;
let store; let store;
const [packageWithoutTagsOrPipeline, packageWithTabsAndPipeline] = packageList; const [packageWithoutTags, packageWithTags] = packageList;
const findPackageTags = () => wrapper.find(PackageTags); const findPackageTags = () => wrapper.find(PackageTags);
const findProjectLink = () => wrapper.find({ ref: 'packages-row-project' }); const findProjectLink = () => wrapper.find({ ref: 'packages-row-project' });
const findDeleteButton = () => wrapper.find({ ref: 'action-delete' }); const findDeleteButton = () => wrapper.find({ ref: 'action-delete' });
const findPipelineRef = () => wrapper.find({ ref: 'pipeline-ref' });
const findPipelineSha = () => wrapper.find({ ref: 'pipeline-sha' });
const mountComponent = ( const mountComponent = (
isGroupPage = false, isGroupPage = false,
packageEntity = packageWithoutTagsOrPipeline, packageEntity = packageWithoutTags,
shallow = true, shallow = true,
) => { ) => {
const mountFunc = shallow ? shallowMount : mount; const mountFunc = shallow ? shallowMount : mount;
...@@ -62,7 +60,7 @@ describe('packages_list_row', () => { ...@@ -62,7 +60,7 @@ describe('packages_list_row', () => {
describe('tags', () => { describe('tags', () => {
it('renders package tags when a package has tags', () => { it('renders package tags when a package has tags', () => {
mountComponent(false, packageWithTabsAndPipeline); mountComponent(false, packageWithTags);
expect(findPackageTags().exists()).toBe(true); expect(findPackageTags().exists()).toBe(true);
}); });
...@@ -88,31 +86,15 @@ describe('packages_list_row', () => { ...@@ -88,31 +86,15 @@ describe('packages_list_row', () => {
}); });
}); });
describe('pipeline information', () => {
it('displays branch and commit when pipeline info exists', () => {
mountComponent(false, packageWithTabsAndPipeline);
expect(findPipelineRef().exists()).toBe(true);
expect(findPipelineSha().exists()).toBe(true);
});
it('does not show any pipeline details when no information exists', () => {
mountComponent(false, packageWithoutTagsOrPipeline);
expect(findPipelineRef().exists()).toBe(false);
expect(findPipelineSha().exists()).toBe(false);
});
});
describe('delete event', () => { describe('delete event', () => {
beforeEach(() => mountComponent(false, packageWithoutTagsOrPipeline, false)); beforeEach(() => mountComponent(false, packageWithoutTags, false));
it('emits the packageToDelete event when the delete button is clicked', () => { it('emits the packageToDelete event when the delete button is clicked', () => {
findDeleteButton().trigger('click'); findDeleteButton().trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('packageToDelete')).toBeTruthy(); expect(wrapper.emitted('packageToDelete')).toBeTruthy();
expect(wrapper.emitted('packageToDelete')[0]).toEqual([packageWithoutTagsOrPipeline]); expect(wrapper.emitted('packageToDelete')[0]).toEqual([packageWithoutTags]);
}); });
}); });
}); });
......
import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import PublishMethod from 'ee/packages/list/components/publish_method.vue';
import { packageList } from '../../mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('publish_method', () => {
let wrapper;
let store;
const [packageWithoutPipeline, packageWithPipeline] = packageList;
const findPipelineRef = () => wrapper.find({ ref: 'pipeline-ref' });
const findPipelineSha = () => wrapper.find({ ref: 'pipeline-sha' });
const findManualPublish = () => wrapper.find({ ref: 'manual-ref' });
const mountComponent = packageEntity => {
store = new Vuex.Store({
getters: {
getCommitLink: () => () => {
return 'commit-link';
},
},
});
wrapper = shallowMount(PublishMethod, {
localVue,
store,
propsData: {
packageEntity,
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('renders', () => {
mountComponent(packageWithPipeline);
expect(wrapper.element).toMatchSnapshot();
});
describe('pipeline information', () => {
it('displays branch and commit when pipeline info exists', () => {
mountComponent(packageWithPipeline);
expect(findPipelineRef().exists()).toBe(true);
expect(findPipelineSha().exists()).toBe(true);
});
it('does not show any pipeline details when no information exists', () => {
mountComponent(packageWithoutPipeline);
expect(findPipelineRef().exists()).toBe(false);
expect(findPipelineSha().exists()).toBe(false);
expect(findManualPublish().exists()).toBe(true);
expect(findManualPublish().text()).toBe('Manually Published');
});
});
});
...@@ -14341,6 +14341,9 @@ msgstr "" ...@@ -14341,6 +14341,9 @@ msgstr ""
msgid "PackageRegistry|Learn how to %{noPackagesLinkStart}publish and share your packages%{noPackagesLinkEnd} with GitLab." msgid "PackageRegistry|Learn how to %{noPackagesLinkStart}publish and share your packages%{noPackagesLinkEnd} with GitLab."
msgstr "" msgstr ""
msgid "PackageRegistry|Manually Published"
msgstr ""
msgid "PackageRegistry|Maven" msgid "PackageRegistry|Maven"
msgstr "" msgstr ""
......
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