From b4d4af50d8cc0d7e1d2e6eb04e0a165b71f0e678 Mon Sep 17 00:00:00 2001 From: NetPenguins Date: Sat, 12 Sep 2020 10:26:19 -0400 Subject: [PATCH] prettier misconfigured --- .../src/api/GithubActionsClient.ts | 6 +- .../WorkflowRunDetails/WorkflowRunDetails.tsx | 31 ++- .../WorkflowRunLogs/WorkflowRunLogs.tsx | 200 ++++++++++-------- .../useDownloadWorkflowRunLogs.ts | 36 ++-- 4 files changed, 150 insertions(+), 123 deletions(-) diff --git a/plugins/github-actions/src/api/GithubActionsClient.ts b/plugins/github-actions/src/api/GithubActionsClient.ts index 6b22150ec0..94fb774537 100644 --- a/plugins/github-actions/src/api/GithubActionsClient.ts +++ b/plugins/github-actions/src/api/GithubActionsClient.ts @@ -114,11 +114,13 @@ export class GithubActionsClient implements GithubActionsApi { repo: string; runId: number; }): Promise { - const workflow = await new Octokit({ auth: token }).actions.downloadJobLogsForWorkflowRun({ + const workflow = await new Octokit({ + auth: token, + }).actions.downloadJobLogsForWorkflowRun({ owner, repo, job_id: runId, }); return workflow.data; } -}; +} diff --git a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx index fb4f7d7f77..fd2cc69376 100644 --- a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx +++ b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx @@ -112,7 +112,15 @@ const StepView = ({ step }: { step: Step }) => { ); }; -const JobListItem = ({ job, className, entity }: { job: Job; className: string; entity: Entity }) => { +const JobListItem = ({ + job, + className, + entity, +}: { + job: Job; + className: string; + entity: Entity; +}) => { const classes = useStyles(); return ( @@ -137,20 +145,11 @@ const JobListItem = ({ job, className, entity }: { job: Job; className: string; - {job.status === "queued" || job.status === "in_progress" ? - - : - - } - + {job.status === 'queued' || job.status === 'in_progress' ? ( + + ) : ( + + )} ); }; @@ -233,7 +232,7 @@ export const WorkflowRunDetails = ({ entity }: { entity: Entity }) => { {jobs.loading ? ( ) : ( - + )} diff --git a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx index 804914fd3b..390f35d516 100644 --- a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx +++ b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx @@ -14,18 +14,18 @@ * limitations under the License. */ -import { - Accordion, - AccordionSummary, - CircularProgress, - Fade, - LinearProgress, - makeStyles, - Modal, - Theme, - Tooltip, - Typography, - Zoom +import { + Accordion, + AccordionSummary, + CircularProgress, + Fade, + LinearProgress, + makeStyles, + Modal, + Theme, + Tooltip, + Typography, + Zoom, } from '@material-ui/core'; import React, { Suspense } from 'react'; @@ -39,57 +39,74 @@ import { Entity } from '@backstage/catalog-model'; const LazyLog = React.lazy(() => import('react-lazylog/build/LazyLog')); const useStyles = makeStyles(() => ({ - button: { - order: -1, - 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%' - } - })); + button: { + order: -1, + 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, className }: { jobLogs: any; className: string }) =>{ - return( - }> -
- { - if(line.toLocaleLowerCase().includes("error") - || line.toLocaleLowerCase().includes("failed") - || line.toLocaleLowerCase().includes("failure")) - { - return - } - return line; - }} - /> -
-
- ) -} +const DisplayLog = ({ + jobLogs, + className, +}: { + jobLogs: any; + className: string; +}) => { + return ( + }> +
+ { + if ( + line.toLocaleLowerCase().includes('error') || + line.toLocaleLowerCase().includes('failed') || + line.toLocaleLowerCase().includes('failure') + ) { + return ( + + ); + } + return line; + }} + /> +
+
+ ); +}; /** - * A component for Run Logs visualization. + * A component for Run Logs visualization. */ -export const WorkflowRunLogs = ({ entity, runId, inProgress }:{ entity: Entity, runId: string, inProgress: boolean }) => { +export const WorkflowRunLogs = ({ + entity, + runId, + inProgress, +}: { + entity: Entity; + runId: string; + inProgress: boolean; +}) => { const classes = useStyles(); const projectName = useProjectName(entity); @@ -106,42 +123,47 @@ export const WorkflowRunLogs = ({ entity, runId, inProgress }:{ entity: Entity, }; return ( - - + } aria-controls={`panel-${name}-content`} id={`panel-${name}-header`} IconButtonProps={{ - className: classes.button, + className: classes.button, }} + > + + {jobLogs.loading ? : 'Job Log'} + + + { + event.stopPropagation(); + handleOpen(); + }} + style={{ marginLeft: 'auto' }} + /> + + event.stopPropagation()} + open={open} + onClose={handleClose} > - - {jobLogs.loading ? : "Job Log"} - - - { - event.stopPropagation() - handleOpen() - }} - style={{marginLeft: 'auto'}} - /> - - event.stopPropagation()} - open={open} - onClose={handleClose} - > - - - - - - {jobLogs.value && } + + + + + + {jobLogs.value && ( + + )} ); }; diff --git a/plugins/github-actions/src/components/WorkflowRunLogs/useDownloadWorkflowRunLogs.ts b/plugins/github-actions/src/components/WorkflowRunLogs/useDownloadWorkflowRunLogs.ts index 5cf8d57227..734f617b1f 100644 --- a/plugins/github-actions/src/components/WorkflowRunLogs/useDownloadWorkflowRunLogs.ts +++ b/plugins/github-actions/src/components/WorkflowRunLogs/useDownloadWorkflowRunLogs.ts @@ -18,19 +18,23 @@ import { useApi, githubAuthApiRef } from '@backstage/core'; import { useAsync } from 'react-use'; import { githubActionsApiRef } from '../../api'; -export const useDownloadWorkflowRunLogs = (repo: string, owner: string, id: string) => { - const api = useApi(githubActionsApiRef); - const auth = useApi(githubAuthApiRef); - const details = useAsync(async () => { - const token = await auth.getAccessToken(['repo']); - return repo && owner - ? api.downloadJobLogsForWorkflowRun({ - token, - owner, - repo, - runId: parseInt(id, 10), - }) - : Promise.reject('No repo/owner provided'); - }, [repo, owner, id]); - return details; - }; +export const useDownloadWorkflowRunLogs = ( + repo: string, + owner: string, + id: string, +) => { + const api = useApi(githubActionsApiRef); + const auth = useApi(githubAuthApiRef); + const details = useAsync(async () => { + const token = await auth.getAccessToken(['repo']); + return repo && owner + ? api.downloadJobLogsForWorkflowRun({ + token, + owner, + repo, + runId: parseInt(id, 10), + }) + : Promise.reject('No repo/owner provided'); + }, [repo, owner, id]); + return details; +};