Fix: package search bug with RH repos in template

This fixes a bug inside of the package search step where packages from
additional (not the 2 default ones) RH repos were not coming up when
searching. This only happens when using a content template as that's
currently the only way to add more RH repos.
This commit is contained in:
Dominik Vagner 2025-06-16 16:26:55 +02:00 committed by Klara Simickova
parent 8d106499fd
commit eaead88a78

View file

@ -70,6 +70,7 @@ import {
useSearchPackageGroupMutation,
ApiSearchRpmResponse,
ApiPackageSourcesResponse,
useGetTemplateQuery,
} from '../../../../store/contentSourcesApi';
import { useAppSelector } from '../../../../store/hooks';
import { Package } from '../../../../store/imageBuilderApi';
@ -89,6 +90,7 @@ import {
addModule,
removeModule,
selectModules,
selectTemplate,
} from '../../../../store/wizardSlice';
import {
getEpelDefinitionForDistribution,
@ -138,6 +140,24 @@ const Packages = () => {
const packages = useAppSelector(selectPackages);
const groups = useAppSelector(selectGroups);
const modules = useAppSelector(selectModules);
const template = useAppSelector(selectTemplate);
const { data: templateData } = useGetTemplateQuery({
uuid: template,
});
const {
data: { data: reposInTemplate = [] } = {},
isLoading: isLoadingReposInTemplate,
} = useListRepositoriesQuery({
contentType: 'rpm',
limit: 100,
offset: 0,
uuid:
templateData && templateData.repository_uuids
? templateData.repository_uuids.join(',')
: '',
});
const { data: distroRepositories, isSuccess: isSuccessDistroRepositories } =
useGetArchitecturesQuery({
@ -256,16 +276,23 @@ const Packages = () => {
searchDistroRpms({
apiContentUnitSearchRequest: {
search: debouncedSearchTerm,
urls: distroRepositories
?.filter((archItem) => {
return archItem.arch === arch;
})[0]
.repositories.flatMap((repo) => {
if (!repo.baseurl) {
throw new Error(`Repository ${repo} missing baseurl`);
}
return repo.baseurl;
}),
urls:
template === ''
? distroRepositories
?.filter((archItem) => {
return archItem.arch === arch;
})[0]
.repositories.flatMap((repo) => {
if (!repo.baseurl) {
throw new Error(`Repository ${repo} missing baseurl`);
}
return repo.baseurl;
})
: reposInTemplate
.filter((r) => r.org_id === '-1' && !!r.url)
.flatMap((r) =>
r.url!.endsWith('/') ? r.url!.slice(0, -1) : r.url!
),
limit: 500,
include_package_sources: true,
},
@ -302,9 +329,11 @@ const Packages = () => {
searchRecommendedRpms,
epelRepoUrlByDistribution,
isSuccessDistroRepositories,
searchDistroRpms,
distroRepositories,
arch,
template,
distribution,
debouncedSearchTermIsGroup,
]);
useEffect(() => {
@ -353,6 +382,11 @@ const Packages = () => {
debouncedSearchTerm,
activeTabKey,
epelRepoUrlByDistribution,
debouncedSearchTermIsGroup,
arch,
distroRepositories,
isSuccessDistroRepositories,
isSuccessEpelRepo,
]);
const EmptySearch = () => {
@ -1338,6 +1372,7 @@ const Packages = () => {
(isLoadingDistroPackages ||
isLoadingCustomPackages ||
isLoadingDistroGroups ||
isLoadingReposInTemplate ||
isLoadingCustomGroups) &&
activeTabKey === Repos.INCLUDED):
return <Searching />;
@ -1384,6 +1419,7 @@ const Packages = () => {
sortedPackages,
activeSortDirection,
activeSortIndex,
template,
]);
const PackagesTable = () => {