Skip to content

Commit f95ef97

Browse files
committed
fix: make packages search respect chosen date
This fixes an issue with the 'Packages' step where you could pick additional packages that might not be available in the included repositories at the chosen snapshot date, or ones that were removed. This would be very complicated to do solely in this frontend so the names search APIs were extended to support a date argument and search the correct snapshots for the content when that's provided.
1 parent 6c458ff commit f95ef97

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Components/CreateImageWizard/steps/Packages/Packages.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import {
9393
selectModules,
9494
selectPackages,
9595
selectRecommendedRepositories,
96+
selectSnapshotDate,
9697
selectTemplate,
9798
} from '../../../../store/wizardSlice';
9899
import {
@@ -101,6 +102,7 @@ import {
101102
getEpelVersionForDistribution,
102103
} from '../../../../Utilities/epel';
103104
import useDebounce from '../../../../Utilities/useDebounce';
105+
import { convertStringToDate } from '../../../../Utilities/time';
104106

105107
export type PackageRepository = 'distro' | 'custom' | 'recommended' | '';
106108

@@ -144,6 +146,7 @@ const Packages = () => {
144146
const groups = useAppSelector(selectGroups);
145147
const modules = useAppSelector(selectModules);
146148
const template = useAppSelector(selectTemplate);
149+
const snapshotDate = useAppSelector(selectSnapshotDate);
147150

148151
const { data: templateData } = useGetTemplateQuery({
149152
uuid: template,
@@ -298,6 +301,7 @@ const Packages = () => {
298301
),
299302
limit: 500,
300303
include_package_sources: true,
304+
date: !!snapshotDate ? new Date(convertStringToDate(snapshotDate)).toISOString() : undefined,
301305
},
302306
});
303307
}
@@ -312,13 +316,15 @@ const Packages = () => {
312316
}),
313317
limit: 500,
314318
include_package_sources: true,
319+
date: !!snapshotDate ? new Date(convertStringToDate(snapshotDate)).toISOString() : undefined,
315320
},
316321
});
317322
} else {
318323
searchRecommendedRpms({
319324
apiContentUnitSearchRequest: {
320325
search: debouncedSearchTerm,
321326
urls: [epelRepoUrlByDistribution],
327+
date: !!snapshotDate ? new Date(convertStringToDate(snapshotDate)).toISOString() : undefined,
322328
},
323329
});
324330
}
@@ -337,6 +343,7 @@ const Packages = () => {
337343
template,
338344
distribution,
339345
debouncedSearchTermIsGroup,
346+
snapshotDate,
340347
]);
341348

342349
useEffect(() => {
@@ -346,7 +353,7 @@ const Packages = () => {
346353
if (isSuccessDistroRepositories) {
347354
searchDistroGroups({
348355
apiContentUnitSearchRequest: {
349-
search: debouncedSearchTerm.substr(1),
356+
search: debouncedSearchTerm.substring(1),
350357
urls: distroRepositories
351358
?.filter((archItem) => {
352359
return archItem.arch === arch;
@@ -357,23 +364,26 @@ const Packages = () => {
357364
}
358365
return repo.baseurl;
359366
}),
367+
date: !!snapshotDate ? new Date(convertStringToDate(snapshotDate)).toISOString() : undefined,
360368
},
361369
});
362370
}
363371
if (activeTabKey === Repos.INCLUDED && customRepositories.length > 0) {
364372
searchCustomGroups({
365373
apiContentUnitSearchRequest: {
366-
search: debouncedSearchTerm.substr(1),
374+
search: debouncedSearchTerm.substring(1),
367375
uuids: customRepositories.flatMap((repo) => {
368376
return repo.id;
369377
}),
378+
date: !!snapshotDate ? new Date(convertStringToDate(snapshotDate)).toISOString() : undefined,
370379
},
371380
});
372381
} else if (activeTabKey === Repos.OTHER && isSuccessEpelRepo) {
373382
searchRecommendedGroups({
374383
apiContentUnitSearchRequest: {
375-
search: debouncedSearchTerm.substr(1),
384+
search: debouncedSearchTerm.substring(1),
376385
urls: [epelRepoUrlByDistribution],
386+
date: !!snapshotDate ? new Date(convertStringToDate(snapshotDate)).toISOString() : undefined,
377387
},
378388
});
379389
}
@@ -390,6 +400,7 @@ const Packages = () => {
390400
distroRepositories,
391401
isSuccessDistroRepositories,
392402
isSuccessEpelRepo,
403+
snapshotDate,
393404
]);
394405

395406
const EmptySearch = () => {
@@ -1438,6 +1449,7 @@ const Packages = () => {
14381449
toggleSelected,
14391450
activeTabKey,
14401451
transformedPackages,
1452+
transformedGroups,
14411453
isSelectingPackage,
14421454
recommendedRepositories,
14431455
transformedPackages.length,

src/store/service/contentSourcesApi.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ export type ErrorsErrorResponse = {
254254
errors?: ErrorsHandlerError[] | undefined;
255255
};
256256
export type ApiContentUnitSearchRequest = {
257+
/** Optional date to search in dated snapshots of the listed repositories. */
258+
date?: string | undefined;
257259
/** List of names to search using an exact match */
258260
exact_names?: string[] | undefined;
259261
/** Whether to include module information */

0 commit comments

Comments
 (0)