Skip to content

Commit 1683f24

Browse files
committed
feat(artifacts): add artifacts queries, mocks
1 parent 4423da9 commit 1683f24

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Content, PageSection, Tab, TabContent, Tabs, TabTitleText } from "@patternfly/react-core";
2+
import { ExternalLinkAltIcon } from "@patternfly/react-icons";
3+
4+
import { LoadingWrapper } from "@app/components/LoadingWrapper";
5+
import { useFetchArtifactsImageData } from "@app/queries/artifacts";
6+
7+
export const Artifacts = () => {};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Artifacts as default } from "./Artifacts";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { AxiosError } from "axios";
2+
3+
import { client } from "@app/axios-config/apiInit";
4+
import { getApiV1ArtifactsImage, type _Error, type ImageMetadataResponse } from "@app/client";
5+
import { useMockableQuery } from "./helpers";
6+
import { artifactsImageDataMock } from "./mocks/artifacts.mock";
7+
8+
export const ArtifactsKey = "Artifacts";
9+
10+
export const useFetchArtifactsImageData = () => {
11+
const { data, isLoading, error, refetch } = useMockableQuery<ImageMetadataResponse | null, AxiosError<_Error>>(
12+
{
13+
queryKey: [ArtifactsKey, "image"],
14+
queryFn: async () => {
15+
const response = await getApiV1ArtifactsImage({ client, query: { uri: "" } });
16+
return response.data ?? null;
17+
},
18+
},
19+
artifactsImageDataMock
20+
);
21+
22+
return { config: data, isFetching: isLoading, fetchError: error, refetch };
23+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { ImageMetadataResponse, Metadata } from "@app/client";
2+
3+
export const artifactsImageDataMock: ImageMetadataResponse = {
4+
image: "docker.io/library/nginx:latest",
5+
6+
// container image metadata
7+
metadata: {
8+
// media type of the container image (e.g., OCI manifest type)
9+
mediaType: "application/vnd.oci.image.manifest.v1+json",
10+
11+
// size of container image
12+
size: 1234,
13+
14+
// key-value labels or annotations associated with image
15+
labels: {
16+
"org.opencontainers.image.version": "1.0.0",
17+
},
18+
} as Metadata,
19+
// container image's digest
20+
digest: "sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
21+
};

0 commit comments

Comments
 (0)