import React from 'react'; import { Alert, Panel, PanelMain, Spinner } from '@patternfly/react-core'; import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; import { useListRepositoriesQuery } from '../../../../store/contentSourcesApi'; import { useAppSelector } from '../../../../store/hooks'; import { selectCustomRepositories, selectPackages, selectPartitions, } from '../../../../store/wizardSlice'; import { getConversionFactor } from '../FileSystem/FileSystemConfiguration'; type repoPropType = { repoUrl: string[] | undefined; }; const RepoName = ({ repoUrl }: repoPropType) => { const { data, isSuccess, isFetching, isError } = useListRepositoriesQuery( { // @ts-ignore if repoUrl is undefined the query is going to get skipped, so it's safe to ignore the linter here url: repoUrl, contentType: 'rpm', origin: 'external', }, { skip: !repoUrl } ); const errorLoading = () => { return ( ); }; return ( <> {/* this might be a tad bit hacky "isSuccess" indicates only that the query fetched successfuly, but it doesn't differentiate between a scenario when the repository was found in the response and when it was not for this reason I've split the "isSuccess" into two paths: - query finished and the repo was found -> render the name of the repo - query finished, but the repo was not found -> render an error */} {isSuccess && data.data?.[0]?.name &&

{data.data?.[0].name}

} {isSuccess && !data.data?.[0]?.name && errorLoading()} {isFetching && } {isError && errorLoading()} ); }; export const FSReviewTable = () => { const partitions = useAppSelector(selectPartitions); return ( {partitions.map((partition, partitionIndex) => ( ))}
Mount point File system type Minimum size
{partition.mountpoint} xfs {( parseInt(partition.min_size) / getConversionFactor(partition.unit) ).toString()}{' '} {partition.unit}
); }; export const PackagesTable = () => { const packages = useAppSelector(selectPackages); return ( {packages.map((pkg, pkgIndex) => ( ))}
Name Description Package repository
{pkg.name} {pkg.summary} {pkg.repository === 'distro' ? 'Red Hat repository' : pkg.repository === 'custom' ? 'Custom repository' : 'EPEL Everything x86_64'}
); }; export const RepositoriesTable = () => { const repositoriesList = useAppSelector(selectCustomRepositories); return ( {repositoriesList?.map((repo, repoIndex) => ( ))}
Name
); };