diff --git a/frontend/hub/collections/hooks/useCollectionVersionColumns.tsx b/frontend/hub/collections/hooks/useCollectionVersionColumns.tsx new file mode 100644 index 0000000000..0099282995 --- /dev/null +++ b/frontend/hub/collections/hooks/useCollectionVersionColumns.tsx @@ -0,0 +1,94 @@ +import { Label } from '@patternfly/react-core'; +import { + AnsibleTowerIcon, + CheckCircleIcon, + ExclamationTriangleIcon, +} from '@patternfly/react-icons'; +import { useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; +import { ITableColumn, TextCell } from '../../../../framework'; +import { RouteObj } from '../../../Routes'; +import { CollectionVersionSearch } from '../CollectionVersionSearch'; + +export function useCollectionVersionColumns(_options?: { + disableSort?: boolean; + disableLinks?: boolean; +}) { + const { t } = useTranslation(); + return useMemo[]>( + () => [ + { + header: t('Name'), + value: (collection) => collection.collection_version.name, + cell: (collection) => ( + + ), + card: 'name', + list: 'name', + icon: () => , + }, + { + header: t('Repository'), + type: 'text', + value: (collection) => collection.repository.name, + }, + { + header: t('Namespace'), + type: 'text', + value: (collection) => collection.collection_version.namespace, + }, + { + header: t('Description'), + type: 'description', + value: (collection) => collection.collection_version.description, + card: 'description', + list: 'description', + }, + { + header: t('Modules'), + type: 'count', + value: (collection) => + collection.collection_version.contents.filter((c) => c.content_type === 'module').length, + }, + { + header: t('Updated'), + type: 'datetime', + value: (collection) => collection.collection_version.pulp_created, + card: 'hidden', + list: 'secondary', + }, + { + header: t('Version'), + type: 'text', + value: (collection) => collection.collection_version.version, + card: 'hidden', + list: 'secondary', + }, + { + header: t('Signed state'), + cell: (collection) => { + switch (collection.is_signed) { + case true: + return ( + + ); + case false: + return ( + + ); + } + }, + list: 'secondary', + value: (collection) => collection.is_signed, + }, + ], + [t] + ); +} diff --git a/frontend/hub/namespaces/HubNamespaceDetails.tsx b/frontend/hub/namespaces/HubNamespaceDetails.tsx index dabf5ea7d7..ba94b09144 100644 --- a/frontend/hub/namespaces/HubNamespaceDetails.tsx +++ b/frontend/hub/namespaces/HubNamespaceDetails.tsx @@ -18,12 +18,9 @@ import { useHubView } from '../useHubView'; import { useHubNamespaceActions } from './hooks/useHubNamespaceActions'; import { useHubNamespacesColumns } from './hooks/useHubNamespacesColumns'; import { useCollectionFilters } from '../collections/hooks/useCollectionFilters'; -import { useCollectionsActions } from '../collections/hooks/useCollectionsActions'; -import { useCollectionColumns } from '../collections/hooks/useCollectionColumns'; -import { useCollectionActions } from '../collections/hooks/useCollectionActions'; +import { useCollectionVersionColumns } from '../collections/hooks/useCollectionVersionColumns'; import { CollectionVersionSearch } from '../collections/CollectionVersionSearch'; -import { hubAPI, idKeyFn } from '../api'; - +import { hubAPI } from '../api'; import { DropdownPosition } from '@patternfly/react-core'; export function NamespaceDetails() { @@ -65,6 +62,7 @@ export function NamespaceDetails() { function NamespaceDetailsTab(props: { namespace?: HubNamespace }) { const { namespace } = props; + // eslint-disable-next-line no-console const tableColumns = useHubNamespacesColumns(); return ; } @@ -72,24 +70,20 @@ function NamespaceDetailsTab(props: { namespace?: HubNamespace }) { function CollectionsTab(props: { namespace?: HubNamespace }) { const { t } = useTranslation(); const toolbarFilters = useCollectionFilters(); - const tableColumns = useCollectionColumns(); + const tableColumns = useCollectionVersionColumns(); const view = useHubView({ - url: hubAPI`/_ui/v1/repo/published/`, - keyFn: idKeyFn, + url: hubAPI`/v3/plugin/ansible/search/collection-versions/`, + keyFn: (item) => item.collection_version.pulp_href + ':' + item.repository.name, tableColumns, queryParams: { namespace: props?.namespace?.name }, }); - const toolbarActions = useCollectionsActions(view.unselectItemsAndRefresh); - const rowActions = useCollectionActions(view.unselectItemsAndRefresh); const navigate = useNavigate(); return ( toolbarFilters={toolbarFilters} - toolbarActions={toolbarActions} tableColumns={tableColumns} - rowActions={rowActions} errorStateTitle={t('Error loading collections')} emptyStateTitle={t('No collections yet')} emptyStateDescription={t('To get started, upload a collection.')}