Cleanup unused types
This commit is contained in:
@@ -18,7 +18,6 @@ import { createApiRef } from '@backstage/core';
|
||||
import {
|
||||
ActionsListWorkflowRunsForRepoResponseData,
|
||||
ActionsGetWorkflowResponseData,
|
||||
ActionsGetWorkflowRunResponseData,
|
||||
} from '../api/types';
|
||||
|
||||
export const cloudbuildApiRef = createApiRef<CloudbuildApi>({
|
||||
@@ -51,7 +50,7 @@ export type CloudbuildApi = {
|
||||
token: string;
|
||||
projectId: string;
|
||||
id: string;
|
||||
}) => Promise<ActionsGetWorkflowRunResponseData>;
|
||||
}) => Promise<ActionsGetWorkflowResponseData>;
|
||||
reRunWorkflow: ({
|
||||
token,
|
||||
projectId,
|
||||
|
||||
@@ -18,8 +18,7 @@ import { CloudbuildApi } from './CloudbuildApi';
|
||||
import {
|
||||
ActionsListWorkflowRunsForRepoResponseData,
|
||||
ActionsGetWorkflowResponseData,
|
||||
ActionsGetWorkflowRunResponseData,
|
||||
Build,
|
||||
Builds,
|
||||
} from '../api/types';
|
||||
|
||||
export class CloudbuildClient implements CloudbuildApi {
|
||||
@@ -59,11 +58,11 @@ export class CloudbuildClient implements CloudbuildApi {
|
||||
},
|
||||
);
|
||||
|
||||
const builds: Build[] = await workflowRuns.json();
|
||||
const builds: Builds = await workflowRuns.json();
|
||||
|
||||
const response: ActionsListWorkflowRunsForRepoResponseData = {
|
||||
total_count: builds.length,
|
||||
builds: builds,
|
||||
total_count: builds.builds.length,
|
||||
builds: builds.builds,
|
||||
};
|
||||
|
||||
return response;
|
||||
@@ -99,7 +98,7 @@ export class CloudbuildClient implements CloudbuildApi {
|
||||
token: string;
|
||||
projectId: string;
|
||||
id: string;
|
||||
}): Promise<ActionsGetWorkflowRunResponseData> {
|
||||
}): Promise<ActionsGetWorkflowResponseData> {
|
||||
const workflow = await fetch(
|
||||
`https://cloudbuild.googleapis.com/v1/projects/${projectId}/builds/${id}`,
|
||||
{
|
||||
|
||||
@@ -14,61 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface Build {
|
||||
id: string;
|
||||
status: string;
|
||||
source: Source;
|
||||
createTime: string;
|
||||
startTime: string;
|
||||
steps: Step[];
|
||||
timeout: string;
|
||||
projectId: string;
|
||||
logsBucket: string;
|
||||
sourceProvenance: SourceProvenance;
|
||||
buildTriggerId: string;
|
||||
options: Options;
|
||||
logUrl: string;
|
||||
substitutions: Substitutions;
|
||||
tags: string[];
|
||||
queueTtl: string;
|
||||
name: string;
|
||||
finishTime: any;
|
||||
results: Results;
|
||||
timing: Timing2;
|
||||
}
|
||||
|
||||
export type Jobs = {
|
||||
total_count: number;
|
||||
jobs: Build[];
|
||||
};
|
||||
|
||||
export interface ActionsListWorkflowRunsForRepoResponseData {
|
||||
total_count: number;
|
||||
builds: Build[];
|
||||
builds: ActionsGetWorkflowResponseData[];
|
||||
}
|
||||
export type ActionsGetWorkflowResponseData = {
|
||||
id: string;
|
||||
status: string;
|
||||
source: Source;
|
||||
createTime: string;
|
||||
startTime: string;
|
||||
steps: Step[];
|
||||
timeout: string;
|
||||
projectId: string;
|
||||
logsBucket: string;
|
||||
sourceProvenance: SourceProvenance;
|
||||
buildTriggerId: string;
|
||||
options: Options;
|
||||
logUrl: string;
|
||||
substitutions: Substitutions;
|
||||
tags: string[];
|
||||
queueTtl: string;
|
||||
name: string;
|
||||
finishTime: any;
|
||||
results: Results;
|
||||
timing: Timing2;
|
||||
|
||||
export type Builds = {
|
||||
builds: ActionsGetWorkflowResponseData[];
|
||||
};
|
||||
export type ActionsGetWorkflowRunResponseData = {
|
||||
|
||||
export type ActionsGetWorkflowResponseData = {
|
||||
id: string;
|
||||
status: string;
|
||||
source: Source;
|
||||
|
||||
@@ -60,97 +60,11 @@ const useStyles = makeStyles<Theme>(theme => ({
|
||||
},
|
||||
}));
|
||||
|
||||
// const JobsList = ({ jobs, entity }: { jobs?: Jobs; entity: Entity }) => {
|
||||
// const classes = useStyles();
|
||||
// return (
|
||||
// <Box>
|
||||
// {jobs &&
|
||||
// jobs.total_count > 0 &&
|
||||
// jobs.jobs.map((job: Build) => (
|
||||
// <JobListItem
|
||||
// job={job}
|
||||
// className={
|
||||
// job.status !== 'success' ? classes.failed : classes.success
|
||||
// }
|
||||
// entity={entity}
|
||||
// />
|
||||
// ))}
|
||||
// </Box>
|
||||
// );
|
||||
// };
|
||||
|
||||
// const getElapsedTime = (start: string, end: string) => {
|
||||
// const diff = moment(moment(end || moment()).diff(moment(start)));
|
||||
// const timeElapsed = diff.format('m [minutes] s [seconds]');
|
||||
// return timeElapsed;
|
||||
// };
|
||||
|
||||
// const StepView = ({ step }: { step: Step }) => {
|
||||
// return (
|
||||
// <TableRow>
|
||||
// <TableCell>
|
||||
// <ListItemText
|
||||
// primary={step.name}
|
||||
// secondary={getElapsedTime(step.pullTiming.startTime, step.pullTiming.endTime)}
|
||||
// />
|
||||
// </TableCell>
|
||||
// <TableCell>
|
||||
// <WorkflowRunStatus status={step.status.toUpperCase()} />
|
||||
// </TableCell>
|
||||
// </TableRow>
|
||||
// );
|
||||
// };
|
||||
|
||||
// const JobListItem = ({
|
||||
// job,
|
||||
// className,
|
||||
// entity,
|
||||
// }: {
|
||||
// job: Build;
|
||||
// className: string;
|
||||
// entity: Entity;
|
||||
// }) => {
|
||||
// const classes = useStyles();
|
||||
// return (
|
||||
// <Accordion TransitionProps={{ unmountOnExit: true }} className={className}>
|
||||
// <AccordionSummary
|
||||
// expandIcon={<ExpandMoreIcon />}
|
||||
// aria-controls={`panel-${name}-content`}
|
||||
// id={`panel-${name}-header`}
|
||||
// IconButtonProps={{
|
||||
// className: classes.button,
|
||||
// }}
|
||||
// >
|
||||
// <Typography variant="button">
|
||||
// {job.name} ({getElapsedTime(job.startTime, job.finishTime)})
|
||||
// </Typography>
|
||||
// </AccordionSummary>
|
||||
// <AccordionDetails className={classes.accordionDetails}>
|
||||
// <TableContainer>
|
||||
// <Table>
|
||||
// {job.steps.map((step: Step) => (
|
||||
// <StepView step={step} />
|
||||
// ))}
|
||||
// </Table>
|
||||
// </TableContainer>
|
||||
// </AccordionDetails>
|
||||
// {job.status === 'QUEUED' || job.status === 'WORKING' ? (
|
||||
// <WorkflowRunLogs runId={job.id} inProgress entity={entity} />
|
||||
// ) : (
|
||||
// <WorkflowRunLogs runId={job.id} inProgress={false} entity={entity} />
|
||||
// )}
|
||||
// </Accordion>
|
||||
// );
|
||||
// };
|
||||
|
||||
export const WorkflowRunDetails = ({ entity }: { entity: Entity }) => {
|
||||
// const projectName = useProjectName(entity);
|
||||
const { value: projectName, loading, error } = useProjectName(entity);
|
||||
const [projectId] = (projectName ?? '/').split('/');
|
||||
|
||||
// const [projectId] = projectName.value ? projectName.value : [];
|
||||
const details = useWorkflowRunsDetails(projectId);
|
||||
// const steps = useWorkflowRunJobs(projectId)
|
||||
|
||||
const classes = useStyles();
|
||||
if (error) {
|
||||
@@ -216,16 +130,6 @@ export const WorkflowRunDetails = ({ entity }: { entity: Entity }) => {
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/* <TableRow>
|
||||
<TableCell colSpan={2}>
|
||||
<Typography noWrap>Jobs</Typography>
|
||||
{loading ? (
|
||||
<CircularProgress />
|
||||
) : (
|
||||
<JobsList jobs={steps.value} entity={entity} />
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow> */}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
|
||||
@@ -14,14 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { useAsync } from 'react-use';
|
||||
import { Jobs } from '../../api/types';
|
||||
import { ActionsListWorkflowRunsForRepoResponseData } from '../../api/types';
|
||||
|
||||
export const useWorkflowRunJobs = (jobsUrl?: string) => {
|
||||
const jobs = useAsync(async (): Promise<Jobs> => {
|
||||
const jobs = useAsync(async (): Promise<
|
||||
ActionsListWorkflowRunsForRepoResponseData
|
||||
> => {
|
||||
if (jobsUrl === undefined) {
|
||||
return {
|
||||
total_count: 0,
|
||||
jobs: [],
|
||||
builds: [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ export function useWorkflowRuns({ projectId }: { projectId: string }) {
|
||||
): WorkflowRun[] => {
|
||||
setTotal(workflowRunsData.total_count);
|
||||
// Transformation here
|
||||
return workflowRunsData.builds.builds.map(run => ({
|
||||
return workflowRunsData.builds.map(run => ({
|
||||
message: run.substitutions.REPO_NAME,
|
||||
id: `${run.id}`,
|
||||
onReRunClick: async () => {
|
||||
|
||||
Reference in New Issue
Block a user