mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(docker/images): show used tag correctly [EE-5396] (#10305)
This commit is contained in:
parent
b895e88075
commit
9bf2957ea7
29 changed files with 383 additions and 287 deletions
9
app/react/docker/proxy/queries/images/queryKeys.ts
Normal file
9
app/react/docker/proxy/queries/images/queryKeys.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { queryKeys as proxyQueryKeys } from '../query-keys';
|
||||
|
||||
export const queryKeys = {
|
||||
base: (environmentId: EnvironmentId) =>
|
||||
[proxyQueryKeys.base(environmentId), 'images'] as const,
|
||||
list: (environmentId: EnvironmentId) => queryKeys.base(environmentId),
|
||||
};
|
36
app/react/docker/proxy/queries/images/useImages.ts
Normal file
36
app/react/docker/proxy/queries/images/useImages.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { useQuery } from 'react-query';
|
||||
import { ImageSummary } from 'docker-types/generated/1.41';
|
||||
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { buildUrl } from '../build-url';
|
||||
|
||||
import { queryKeys } from './queryKeys';
|
||||
|
||||
type ImagesListResponse = Array<ImageSummary>;
|
||||
|
||||
export function useImages<T = ImagesListResponse>(
|
||||
environmentId: EnvironmentId,
|
||||
{
|
||||
select,
|
||||
enabled,
|
||||
}: { select?(data: ImagesListResponse): T; enabled?: boolean } = {}
|
||||
) {
|
||||
return useQuery(
|
||||
queryKeys.list(environmentId),
|
||||
() => getImages(environmentId),
|
||||
{ select, enabled }
|
||||
);
|
||||
}
|
||||
|
||||
async function getImages(environmentId: EnvironmentId) {
|
||||
try {
|
||||
const { data } = await axios.get<ImagesListResponse>(
|
||||
buildUrl(environmentId, 'images', 'json')
|
||||
);
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw parseAxiosError(err as Error, 'Unable to retrieve images');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue