Commit 1479d6b8 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Miguel Rincon

Fetch only the last pipeline on package list

parent 20e4a075
<script> <script>
import { GlButton, GlLink, GlSprintf, GlTooltipDirective, GlTruncate } from '@gitlab/ui'; import { GlButton, GlLink, GlSprintf, GlTooltipDirective, GlTruncate } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__, __ } from '~/locale';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import { import {
PACKAGE_ERROR_STATUS, PACKAGE_ERROR_STATUS,
...@@ -64,6 +64,7 @@ export default { ...@@ -64,6 +64,7 @@ export default {
}, },
i18n: { i18n: {
erroredPackageText: s__('PackageRegistry|Invalid Package: failed metadata extraction'), erroredPackageText: s__('PackageRegistry|Invalid Package: failed metadata extraction'),
createdAt: __('Created %{timestamp}'),
}, },
}; };
</script> </script>
...@@ -127,8 +128,8 @@ export default { ...@@ -127,8 +128,8 @@ export default {
</template> </template>
<template #right-secondary> <template #right-secondary>
<span> <span data-testid="created-date">
<gl-sprintf :message="__('Created %{timestamp}')"> <gl-sprintf :message="$options.i18n.createdAt">
<template #timestamp> <template #timestamp>
<timeago-tooltip :time="packageEntity.createdAt" /> <timeago-tooltip :time="packageEntity.createdAt" />
</template> </template>
......
...@@ -10,7 +10,7 @@ fragment PackageData on Package { ...@@ -10,7 +10,7 @@ fragment PackageData on Package {
name name
} }
} }
pipelines { pipelines(last: 1) {
nodes { nodes {
sha sha
ref ref
......
...@@ -77,7 +77,9 @@ exports[`packages_list_row renders 1`] = ` ...@@ -77,7 +77,9 @@ exports[`packages_list_row renders 1`] = `
<div <div
class="gl-display-flex gl-align-items-center gl-min-h-6" class="gl-display-flex gl-align-items-center gl-min-h-6"
> >
<span> <span
data-testid="created-date"
>
Created Created
<timeago-tooltip-stub <timeago-tooltip-stub
cssclass="" cssclass=""
......
...@@ -6,6 +6,8 @@ import PackagesListRow from '~/packages_and_registries/package_registry/componen ...@@ -6,6 +6,8 @@ import PackagesListRow from '~/packages_and_registries/package_registry/componen
import PackagePath from '~/packages/shared/components/package_path.vue'; import PackagePath from '~/packages/shared/components/package_path.vue';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages/shared/components/package_tags.vue';
import PackageIconAndName from '~/packages/shared/components/package_icon_and_name.vue'; import PackageIconAndName from '~/packages/shared/components/package_icon_and_name.vue';
import PublishMethod from '~/packages_and_registries/package_registry/components/list/publish_method.vue';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { PACKAGE_ERROR_STATUS } from '~/packages_and_registries/package_registry/constants'; import { PACKAGE_ERROR_STATUS } from '~/packages_and_registries/package_registry/constants';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
...@@ -29,6 +31,9 @@ describe('packages_list_row', () => { ...@@ -29,6 +31,9 @@ describe('packages_list_row', () => {
const findPackageLink = () => wrapper.findComponent(GlLink); const findPackageLink = () => wrapper.findComponent(GlLink);
const findWarningIcon = () => wrapper.findByTestId('warning-icon'); const findWarningIcon = () => wrapper.findByTestId('warning-icon');
const findLeftSecondaryInfos = () => wrapper.findByTestId('left-secondary-infos'); const findLeftSecondaryInfos = () => wrapper.findByTestId('left-secondary-infos');
const findPublishMethod = () => wrapper.findComponent(PublishMethod);
const findCreatedDateText = () => wrapper.findByTestId('created-date');
const findTimeAgoTooltip = () => wrapper.findComponent(TimeagoTooltip);
const mountComponent = ({ const mountComponent = ({
packageEntity = packageWithoutTags, packageEntity = packageWithoutTags,
...@@ -153,4 +158,23 @@ describe('packages_list_row', () => { ...@@ -153,4 +158,23 @@ describe('packages_list_row', () => {
expect(findPackageIconAndName().text()).toBe(packageWithoutTags.packageType.toLowerCase()); expect(findPackageIconAndName().text()).toBe(packageWithoutTags.packageType.toLowerCase());
}); });
}); });
describe('right info', () => {
it('has publish method component', () => {
mountComponent({
packageEntity: { ...packageWithoutTags, pipelines: { nodes: packagePipelines() } },
});
expect(findPublishMethod().props('pipeline')).toEqual(packagePipelines()[0]);
});
it('has the created date', () => {
mountComponent();
expect(findCreatedDateText().text()).toMatchInterpolatedText(PackagesListRow.i18n.createdAt);
expect(findTimeAgoTooltip().props()).toMatchObject({
time: packageData().createdAt,
});
});
});
}); });
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