CreateImageWizard/Repositories: show hint why a repo is disabled

This commit is contained in:
Florian Schüller 2024-04-30 11:02:22 +02:00 committed by Klara Simickova
parent 1511b3f232
commit 8ac3fe5409

View file

@ -260,16 +260,29 @@ const Repositories = () => {
);
};
const isRepoDisabled = (repo: ApiRepositoryResponseRead) => {
return (
// repository data is still fetching, it's not valid
// or it comes from the repository recommendations
// and removing it would mean invalidating packages
// added from the recommended repository
isFetching ||
repo.status !== 'Valid' ||
(recommendedRepos.length > 0 && repo.url?.includes('epel'))
);
const isRepoDisabled = (
repo: ApiRepositoryResponseRead
): [boolean, string] => {
if (isFetching) {
return [true, 'Repository data is still fetching, please wait.'];
}
if (recommendedRepos.length > 0 && repo.url?.includes('epel')) {
return [
true,
'Selecting this repository would invalidate packages added from recommended repositories.\n' +
'Please use another combination of custom and recommended repositories.',
];
}
if (repo.status !== 'Valid') {
return [
true,
`Repository can't be selected. The status is still '${repo.status}'.`,
];
}
return [false, '']; // Repository is enabled
};
const handlePerPageSelect = (
@ -550,6 +563,8 @@ const Repositories = () => {
}
const repoExists = repo.name ? true : false;
const [isDisabled, disabledReason] =
isRepoDisabled(repo);
return (
<Tr key={repo.url}>
<Td
@ -562,8 +577,9 @@ const Repositories = () => {
rowIndex,
isSelecting
),
isDisabled: isRepoDisabled(repo),
isDisabled: isDisabled,
}}
title={disabledReason}
/>
<Td dataLabel={'Name'}>
{repoExists