Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NCL-7210] Implement Built Artifacts page #269

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/components/BuildArtifactsPage/BuildArtifactsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
import { ContentBox } from 'components/ContentBox/ContentBox';
import { useParams } from 'react-router-dom';

export const BuildArtifactsPage = () => {
return <ContentBox padding></ContentBox>;
import { useQueryParamsEffect } from 'hooks/useQueryParamsEffect';
import { useServiceContainer } from 'hooks/useServiceContainer';

import { ArtifactsList } from 'components/ArtifactsList/ArtifactsList';

import * as buildApi from 'services/buildApi';

interface IBuildArtifactsPageProps {
componentId?: string;
}

export const BuildArtifactsPage = ({ componentId = 'a1' }: IBuildArtifactsPageProps) => {
const { buildId } = useParams();

const serviceContainerArtifacts = useServiceContainer(buildApi.getBuiltArtifacts);
const serviceContainerArtifactsRunner = serviceContainerArtifacts.run;

useQueryParamsEffect(
({ requestConfig } = {}) => serviceContainerArtifactsRunner({ serviceData: { id: buildId }, requestConfig }),
{ componentId }
);

return <ArtifactsList {...{ serviceContainerArtifacts, componentId }} />;
};
13 changes: 12 additions & 1 deletion src/services/buildApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosRequestConfig } from 'axios';

import { Build, BuildPage, BuildsGraph, RunningBuildCount } from 'pnc-api-types-ts';
import { ArtifactPage, Build, BuildPage, BuildsGraph, RunningBuildCount } from 'pnc-api-types-ts';

import { mockClient } from 'services/mockClient';

Expand Down Expand Up @@ -38,6 +38,17 @@ export const getBuild = ({ id }: IBuildApiData, requestConfig: AxiosRequestConfi
return pncClient.getHttpClient().get<Build>(`/builds/${id}`, requestConfig);
};

/**
* Gets Artifacts built in a Build.
*
* @param serviceData - object containing:
* - id - Build ID
* @param requestConfig - Axios based request config
*/
export const getBuiltArtifacts = ({ id }: IBuildApiData, requestConfig: AxiosRequestConfig = {}) => {
return pncClient.getHttpClient().get<ArtifactPage>(`/builds/${id}/artifacts/built`, requestConfig);
};

/**
* Gets Build Metrics by a list of build Ids.
*
Expand Down