forked from ansible/ansible-hub-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollection-list.tsx
74 lines (71 loc) · 1.77 KB
/
collection-list.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { t } from '@lingui/macro';
import { DataList } from '@patternfly/react-core';
import * as React from 'react';
import { CollectionVersionSearch } from 'src/api';
import {
CollectionListItem,
EmptyStateFilter,
Pagination,
} from 'src/components';
import { ParamHelper } from 'src/utilities';
import './list.scss';
interface IProps {
collections: CollectionVersionSearch[];
displaySignatures: boolean;
params: {
sort?: string;
page?: number;
page_size?: number;
};
updateParams: (params) => void;
itemCount: number;
ignoredParams: string[];
collectionControls: (collection) => {
dropdownMenu?: React.ReactNode | null;
uploadButton?: React.ReactNode | null;
};
}
// only used in namespace detail, collections uses individual items
export const CollectionList = (props: IProps) => {
const {
collections,
collectionControls,
displaySignatures,
params,
updateParams,
ignoredParams,
itemCount,
} = props;
return (
<React.Fragment>
<DataList aria-label={t`List of Collections`}>
{collections.length > 0 ? (
collections.map((c, i) => (
<CollectionListItem
key={i}
collection={c}
displaySignatures={displaySignatures}
showNamespace
{...collectionControls(c)}
/>
))
) : (
<EmptyStateFilter
clearAllFilters={() => {
ParamHelper.clearAllFilters({
params,
ignoredParams,
updateParams,
});
}}
/>
)}
</DataList>
<Pagination
params={params}
updateParams={(p) => updateParams(p)}
count={itemCount}
/>
</React.Fragment>
);
};