Skip to content

Commit 0a249fd

Browse files
committed
add collectionversionsearch
1 parent df9c030 commit 0a249fd

File tree

2 files changed

+100
-12
lines changed

2 files changed

+100
-12
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { Label } from '@patternfly/react-core';
2+
import {
3+
AnsibleTowerIcon,
4+
CheckCircleIcon,
5+
ExclamationTriangleIcon,
6+
} from '@patternfly/react-icons';
7+
import { useMemo } from 'react';
8+
import { useTranslation } from 'react-i18next';
9+
import { ITableColumn, TextCell } from '../../../../framework';
10+
import { RouteObj } from '../../../Routes';
11+
import { CollectionVersionSearch } from '../CollectionVersionSearch';
12+
13+
export function useCollectionVersionColumns(_options?: {
14+
disableSort?: boolean;
15+
disableLinks?: boolean;
16+
}) {
17+
const { t } = useTranslation();
18+
return useMemo<ITableColumn<CollectionVersionSearch>[]>(
19+
() => [
20+
{
21+
header: t('Name'),
22+
value: (collection) => collection.collection_version.name,
23+
cell: (collection) => (
24+
<TextCell
25+
text={collection.collection_version.name}
26+
to={RouteObj.CollectionDetails.replace(':id', collection.collection_version.name)}
27+
/>
28+
),
29+
card: 'name',
30+
list: 'name',
31+
icon: () => <AnsibleTowerIcon />,
32+
},
33+
{
34+
header: t('Repository'),
35+
type: 'text',
36+
value: (collection) => collection.repository.name,
37+
},
38+
{
39+
header: t('Namespace'),
40+
type: 'text',
41+
value: (collection) => collection.collection_version.namespace,
42+
},
43+
{
44+
header: t('Description'),
45+
type: 'description',
46+
value: (collection) => collection.collection_version.description,
47+
card: 'description',
48+
list: 'description',
49+
},
50+
{
51+
header: t('Modules'),
52+
type: 'count',
53+
value: (collection) =>
54+
collection.collection_version.contents.filter((c) => c.content_type === 'module').length,
55+
},
56+
{
57+
header: t('Updated'),
58+
type: 'datetime',
59+
value: (collection) => collection.collection_version.pulp_created,
60+
card: 'hidden',
61+
list: 'secondary',
62+
},
63+
{
64+
header: t('Version'),
65+
type: 'text',
66+
value: (collection) => collection.collection_version.version,
67+
card: 'hidden',
68+
list: 'secondary',
69+
},
70+
{
71+
header: t('Signed state'),
72+
cell: (collection) => {
73+
switch (collection.is_signed) {
74+
case true:
75+
return (
76+
<Label icon={<CheckCircleIcon />} variant="outline" color="green">
77+
{t('Signed')}
78+
</Label>
79+
);
80+
case false:
81+
return (
82+
<Label icon={<ExclamationTriangleIcon />} variant="outline" color="orange">
83+
{t('Unsigned')}
84+
</Label>
85+
);
86+
}
87+
},
88+
list: 'secondary',
89+
value: (collection) => collection.is_signed,
90+
},
91+
],
92+
[t]
93+
);
94+
}

frontend/hub/namespaces/HubNamespaceDetails.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ import { useHubView } from '../useHubView';
1818
import { useHubNamespaceActions } from './hooks/useHubNamespaceActions';
1919
import { useHubNamespacesColumns } from './hooks/useHubNamespacesColumns';
2020
import { useCollectionFilters } from '../collections/hooks/useCollectionFilters';
21-
import { useCollectionsActions } from '../collections/hooks/useCollectionsActions';
22-
import { useCollectionColumns } from '../collections/hooks/useCollectionColumns';
23-
import { useCollectionActions } from '../collections/hooks/useCollectionActions';
21+
import { useCollectionVersionColumns } from '../collections/hooks/useCollectionVersionColumns';
2422
import { CollectionVersionSearch } from '../collections/CollectionVersionSearch';
25-
import { hubAPI, idKeyFn } from '../api';
26-
23+
import { hubAPI } from '../api';
2724
import { DropdownPosition } from '@patternfly/react-core';
2825

2926
export function NamespaceDetails() {
@@ -65,31 +62,28 @@ export function NamespaceDetails() {
6562

6663
function NamespaceDetailsTab(props: { namespace?: HubNamespace }) {
6764
const { namespace } = props;
65+
// eslint-disable-next-line no-console
6866
const tableColumns = useHubNamespacesColumns();
6967
return <PageDetailsFromColumns item={namespace} columns={tableColumns} />;
7068
}
7169

7270
function CollectionsTab(props: { namespace?: HubNamespace }) {
7371
const { t } = useTranslation();
7472
const toolbarFilters = useCollectionFilters();
75-
const tableColumns = useCollectionColumns();
73+
const tableColumns = useCollectionVersionColumns();
7674
const view = useHubView<CollectionVersionSearch>({
77-
url: hubAPI`/_ui/v1/repo/published/`,
78-
keyFn: idKeyFn,
75+
url: hubAPI`/v3/plugin/ansible/search/collection-versions/`,
76+
keyFn: (item) => item.collection_version.pulp_href + ':' + item.repository.name,
7977
tableColumns,
8078
queryParams: { namespace: props?.namespace?.name },
8179
});
82-
const toolbarActions = useCollectionsActions(view.unselectItemsAndRefresh);
83-
const rowActions = useCollectionActions(view.unselectItemsAndRefresh);
8480
const navigate = useNavigate();
8581

8682
return (
8783
<PageLayout>
8884
<PageTable<CollectionVersionSearch>
8985
toolbarFilters={toolbarFilters}
90-
toolbarActions={toolbarActions}
9186
tableColumns={tableColumns}
92-
rowActions={rowActions}
9387
errorStateTitle={t('Error loading collections')}
9488
emptyStateTitle={t('No collections yet')}
9589
emptyStateDescription={t('To get started, upload a collection.')}

0 commit comments

Comments
 (0)