Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/Components/CreateImageWizard/steps/Packages/Packages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ import {
selectModules,
selectPackages,
selectRecommendedRepositories,
selectSnapshotDate,
selectTemplate,
} from '../../../../store/wizardSlice';
import {
getEpelDefinitionForDistribution,
getEpelUrlForDistribution,
getEpelVersionForDistribution,
} from '../../../../Utilities/epel';
import { convertStringToDate } from '../../../../Utilities/time';
import useDebounce from '../../../../Utilities/useDebounce';

export type PackageRepository = 'distro' | 'custom' | 'recommended' | '';
Expand Down Expand Up @@ -144,6 +146,7 @@ const Packages = () => {
const groups = useAppSelector(selectGroups);
const modules = useAppSelector(selectModules);
const template = useAppSelector(selectTemplate);
const snapshotDate = useAppSelector(selectSnapshotDate);

const { data: templateData } = useGetTemplateQuery({
uuid: template,
Expand Down Expand Up @@ -298,6 +301,9 @@ const Packages = () => {
),
limit: 500,
include_package_sources: true,
date: snapshotDate
? new Date(convertStringToDate(snapshotDate)).toISOString()
: undefined,
},
});
}
Expand All @@ -312,13 +318,19 @@ const Packages = () => {
}),
limit: 500,
include_package_sources: true,
date: snapshotDate
? new Date(convertStringToDate(snapshotDate)).toISOString()
: undefined,
},
});
} else {
searchRecommendedRpms({
apiContentUnitSearchRequest: {
search: debouncedSearchTerm,
urls: [epelRepoUrlByDistribution],
date: snapshotDate
? new Date(convertStringToDate(snapshotDate)).toISOString()
: undefined,
},
});
}
Expand All @@ -337,6 +349,7 @@ const Packages = () => {
template,
distribution,
debouncedSearchTermIsGroup,
snapshotDate,
]);

useEffect(() => {
Expand All @@ -346,7 +359,7 @@ const Packages = () => {
if (isSuccessDistroRepositories) {
searchDistroGroups({
apiContentUnitSearchRequest: {
search: debouncedSearchTerm.substr(1),
search: debouncedSearchTerm.substring(1),
urls: distroRepositories
?.filter((archItem) => {
return archItem.arch === arch;
Expand All @@ -357,23 +370,32 @@ const Packages = () => {
}
return repo.baseurl;
}),
date: snapshotDate
? new Date(convertStringToDate(snapshotDate)).toISOString()
: undefined,
},
});
}
if (activeTabKey === Repos.INCLUDED && customRepositories.length > 0) {
searchCustomGroups({
apiContentUnitSearchRequest: {
search: debouncedSearchTerm.substr(1),
search: debouncedSearchTerm.substring(1),
uuids: customRepositories.flatMap((repo) => {
return repo.id;
}),
date: snapshotDate
? new Date(convertStringToDate(snapshotDate)).toISOString()
: undefined,
},
});
} else if (activeTabKey === Repos.OTHER && isSuccessEpelRepo) {
searchRecommendedGroups({
apiContentUnitSearchRequest: {
search: debouncedSearchTerm.substr(1),
search: debouncedSearchTerm.substring(1),
urls: [epelRepoUrlByDistribution],
date: snapshotDate
? new Date(convertStringToDate(snapshotDate)).toISOString()
: undefined,
},
});
}
Expand All @@ -390,6 +412,7 @@ const Packages = () => {
distroRepositories,
isSuccessDistroRepositories,
isSuccessEpelRepo,
snapshotDate,
]);

const EmptySearch = () => {
Expand Down Expand Up @@ -1255,12 +1278,12 @@ const Packages = () => {
bodyContent={
<div
style={
grp.package_list.length > 0
grp.package_list?.length > 0
? { height: '40em', overflow: 'scroll' }
: {}
}
>
{grp.package_list.length > 0 ? (
{grp.package_list?.length > 0 ? (
<Table
variant='compact'
data-testid='group-included-packages-table'
Expand Down Expand Up @@ -1438,6 +1461,7 @@ const Packages = () => {
toggleSelected,
activeTabKey,
transformedPackages,
transformedGroups,
isSelectingPackage,
recommendedRepositories,
transformedPackages.length,
Expand Down
Loading
Loading