import { Link } from 'react-router-dom'; import { Flex, FlexItem } from '@patternfly/react-core'; import { COMPONENT_DETAILS_V2_PATH, COMPONENT_VERSION_DETAILS_PATH, GROUP_DETAILS_PATH, } from '@routes/paths'; import { Timestamp } from '~/shared'; import { defineFilters } from '~/shared/components/Filter'; import { ColumnDefinition } from '~/shared/components/TableV2'; import { ComponentGroupKind } from '~/types'; import { getLatestPromotedBuild } from '~/utils/component-group-utils'; import { textMatch } from '~/utils/text-filter-utils'; import ComponentGroupPromotionStatus from '../ComponentGroupPromotionStatus'; export const componentGroupsFilterConfig = defineFilters()([ { type: 'search', param: 'name', label: 'Name', mode: 'client', filterFn: (item, value) => textMatch(item.metadata?.name ?? '', value), }, ] as const); export const componentGroupsTableColumns: ColumnDefinition[] = [ { id: 'name', header: 'Name', accessorFn: (row) => row.metadata?.name ?? '-', sortable: true, size: 2, nonHidable: true, cell: (info) => { const groupName = info.row.original.metadata?.name ?? '-'; return ( {groupName} ); }, }, { id: 'components', header: 'Components', accessorFn: (row) => row.spec?.components?.length ?? 0, nonHidable: true, cell: (info) => {info.getValue() as number}, }, { id: 'last-build', header: 'Last promoted build', accessorFn: (row) => getLatestPromotedBuild(row.status?.globalCandidateList ?? [])?.lastPromotedBuildTime, nonHidable: true, size: 2, cell: (info) => { const namespace = info.row.original.metadata?.namespace; const latestBuild = getLatestPromotedBuild( info.row.original.status?.globalCandidateList ?? [], ); if (!latestBuild) { return No Builds yet; } return ( {latestBuild.name} {latestBuild.version ? <> on {latestBuild.version} : null} • ); }, }, { id: 'promotion-status', header: 'Promotion status', cell: (info) => { const group = info.row.original; return ; }, }, ] as const;