Skip to content

Commit 732fcff

Browse files
dominikvagnerregexowl
authored andcommitted
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 3aa5b57 commit 732fcff

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ import {
9393
selectModules,
9494
selectPackages,
9595
selectRecommendedRepositories,
96+
selectSnapshotDate,
9697
selectTemplate,
9798
} from '../../../../store/wizardSlice';
9899
import {
99100
getEpelDefinitionForDistribution,
100101
getEpelUrlForDistribution,
101102
getEpelVersionForDistribution,
102103
} from '../../../../Utilities/epel';
104+
import { convertStringToDate } from '../../../../Utilities/time';
103105
import useDebounce from '../../../../Utilities/useDebounce';
104106

105107
export type PackageRepository = 'distro' | 'custom' | 'recommended' | '';
@@ -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,9 @@ const Packages = () => {
298301
),
299302
limit: 500,
300303
include_package_sources: true,
304+
date: snapshotDate
305+
? new Date(convertStringToDate(snapshotDate)).toISOString()
306+
: undefined,
301307
},
302308
});
303309
}
@@ -312,13 +318,19 @@ const Packages = () => {
312318
}),
313319
limit: 500,
314320
include_package_sources: true,
321+
date: snapshotDate
322+
? new Date(convertStringToDate(snapshotDate)).toISOString()
323+
: undefined,
315324
},
316325
});
317326
} else {
318327
searchRecommendedRpms({
319328
apiContentUnitSearchRequest: {
320329
search: debouncedSearchTerm,
321330
urls: [epelRepoUrlByDistribution],
331+
date: snapshotDate
332+
? new Date(convertStringToDate(snapshotDate)).toISOString()
333+
: undefined,
322334
},
323335
});
324336
}
@@ -337,6 +349,7 @@ const Packages = () => {
337349
template,
338350
distribution,
339351
debouncedSearchTermIsGroup,
352+
snapshotDate,
340353
]);
341354

342355
useEffect(() => {
@@ -346,7 +359,7 @@ const Packages = () => {
346359
if (isSuccessDistroRepositories) {
347360
searchDistroGroups({
348361
apiContentUnitSearchRequest: {
349-
search: debouncedSearchTerm.substr(1),
362+
search: debouncedSearchTerm.substring(1),
350363
urls: distroRepositories
351364
?.filter((archItem) => {
352365
return archItem.arch === arch;
@@ -357,23 +370,32 @@ const Packages = () => {
357370
}
358371
return repo.baseurl;
359372
}),
373+
date: snapshotDate
374+
? new Date(convertStringToDate(snapshotDate)).toISOString()
375+
: undefined,
360376
},
361377
});
362378
}
363379
if (activeTabKey === Repos.INCLUDED && customRepositories.length > 0) {
364380
searchCustomGroups({
365381
apiContentUnitSearchRequest: {
366-
search: debouncedSearchTerm.substr(1),
382+
search: debouncedSearchTerm.substring(1),
367383
uuids: customRepositories.flatMap((repo) => {
368384
return repo.id;
369385
}),
386+
date: snapshotDate
387+
? new Date(convertStringToDate(snapshotDate)).toISOString()
388+
: undefined,
370389
},
371390
});
372391
} else if (activeTabKey === Repos.OTHER && isSuccessEpelRepo) {
373392
searchRecommendedGroups({
374393
apiContentUnitSearchRequest: {
375-
search: debouncedSearchTerm.substr(1),
394+
search: debouncedSearchTerm.substring(1),
376395
urls: [epelRepoUrlByDistribution],
396+
date: snapshotDate
397+
? new Date(convertStringToDate(snapshotDate)).toISOString()
398+
: undefined,
377399
},
378400
});
379401
}
@@ -390,6 +412,7 @@ const Packages = () => {
390412
distroRepositories,
391413
isSuccessDistroRepositories,
392414
isSuccessEpelRepo,
415+
snapshotDate,
393416
]);
394417

395418
const EmptySearch = () => {
@@ -1438,6 +1461,7 @@ const Packages = () => {
14381461
toggleSelected,
14391462
activeTabKey,
14401463
transformedPackages,
1464+
transformedGroups,
14411465
isSelectingPackage,
14421466
recommendedRepositories,
14431467
transformedPackages.length,

0 commit comments

Comments
 (0)