Commit ca611046 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '225665-create-shared-components-for-package-and-container-registry' into 'master'

Move registry details_row and history_item to vue_shared/registry

See merge request gitlab-org/gitlab!41563
parents da5255f5 3a5dedaf
<script> <script>
import { GlLink, GlSprintf } from '@gitlab/ui'; import { GlLink, GlSprintf } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import DetailsRow from '~/registry/shared/components/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import { generateConanRecipe } from '../utils'; import { generateConanRecipe } from '../utils';
import { PackageType } from '../../shared/constants'; import { PackageType } from '../../shared/constants';
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlLink, GlSprintf } from '@gitlab/ui'; import { GlLink, GlSprintf } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import HistoryElement from './history_element.vue'; import HistoryItem from '~/vue_shared/components/registry/history_item.vue';
export default { export default {
name: 'PackageHistory', name: 'PackageHistory',
...@@ -16,7 +16,7 @@ export default { ...@@ -16,7 +16,7 @@ export default {
components: { components: {
GlLink, GlLink,
GlSprintf, GlSprintf,
HistoryElement, HistoryItem,
TimeAgoTooltip, TimeAgoTooltip,
}, },
props: { props: {
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
<div class="issuable-discussion"> <div class="issuable-discussion">
<h3 class="gl-font-lg" data-testid="title">{{ __('History') }}</h3> <h3 class="gl-font-lg" data-testid="title">{{ __('History') }}</h3>
<ul class="timeline main-notes-list notes gl-mb-4" data-testid="timeline"> <ul class="timeline main-notes-list notes gl-mb-4" data-testid="timeline">
<history-element icon="clock" data-testid="created-on"> <history-item icon="clock" data-testid="created-on">
<gl-sprintf :message="$options.i18n.createdOn"> <gl-sprintf :message="$options.i18n.createdOn">
<template #name> <template #name>
<strong>{{ packageEntity.name }}</strong> <strong>{{ packageEntity.name }}</strong>
...@@ -58,8 +58,8 @@ export default { ...@@ -58,8 +58,8 @@ export default {
<time-ago-tooltip :time="packageEntity.created_at" /> <time-ago-tooltip :time="packageEntity.created_at" />
</template> </template>
</gl-sprintf> </gl-sprintf>
</history-element> </history-item>
<history-element icon="pencil" data-testid="updated-at"> <history-item icon="pencil" data-testid="updated-at">
<gl-sprintf :message="$options.i18n.updatedAtText"> <gl-sprintf :message="$options.i18n.updatedAtText">
<template #name> <template #name>
<strong>{{ packageEntity.name }}</strong> <strong>{{ packageEntity.name }}</strong>
...@@ -71,9 +71,9 @@ export default { ...@@ -71,9 +71,9 @@ export default {
<time-ago-tooltip :time="packageEntity.updated_at" /> <time-ago-tooltip :time="packageEntity.updated_at" />
</template> </template>
</gl-sprintf> </gl-sprintf>
</history-element> </history-item>
<template v-if="packagePipeline"> <template v-if="packagePipeline">
<history-element icon="commit" data-testid="commit"> <history-item icon="commit" data-testid="commit">
<gl-sprintf :message="$options.i18n.commitText"> <gl-sprintf :message="$options.i18n.commitText">
<template #link> <template #link>
<gl-link :href="packagePipeline.project.commit_url">{{ <gl-link :href="packagePipeline.project.commit_url">{{
...@@ -84,8 +84,8 @@ export default { ...@@ -84,8 +84,8 @@ export default {
<strong>{{ packagePipeline.ref }}</strong> <strong>{{ packagePipeline.ref }}</strong>
</template> </template>
</gl-sprintf> </gl-sprintf>
</history-element> </history-item>
<history-element icon="pipeline" data-testid="pipeline"> <history-item icon="pipeline" data-testid="pipeline">
<gl-sprintf :message="$options.i18n.pipelineText"> <gl-sprintf :message="$options.i18n.pipelineText">
<template #link> <template #link>
<gl-link :href="packagePipeline.project.pipeline_url" <gl-link :href="packagePipeline.project.pipeline_url"
...@@ -97,9 +97,9 @@ export default { ...@@ -97,9 +97,9 @@ export default {
</template> </template>
<template #author>{{ packagePipeline.user.name }}</template> <template #author>{{ packagePipeline.user.name }}</template>
</gl-sprintf> </gl-sprintf>
</history-element> </history-item>
</template> </template>
<history-element icon="package" data-testid="published"> <history-item icon="package" data-testid="published">
<gl-sprintf :message="$options.i18n.publishText"> <gl-sprintf :message="$options.i18n.publishText">
<template #project> <template #project>
<strong>{{ projectName }}</strong> <strong>{{ projectName }}</strong>
...@@ -108,7 +108,7 @@ export default { ...@@ -108,7 +108,7 @@ export default {
<time-ago-tooltip :time="packageEntity.created_at" /> <time-ago-tooltip :time="packageEntity.created_at" />
</template> </template>
</gl-sprintf> </gl-sprintf>
</history-element> </history-item>
</ul> </ul>
</div> </div>
</template> </template>
...@@ -7,7 +7,7 @@ import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; ...@@ -7,7 +7,7 @@ import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import DeleteButton from '../delete_button.vue'; import DeleteButton from '../delete_button.vue';
import DetailsRow from '~/registry/shared/components/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import { import {
REMOVE_TAG_BUTTON_TITLE, REMOVE_TAG_BUTTON_TITLE,
DIGEST_LABEL, DIGEST_LABEL,
......
...@@ -3,12 +3,11 @@ import { GlIcon } from '@gitlab/ui'; ...@@ -3,12 +3,11 @@ import { GlIcon } from '@gitlab/ui';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
export default { export default {
name: 'HistoryElement', name: 'HistoryItem',
components: { components: {
GlIcon, GlIcon,
TimelineEntryItem, TimelineEntryItem,
}, },
props: { props: {
icon: { icon: {
type: String, type: String,
...@@ -29,7 +28,9 @@ export default { ...@@ -29,7 +28,9 @@ export default {
<slot></slot> <slot></slot>
</span> </span>
</div> </div>
<div class="note-body"></div> <div class="note-body">
<slot name="body"></slot>
</div>
</div> </div>
</timeline-entry-item> </timeline-entry-item>
</template> </template>
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink, GlSprintf } from '@gitlab/ui'; import { GlLink, GlSprintf } from '@gitlab/ui';
import DetailsRow from '~/registry/shared/components/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import component from '~/packages/details/components/additional_metadata.vue'; import component from '~/packages/details/components/additional_metadata.vue';
import { mavenPackage, conanPackage, nugetPackage, npmPackage } from '../../mock_data'; import { mavenPackage, conanPackage, nugetPackage, npmPackage } from '../../mock_data';
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink, GlSprintf } from '@gitlab/ui'; import { GlLink, GlSprintf } from '@gitlab/ui';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import HistoryElement from '~/packages/details/components/history_element.vue'; import HistoryItem from '~/vue_shared/components/registry/history_item.vue';
import component from '~/packages/details/components/package_history.vue'; import component from '~/packages/details/components/package_history.vue';
import { mavenPackage, mockPipelineInfo } from '../../mock_data'; import { mavenPackage, mockPipelineInfo } from '../../mock_data';
...@@ -17,8 +17,8 @@ describe('Package History', () => { ...@@ -17,8 +17,8 @@ describe('Package History', () => {
wrapper = shallowMount(component, { wrapper = shallowMount(component, {
propsData: { ...defaultProps, ...props }, propsData: { ...defaultProps, ...props },
stubs: { stubs: {
HistoryElement: { HistoryItem: {
props: HistoryElement.props, props: HistoryItem.props,
template: '<div data-testid="history-element"><slot></slot></div>', template: '<div data-testid="history-element"><slot></slot></div>',
}, },
GlSprintf, GlSprintf,
......
...@@ -6,7 +6,7 @@ import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; ...@@ -6,7 +6,7 @@ import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import component from '~/registry/explorer/components/details_page/tags_list_row.vue'; import component from '~/registry/explorer/components/details_page/tags_list_row.vue';
import DeleteButton from '~/registry/explorer/components/delete_button.vue'; import DeleteButton from '~/registry/explorer/components/delete_button.vue';
import DetailsRow from '~/registry/shared/components/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import { import {
REMOVE_TAG_BUTTON_TITLE, REMOVE_TAG_BUTTON_TITLE,
REMOVE_TAG_BUTTON_DISABLE_TOOLTIP, REMOVE_TAG_BUTTON_DISABLE_TOOLTIP,
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`History Element renders the correct markup 1`] = ` exports[`History Item renders the correct markup 1`] = `
<li <li
class="timeline-entry system-note note-wrapper gl-mb-6!" class="timeline-entry system-note note-wrapper gl-mb-6!"
> >
...@@ -31,7 +31,11 @@ exports[`History Element renders the correct markup 1`] = ` ...@@ -31,7 +31,11 @@ exports[`History Element renders the correct markup 1`] = `
<div <div
class="note-body" class="note-body"
/> >
<div
data-testid="body-slot"
/>
</div>
</div> </div>
</div> </div>
</li> </li>
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import component from '~/registry/shared/components/details_row.vue'; import component from '~/vue_shared/components/registry/details_row.vue';
describe('DetailsRow', () => { describe('DetailsRow', () => {
let wrapper; let wrapper;
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import component from '~/packages/details/components/history_element.vue';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import component from '~/vue_shared/components/registry/history_item.vue';
describe('History Element', () => { describe('History Item', () => {
let wrapper; let wrapper;
const defaultProps = { const defaultProps = {
icon: 'pencil', icon: 'pencil',
...@@ -17,6 +17,7 @@ describe('History Element', () => { ...@@ -17,6 +17,7 @@ describe('History Element', () => {
}, },
slots: { slots: {
default: '<div data-testid="default-slot"></div>', default: '<div data-testid="default-slot"></div>',
body: '<div data-testid="body-slot"></div>',
}, },
}); });
}; };
...@@ -29,6 +30,7 @@ describe('History Element', () => { ...@@ -29,6 +30,7 @@ describe('History Element', () => {
const findTimelineEntry = () => wrapper.find(TimelineEntryItem); const findTimelineEntry = () => wrapper.find(TimelineEntryItem);
const findGlIcon = () => wrapper.find(GlIcon); const findGlIcon = () => wrapper.find(GlIcon);
const findDefaultSlot = () => wrapper.find('[data-testid="default-slot"]'); const findDefaultSlot = () => wrapper.find('[data-testid="default-slot"]');
const findBodySlot = () => wrapper.find('[data-testid="body-slot"]');
it('renders the correct markup', () => { it('renders the correct markup', () => {
mountComponent(); mountComponent();
...@@ -41,11 +43,19 @@ describe('History Element', () => { ...@@ -41,11 +43,19 @@ describe('History Element', () => {
expect(findDefaultSlot().exists()).toBe(true); expect(findDefaultSlot().exists()).toBe(true);
}); });
it('has a body slot', () => {
mountComponent();
expect(findBodySlot().exists()).toBe(true);
});
it('has a timeline entry', () => { it('has a timeline entry', () => {
mountComponent(); mountComponent();
expect(findTimelineEntry().exists()).toBe(true); expect(findTimelineEntry().exists()).toBe(true);
}); });
it('has an icon', () => { it('has an icon', () => {
mountComponent(); mountComponent();
......
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