From 98699478237b8ebb86dcbf4543c91fb2651800b6 Mon Sep 17 00:00:00 2001 From: NetPenguins Date: Tue, 1 Sep 2020 13:51:37 -0400 Subject: [PATCH] Return correct type, added modal for log visuals, added loading indications. --- .../src/api/GithubActionsApi.ts | 3 +- .../src/api/GithubActionsClient.ts | 3 +- .../WorkflowRunDetails/WorkflowRunDetails.tsx | 9 ++ .../WorkflowRunLogs/WorkflowRunLogs.tsx | 86 +++++++++++++++---- 4 files changed, 81 insertions(+), 20 deletions(-) diff --git a/plugins/github-actions/src/api/GithubActionsApi.ts b/plugins/github-actions/src/api/GithubActionsApi.ts index 4acb68296d..bf79e74351 100644 --- a/plugins/github-actions/src/api/GithubActionsApi.ts +++ b/plugins/github-actions/src/api/GithubActionsApi.ts @@ -19,6 +19,7 @@ import { ActionsListWorkflowRunsForRepoResponseData, ActionsGetWorkflowResponseData, ActionsGetWorkflowRunResponseData, + EndpointInterface, } from '@octokit/types'; export const githubActionsApiRef = createApiRef({ @@ -85,5 +86,5 @@ export type GithubActionsApi = { owner: string; repo: string; runId: number; - }) => Promise; + }) => Promise; }; diff --git a/plugins/github-actions/src/api/GithubActionsClient.ts b/plugins/github-actions/src/api/GithubActionsClient.ts index a3a68811db..6b22150ec0 100644 --- a/plugins/github-actions/src/api/GithubActionsClient.ts +++ b/plugins/github-actions/src/api/GithubActionsClient.ts @@ -20,6 +20,7 @@ import { ActionsListWorkflowRunsForRepoResponseData, ActionsGetWorkflowResponseData, ActionsGetWorkflowRunResponseData, + EndpointInterface, } from '@octokit/types'; export class GithubActionsClient implements GithubActionsApi { @@ -112,7 +113,7 @@ export class GithubActionsClient implements GithubActionsApi { owner: string; repo: string; runId: number; - }): Promise { + }): Promise { const workflow = await new Octokit({ auth: token }).actions.downloadJobLogsForWorkflowRun({ owner, repo, diff --git a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx index 15fea5d197..a635eb9acb 100644 --- a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx +++ b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx @@ -138,9 +138,18 @@ const JobListItem = ({ job, className }: { job: Job; className: string }) => { + {job.status === "queued" || job.status === "in_progress" ? + + : + } + ); }; diff --git a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx index eeb1ee7e3f..d2757c406f 100644 --- a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx +++ b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx @@ -15,37 +15,59 @@ */ import { + Accordion, + AccordionSummary, + CircularProgress, + Fade, LinearProgress, - ExpansionPanel, - Typography, makeStyles, + Modal, Theme, - ExpansionPanelSummary, + Tooltip, + Typography, + Zoom } from '@material-ui/core'; -import React, {Suspense} from 'react'; +import React, { Suspense } from 'react'; import { useEntityCompoundName } from '@backstage/plugin-catalog'; import { useDownloadWorkflowRunLogs } from './useDownloadWorkflowRunLogs'; import LinePart from 'react-lazylog/build/LinePart'; import { useProjectName } from '../useProjectName'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import DescriptionIcon from '@material-ui/icons/Description'; const LazyLog = React.lazy(() => import('react-lazylog/build/LazyLog')); const useStyles = makeStyles(() => ({ button: { order: -1, - marginRight: 0, + // marginRight: 0, marginLeft: '-20px', }, + modal: { + display: 'flex', + alignItems: 'center', + width: '85%', + height: '85%', + justifyContent: 'center', + margin: 'auto' + }, + normalLog:{ + height: '75vh', + width: '100%' + }, + modalLog:{ + height: '100%', + width: '100%' + } })); -const DisplayLog = (jobLogs: any) =>{ - return( +const DisplayLog = ({ jobLogs, className }: { jobLogs: any; className: string }) =>{ + return( }> -
+
{ } /** - * A component for Run Logs visualization. + * A component for Run Logs visualization. */ -export const WorkflowRunLogs = ({runId}:{runId: string}) => { +export const WorkflowRunLogs = ({ runId, inProgress }:{ runId: string, inProgress: boolean }) => { const classes = useStyles(); let entityCompoundName = useEntityCompoundName(); if (!entityCompoundName.name) { @@ -83,12 +105,21 @@ export const WorkflowRunLogs = ({runId}:{runId: string}) => { const [owner, repo] = projectName.value ? projectName.value.split('/') : []; const jobLogs = useDownloadWorkflowRunLogs(repo, owner, runId); - + const [open, setOpen] = React.useState(false); + + const handleOpen = () => { + setOpen(true); + }; + + const handleClose = () => { + setOpen(false); + }; return ( - - } aria-controls={`panel-${name}-content`} id={`panel-${name}-header`} @@ -97,10 +128,29 @@ export const WorkflowRunLogs = ({runId}:{runId: string}) => { }} > - {jobLogs.value === null ? "No Logs to Display" : "Job Log"} + {jobLogs.loading ? : "Job Log"} - - {jobLogs.value && } - + + { + event.stopPropagation() + handleOpen() + }} + style={{marginLeft: 'auto'}} + /> + + event.stopPropagation()} + open={open} + onClose={handleClose} + > + + + + + + {jobLogs.value && } + ); };