From 771dd371daf702acbce778fb7dc4186b440a6c90 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 10:07:21 -0400 Subject: [PATCH 01/30] update ns type interface --- frontend/hub/namespaces/HubNamespace.tsx | 33 +++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/frontend/hub/namespaces/HubNamespace.tsx b/frontend/hub/namespaces/HubNamespace.tsx index dc7d3f8152..d0d0215a7e 100644 --- a/frontend/hub/namespaces/HubNamespace.tsx +++ b/frontend/hub/namespaces/HubNamespace.tsx @@ -1,17 +1,44 @@ +export interface LinksType { + name: string; + url: string; +} + +export interface LatestMetadataType { + pulp_href: string; + name: string; + company: string; + email: string; + description: string; + resources: string; + links: LinksType[]; + avatar_sha256: string | null; + avatar_url: string | null; + metadata_sha256: string; + groups: string[]; + task: string | null; +} + export interface HubNamespace { pulp_href: string; + pulp_created: string; id: number; name: string; company: string; email: string; avatar_url: string; description: string; + num_collections: number; groups: [ { id: number; name: string; - object_roles: string[]; - }, + object_permissions: string[]; + pulp_href?: string; + } ]; - related_fields: object; + resources: string; + owners: string[]; + links: LinksType[]; + my_permissions: string[]; + latest_metadata: LatestMetadataType; } From e3b3a24231c858f383432585ea2a0081b4171cc9 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 10:09:54 -0400 Subject: [PATCH 02/30] implement new api for list view. --- frontend/hub/namespaces/HubNamespaces.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/hub/namespaces/HubNamespaces.tsx b/frontend/hub/namespaces/HubNamespaces.tsx index 05d1bbbb96..42a7cf8d60 100644 --- a/frontend/hub/namespaces/HubNamespaces.tsx +++ b/frontend/hub/namespaces/HubNamespaces.tsx @@ -2,13 +2,12 @@ import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { PageHeader, PageLayout, PageTab, PageTable, PageTabs } from '../../../framework'; import { RouteObj } from '../../Routes'; -import { useHubView } from '../useHubView'; +import { idKeyFn, usePulpView } from '../usePulpView'; import { HubNamespace } from './HubNamespace'; import { useHubNamespaceActions } from './hooks/useHubNamespaceActions'; import { useHubNamespaceFilters } from './hooks/useHubNamespaceFilters'; import { useHubNamespaceToolbarActions } from './hooks/useHubNamespaceToolbarActions'; import { useHubNamespacesColumns } from './hooks/useHubNamespacesColumns'; -import { hubAPI } from '../api/utils'; import { idKeyFn } from '../../common/utils/nameKeyFn'; export function Namespaces() { @@ -44,11 +43,13 @@ export function Namespaces() { } export function AllNamespaces() { - return ; + return ; } export function MyNamespaces() { - return ; + return ( + + ); } export function CommonNamespaces({ url }: { url: string }) { @@ -58,7 +59,7 @@ export function CommonNamespaces({ url }: { url: string }) { const tableColumns = useHubNamespacesColumns(); const toolbarActions = useHubNamespaceToolbarActions(); const rowActions = useHubNamespaceActions(); - const view = useHubView({ url, keyFn: idKeyFn, toolbarFilters, tableColumns }); + const view = usePulpView({ url, keyFn: idKeyFn, toolbarFilters, tableColumns }); return ( toolbarFilters={toolbarFilters} From d072c9b119aeb8206c3fa8f3536a77aecb3e8011 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 10:29:14 -0400 Subject: [PATCH 03/30] fix icontains filter --- frontend/hub/namespaces/hooks/useHubNamespaceFilters.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/hub/namespaces/hooks/useHubNamespaceFilters.tsx b/frontend/hub/namespaces/hooks/useHubNamespaceFilters.tsx index 6ed6c1be6e..e363ac3878 100644 --- a/frontend/hub/namespaces/hooks/useHubNamespaceFilters.tsx +++ b/frontend/hub/namespaces/hooks/useHubNamespaceFilters.tsx @@ -7,10 +7,10 @@ export function useHubNamespaceFilters() { const toolbarFilters = useMemo( () => [ { - key: 'keywords', + key: 'name__icontains', label: t('Name'), - type: ToolbarFilterType.Text, - query: 'keywords', + type: 'string', + query: 'name__icontains', comparison: 'contains', }, ], From 2579075f41143f50d2b5999d6ebd59d611904fc9 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 11:00:18 -0400 Subject: [PATCH 04/30] rebase --- frontend/hub/namespaces/HubNamespaces.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/hub/namespaces/HubNamespaces.tsx b/frontend/hub/namespaces/HubNamespaces.tsx index 42a7cf8d60..7ea8585054 100644 --- a/frontend/hub/namespaces/HubNamespaces.tsx +++ b/frontend/hub/namespaces/HubNamespaces.tsx @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { PageHeader, PageLayout, PageTab, PageTable, PageTabs } from '../../../framework'; import { RouteObj } from '../../Routes'; -import { idKeyFn, usePulpView } from '../usePulpView'; +import { usePulpView } from '../usePulpView'; import { HubNamespace } from './HubNamespace'; import { useHubNamespaceActions } from './hooks/useHubNamespaceActions'; import { useHubNamespaceFilters } from './hooks/useHubNamespaceFilters'; @@ -59,6 +59,7 @@ export function CommonNamespaces({ url }: { url: string }) { const tableColumns = useHubNamespacesColumns(); const toolbarActions = useHubNamespaceToolbarActions(); const rowActions = useHubNamespaceActions(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const view = usePulpView({ url, keyFn: idKeyFn, toolbarFilters, tableColumns }); return ( From 4c34801c1fdc7f46d877add2d193663bae7d6597 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 13:55:47 -0400 Subject: [PATCH 05/30] use pulpAI in place of hubAPI --- frontend/hub/namespaces/HubNamespaces.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/hub/namespaces/HubNamespaces.tsx b/frontend/hub/namespaces/HubNamespaces.tsx index 7ea8585054..0a3b89980f 100644 --- a/frontend/hub/namespaces/HubNamespaces.tsx +++ b/frontend/hub/namespaces/HubNamespaces.tsx @@ -9,6 +9,7 @@ import { useHubNamespaceFilters } from './hooks/useHubNamespaceFilters'; import { useHubNamespaceToolbarActions } from './hooks/useHubNamespaceToolbarActions'; import { useHubNamespacesColumns } from './hooks/useHubNamespacesColumns'; import { idKeyFn } from '../../common/utils/nameKeyFn'; +import { pulpAPI } from '../api/utils'; export function Namespaces() { const { t } = useTranslation(); @@ -48,7 +49,9 @@ export function AllNamespaces() { export function MyNamespaces() { return ( - + ); } From b365800b4d0a2ed90a642ea116766afb24e83ecc Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 14:06:40 -0400 Subject: [PATCH 06/30] use pulpAPI prefix in api call --- frontend/hub/namespaces/HubNamespaces.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/hub/namespaces/HubNamespaces.tsx b/frontend/hub/namespaces/HubNamespaces.tsx index 0a3b89980f..a79dcbe1dd 100644 --- a/frontend/hub/namespaces/HubNamespaces.tsx +++ b/frontend/hub/namespaces/HubNamespaces.tsx @@ -44,7 +44,7 @@ export function Namespaces() { } export function AllNamespaces() { - return ; + return ; } export function MyNamespaces() { From 1e0e26095abb6f98597f464b7862be14b509e4f6 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 14:45:43 -0400 Subject: [PATCH 07/30] add spot for queryParams --- frontend/hub/namespaces/HubNamespaces.tsx | 27 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/frontend/hub/namespaces/HubNamespaces.tsx b/frontend/hub/namespaces/HubNamespaces.tsx index a79dcbe1dd..b14316ff62 100644 --- a/frontend/hub/namespaces/HubNamespaces.tsx +++ b/frontend/hub/namespaces/HubNamespaces.tsx @@ -13,6 +13,7 @@ import { pulpAPI } from '../api/utils'; export function Namespaces() { const { t } = useTranslation(); + return ( ; + return ; } export function MyNamespaces() { return ( ); } -export function CommonNamespaces({ url }: { url: string }) { +export function CommonNamespaces({ + url, + queryParams, +}: { + url: string; + queryParams: + | { + [key: string]: string; + } + | undefined; +}) { const { t } = useTranslation(); const navigate = useNavigate(); const toolbarFilters = useHubNamespaceFilters(); const tableColumns = useHubNamespacesColumns(); const toolbarActions = useHubNamespaceToolbarActions(); const rowActions = useHubNamespaceActions(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const view = usePulpView({ url, keyFn: idKeyFn, toolbarFilters, tableColumns }); + const view = usePulpView({ + url, + keyFn: idKeyFn, + toolbarFilters, + tableColumns, + queryParams, + }); return ( toolbarFilters={toolbarFilters} From e96c4bafb87aeaf4f2c7e70cba26312a22815e7f Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 26 Jun 2023 17:07:25 -0400 Subject: [PATCH 08/30] disable tsc for the time-being --- .../hub/namespaces/HubNamespaceDetails.tsx | 84 ++++++++++++++++--- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/frontend/hub/namespaces/HubNamespaceDetails.tsx b/frontend/hub/namespaces/HubNamespaceDetails.tsx index f1bef88351..4c96c4aed6 100644 --- a/frontend/hub/namespaces/HubNamespaceDetails.tsx +++ b/frontend/hub/namespaces/HubNamespaceDetails.tsx @@ -1,25 +1,48 @@ import { DropdownPosition } from '@patternfly/react-core'; +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useTranslation } from 'react-i18next'; -import { useParams } from 'react-router-dom'; -import { PageActions, PageHeader, PageLayout, PageTab, PageTabs } from '../../../framework'; -import { PageDetailsFromColumns } from '../../../framework/PageDetails/PageDetailsFromColumns'; +import { useParams, useNavigate } from 'react-router-dom'; +import { + PageActions, + PageHeader, + PageTable, + PageLayout, + PageTab, + PageTabs, +} from '../../../framework'; +import { PageDetailsFromColumns } from '../../../framework'; import { RouteObj } from '../../Routes'; import { useGet } from '../../common/crud/useGet'; import { hubAPI } from '../api/utils'; import { HubItemsResponse } from '../useHubView'; import { HubNamespace } from './HubNamespace'; +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 { Collection } from '../collections/Collection'; +import { idKeyFn, hubAPI } from '../api'; + +import { DropdownPosition } from '@patternfly/react-core'; export function NamespaceDetails() { const { t } = useTranslation(); const params = useParams<{ id: string }>(); const { data } = useGet>( - hubAPI`/_ui/v1/namespaces/?limit=1&name=${params.id ?? ''}` + `/api/automation-hub/pulp/api/v3/pulp_ansible/namespaces/?limit=1&name=${params.id ?? ''}` ); let namespace: HubNamespace | undefined = undefined; - if (data && data.data && data.data.length > 0) { - namespace = data.data[0]; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (data && data.results && data.count > 0) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + namespace = data.results[0]; } const pageActions = useHubNamespaceActions(); @@ -27,10 +50,7 @@ export function NamespaceDetails() { actions={pageActions} @@ -40,8 +60,11 @@ export function NamespaceDetails() { } /> - - + + + + + @@ -53,3 +76,40 @@ function NamespaceDetailsTab(props: { namespace?: HubNamespace }) { const tableColumns = useHubNamespacesColumns(); return ; } + +function CollectionsTab(props: { namespace?: HubNamespace }) { + const { t } = useTranslation(); + const toolbarFilters = useCollectionFilters(); + const tableColumns = useCollectionColumns(); + const view = useHubView({ + url: hubAPI`/_ui/v1/repo/published/`, + keyFn: idKeyFn, + toolbarFilters, + tableColumns, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + 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.')} + emptyStateButtonText={t('Upload collection')} + emptyStateButtonClick={() => navigate(RouteObj.UploadCollection)} + {...view} + defaultTableView="list" + defaultSubtitle={t('Collection')} + /> + + ); +} From 1c76994613a325320fde140af870c8369e892e77 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Thu, 29 Jun 2023 10:43:52 -0400 Subject: [PATCH 09/30] create a namespace metadata type file --- frontend/hub/namespaces/HubMetaDataType.tsx | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 frontend/hub/namespaces/HubMetaDataType.tsx diff --git a/frontend/hub/namespaces/HubMetaDataType.tsx b/frontend/hub/namespaces/HubMetaDataType.tsx new file mode 100644 index 0000000000..92a05e1bf3 --- /dev/null +++ b/frontend/hub/namespaces/HubMetaDataType.tsx @@ -0,0 +1,31 @@ +export interface HubNamespaceMetadata { + metadata: { + pulp_href: string; + name: string; + company: string; + email: string; + description: string; + resources: string; + links: string[]; + avatar_sha256: null; + avatar_url: null; + metadata_sha256: string; + groups: []; + task: null; + }; + repository: { + pulp_href: string; + pulp_created: string; + versions_href: string; + pulp_labels: { + pipeline: string; + }; + latest_version_href: string; + name: string; + description: string; + retain_repo_versions: number; + remote: null; + }; + in_latest_repo_version: true; + in_old_repo_version: false; +} From 26d5db4b9b03a047659368d34b8dd17c785743cf Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Mon, 10 Jul 2023 15:14:54 -0400 Subject: [PATCH 10/30] add new HubNamespaceResponse and fix type errors --- frontend/hub/namespaces/HubNamespaceDetails.tsx | 9 +-------- frontend/hub/useHubView.tsx | 5 +++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend/hub/namespaces/HubNamespaceDetails.tsx b/frontend/hub/namespaces/HubNamespaceDetails.tsx index 4c96c4aed6..2f4fe4f755 100644 --- a/frontend/hub/namespaces/HubNamespaceDetails.tsx +++ b/frontend/hub/namespaces/HubNamespaceDetails.tsx @@ -14,7 +14,6 @@ import { PageDetailsFromColumns } from '../../../framework'; import { RouteObj } from '../../Routes'; import { useGet } from '../../common/crud/useGet'; import { hubAPI } from '../api/utils'; -import { HubItemsResponse } from '../useHubView'; import { HubNamespace } from './HubNamespace'; import { useHubView } from '../useHubView'; import { useHubNamespaceActions } from './hooks/useHubNamespaceActions'; @@ -31,17 +30,11 @@ import { DropdownPosition } from '@patternfly/react-core'; export function NamespaceDetails() { const { t } = useTranslation(); const params = useParams<{ id: string }>(); - const { data } = useGet>( + const { data } = useGet>( `/api/automation-hub/pulp/api/v3/pulp_ansible/namespaces/?limit=1&name=${params.id ?? ''}` ); let namespace: HubNamespace | undefined = undefined; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore if (data && data.results && data.count > 0) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment namespace = data.results[0]; } diff --git a/frontend/hub/useHubView.tsx b/frontend/hub/useHubView.tsx index c6f792b071..9a6ec09179 100644 --- a/frontend/hub/useHubView.tsx +++ b/frontend/hub/useHubView.tsx @@ -22,6 +22,11 @@ export interface HubItemsResponse { }; } +export interface HubNamespaceResponse { + count: number; + results: T[]; +} + export type IHubView = IView & ISelected & { itemCount: number | undefined; From d873a301ef17d5ade64c88362789949faecd8b67 Mon Sep 17 00:00:00 2001 From: Shaiah Emigh-Doyle Date: Tue, 11 Jul 2023 16:10:18 -0400 Subject: [PATCH 11/30] update Collection type to CollectionVersionSearch --- .../hooks/useCollectionColumns.tsx | 45 ++++++++++++------- .../hub/namespaces/HubNamespaceDetails.tsx | 12 ++--- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/frontend/hub/collections/hooks/useCollectionColumns.tsx b/frontend/hub/collections/hooks/useCollectionColumns.tsx index 11e8139301..7972ce2a70 100644 --- a/frontend/hub/collections/hooks/useCollectionColumns.tsx +++ b/frontend/hub/collections/hooks/useCollectionColumns.tsx @@ -8,7 +8,7 @@ import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { ITableColumn, TextCell } from '../../../../framework'; import { RouteObj } from '../../../Routes'; -import { CollectionVersionSearch } from '../Collection'; +import { CollectionVersionSearch } from '../CollectionVersionSearch'; export function useCollectionColumns(_options?: { disableSort?: boolean; disableLinks?: boolean }) { const { t } = useTranslation(); @@ -16,19 +16,11 @@ export function useCollectionColumns(_options?: { disableSort?: boolean; disable () => [ { header: t('Name'), - value: (collection) => collection.collection_version.name, + value: (collection) => collection.collection_version?.name, cell: (collection) => ( ), card: 'name', @@ -45,7 +37,6 @@ export function useCollectionColumns(_options?: { disableSort?: boolean; disable header: t('Namespace'), type: 'text', value: (collection) => collection.collection_version.namespace, - sort: 'namespace', }, { header: t('Description'), @@ -60,6 +51,23 @@ export function useCollectionColumns(_options?: { disableSort?: boolean; disable value: (collection) => collection.collection_version.contents.filter((c) => c.content_type === 'module').length, }, + { + header: t('Roles'), + type: 'count', + value: (collection) => + collection.collection_version.contents.filter((c) => c.content_type === 'TODO').length, + }, + { + header: t('Plugins'), + type: 'count', + value: (collection) => + collection.collection_version.contents.filter((c) => c.content_type === 'TODO').length, + }, + { + header: t('Dependencies'), + type: 'count', + value: (collection) => Object.keys(collection.collection_version.dependencies).length, + }, { header: t('Updated'), type: 'datetime', @@ -78,14 +86,14 @@ export function useCollectionColumns(_options?: { disableSort?: boolean; disable { header: t('Signed state'), cell: (collection) => { - switch (collection.is_signed) { - case true: + switch (collection.collection_version.is_signed) { + case 'true': return ( ); - case false: + case 'false': return (