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
|
|
@ -12,6 +12,7 @@ const config: ConfigFile = {
|
||||||
'createRepository',
|
'createRepository',
|
||||||
'listRepositories',
|
'listRepositories',
|
||||||
'listRepositoriesRpms',
|
'listRepositoriesRpms',
|
||||||
|
'listRepositoryParameters',
|
||||||
'searchRpm',
|
'searchRpm',
|
||||||
'searchPackageGroup',
|
'searchPackageGroup',
|
||||||
'listFeatures',
|
'listFeatures',
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import {
|
||||||
ApiRepositoryResponseRead,
|
ApiRepositoryResponseRead,
|
||||||
useListRepositoriesQuery,
|
useListRepositoriesQuery,
|
||||||
useGetTemplateQuery,
|
useGetTemplateQuery,
|
||||||
|
useListRepositoryParametersQuery,
|
||||||
} from '../../../../store/contentSourcesApi';
|
} from '../../../../store/contentSourcesApi';
|
||||||
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
|
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
|
||||||
import {
|
import {
|
||||||
|
|
@ -87,6 +88,35 @@ const Repositories = () => {
|
||||||
|
|
||||||
const debouncedFilterValue = useDebounce(filterValue);
|
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(
|
const selected = useMemo(
|
||||||
() =>
|
() =>
|
||||||
new Set(
|
new Set(
|
||||||
|
|
@ -640,10 +670,10 @@ const Repositories = () => {
|
||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td dataLabel={'Architecture'}>
|
<Td dataLabel={'Architecture'}>
|
||||||
{distribution_arch || '-'}
|
{getReadableArchitecture(distribution_arch)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td dataLabel={'Version'}>
|
<Td dataLabel={'Version'}>
|
||||||
{distribution_versions || '-'}
|
{getReadableVersions(distribution_versions)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td dataLabel={'Packages'}>{package_count || '-'}</Td>
|
<Td dataLabel={'Packages'}>{package_count || '-'}</Td>
|
||||||
<Td dataLabel={'Status'}>
|
<Td dataLabel={'Status'}>
|
||||||
|
|
@ -758,10 +788,10 @@ const Repositories = () => {
|
||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td dataLabel={'Architecture'}>
|
<Td dataLabel={'Architecture'}>
|
||||||
{distribution_arch || '-'}
|
{getReadableArchitecture(distribution_arch)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td dataLabel={'Version'}>
|
<Td dataLabel={'Version'}>
|
||||||
{distribution_versions || '-'}
|
{getReadableVersions(distribution_versions)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td dataLabel={'Packages'}>{package_count || '-'}</Td>
|
<Td dataLabel={'Packages'}>{package_count || '-'}</Td>
|
||||||
<Td dataLabel={'Status'}>
|
<Td dataLabel={'Status'}>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export const {
|
||||||
useCreateRepositoryMutation,
|
useCreateRepositoryMutation,
|
||||||
useBulkImportRepositoriesMutation,
|
useBulkImportRepositoriesMutation,
|
||||||
useListRepositoriesRpmsQuery,
|
useListRepositoriesRpmsQuery,
|
||||||
|
useListRepositoryParametersQuery,
|
||||||
useListTemplatesQuery,
|
useListTemplatesQuery,
|
||||||
useGetTemplateQuery,
|
useGetTemplateQuery,
|
||||||
contentSourcesApi,
|
contentSourcesApi,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,12 @@ const injectedRtkApi = api.injectEndpoints({
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
listRepositoryParameters: build.query<
|
||||||
|
ListRepositoryParametersApiResponse,
|
||||||
|
ListRepositoryParametersApiArg
|
||||||
|
>({
|
||||||
|
query: () => ({ url: `/repository_parameters/` }),
|
||||||
|
}),
|
||||||
searchRpm: build.mutation<SearchRpmApiResponse, SearchRpmApiArg>({
|
searchRpm: build.mutation<SearchRpmApiResponse, SearchRpmApiArg>({
|
||||||
query: (queryArg) => ({
|
query: (queryArg) => ({
|
||||||
url: `/rpms/names`,
|
url: `/rpms/names`,
|
||||||
|
|
@ -177,6 +183,9 @@ export type ListRepositoriesRpmsApiArg = {
|
||||||
/** Sort the response based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`. */
|
/** Sort the response based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`. */
|
||||||
sortBy?: string;
|
sortBy?: string;
|
||||||
};
|
};
|
||||||
|
export type ListRepositoryParametersApiResponse =
|
||||||
|
/** status 200 OK */ ApiRepositoryParameterResponse;
|
||||||
|
export type ListRepositoryParametersApiArg = void;
|
||||||
export type SearchRpmApiResponse = /** status 200 OK */ ApiSearchRpmResponse[];
|
export type SearchRpmApiResponse = /** status 200 OK */ ApiSearchRpmResponse[];
|
||||||
export type SearchRpmApiArg = {
|
export type SearchRpmApiArg = {
|
||||||
/** request body */
|
/** request body */
|
||||||
|
|
@ -639,6 +648,24 @@ export type ApiRepositoryRpmCollectionResponse = {
|
||||||
links?: ApiLinks | undefined;
|
links?: ApiLinks | undefined;
|
||||||
meta?: ApiResponseMetadata | undefined;
|
meta?: ApiResponseMetadata | undefined;
|
||||||
};
|
};
|
||||||
|
export type ConfigDistributionArch = {
|
||||||
|
/** Static label of the architecture */
|
||||||
|
label?: string | undefined;
|
||||||
|
/** Human-readable form of the architecture */
|
||||||
|
name?: string | undefined;
|
||||||
|
};
|
||||||
|
export type ConfigDistributionVersion = {
|
||||||
|
/** Static label of the version */
|
||||||
|
label?: string | undefined;
|
||||||
|
/** Human-readable form of the version */
|
||||||
|
name?: string | undefined;
|
||||||
|
};
|
||||||
|
export type ApiRepositoryParameterResponse = {
|
||||||
|
/** Architectures available for repository creation */
|
||||||
|
distribution_arches?: ConfigDistributionArch[] | undefined;
|
||||||
|
/** Versions available for repository creation */
|
||||||
|
distribution_versions?: ConfigDistributionVersion[] | undefined;
|
||||||
|
};
|
||||||
export type ApiPackageSourcesResponse = {
|
export type ApiPackageSourcesResponse = {
|
||||||
/** Architecture of the module */
|
/** Architecture of the module */
|
||||||
arch?: string | undefined;
|
arch?: string | undefined;
|
||||||
|
|
@ -776,6 +803,7 @@ export const {
|
||||||
useCreateRepositoryMutation,
|
useCreateRepositoryMutation,
|
||||||
useBulkImportRepositoriesMutation,
|
useBulkImportRepositoriesMutation,
|
||||||
useListRepositoriesRpmsQuery,
|
useListRepositoriesRpmsQuery,
|
||||||
|
useListRepositoryParametersQuery,
|
||||||
useSearchRpmMutation,
|
useSearchRpmMutation,
|
||||||
useListSnapshotsByDateMutation,
|
useListSnapshotsByDateMutation,
|
||||||
useListTemplatesQuery,
|
useListTemplatesQuery,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue