Repositories: fix architecture/version display to use readable names from API
- Add listRepositoryParameters endpoint to contentSources API - Display human-readable names instead of technical labels - Fix inconsistency between Image Builder and Repositories service display - Resolve "any" vs "Any" capitalization issue - https://github.com/osbuild/image-builder-frontend/issues/3008
This commit is contained in:
parent
b59a729656
commit
df5388dae8
4 changed files with 64 additions and 4 deletions
|
|
@ -40,6 +40,7 @@ import {
|
|||
ApiRepositoryResponseRead,
|
||||
useListRepositoriesQuery,
|
||||
useGetTemplateQuery,
|
||||
useListRepositoryParametersQuery,
|
||||
} from '../../../../store/contentSourcesApi';
|
||||
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
|
||||
import {
|
||||
|
|
@ -87,6 +88,35 @@ const Repositories = () => {
|
|||
|
||||
const debouncedFilterValue = useDebounce(filterValue);
|
||||
|
||||
const { data: repositoryParameters } = useListRepositoryParametersQuery();
|
||||
|
||||
const getReadableArchitecture = (technicalArch: string | undefined) => {
|
||||
if (!technicalArch || !repositoryParameters?.distribution_arches) {
|
||||
return technicalArch || '-';
|
||||
}
|
||||
|
||||
const archParam = repositoryParameters.distribution_arches.find(
|
||||
(arch) => arch.label === technicalArch
|
||||
);
|
||||
|
||||
return archParam?.name || technicalArch;
|
||||
};
|
||||
|
||||
const getReadableVersions = (technicalVersions: string[] | undefined) => {
|
||||
if (!technicalVersions || !repositoryParameters?.distribution_versions) {
|
||||
return technicalVersions || '-';
|
||||
}
|
||||
|
||||
const readableVersions = technicalVersions.map((version) => {
|
||||
const versionParam = repositoryParameters.distribution_versions?.find(
|
||||
(v) => v.label === version
|
||||
);
|
||||
return versionParam?.name || version;
|
||||
});
|
||||
|
||||
return readableVersions.join(', ');
|
||||
};
|
||||
|
||||
const selected = useMemo(
|
||||
() =>
|
||||
new Set(
|
||||
|
|
@ -640,10 +670,10 @@ const Repositories = () => {
|
|||
)}
|
||||
</Td>
|
||||
<Td dataLabel={'Architecture'}>
|
||||
{distribution_arch || '-'}
|
||||
{getReadableArchitecture(distribution_arch)}
|
||||
</Td>
|
||||
<Td dataLabel={'Version'}>
|
||||
{distribution_versions || '-'}
|
||||
{getReadableVersions(distribution_versions)}
|
||||
</Td>
|
||||
<Td dataLabel={'Packages'}>{package_count || '-'}</Td>
|
||||
<Td dataLabel={'Status'}>
|
||||
|
|
@ -758,10 +788,10 @@ const Repositories = () => {
|
|||
)}
|
||||
</Td>
|
||||
<Td dataLabel={'Architecture'}>
|
||||
{distribution_arch || '-'}
|
||||
{getReadableArchitecture(distribution_arch)}
|
||||
</Td>
|
||||
<Td dataLabel={'Version'}>
|
||||
{distribution_versions || '-'}
|
||||
{getReadableVersions(distribution_versions)}
|
||||
</Td>
|
||||
<Td dataLabel={'Packages'}>{package_count || '-'}</Td>
|
||||
<Td dataLabel={'Status'}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue