|
| 1 | +import React from 'react'; |
| 2 | +import { |
| 3 | + Card, |
| 4 | + CardContent, |
| 5 | + Typography, |
| 6 | + Divider, |
| 7 | + List, |
| 8 | + ListItem, |
| 9 | + Box, |
| 10 | + Chip, |
| 11 | + CardCover, |
| 12 | +} from '@mui/joy'; |
| 13 | +import { SquareCheckIcon } from 'lucide-react'; |
| 14 | + |
| 15 | +export default function WorkflowRunDisplay({ selectedWorkflowRun }) { |
| 16 | + if (!selectedWorkflowRun) { |
| 17 | + return <Typography>No workflow run selected</Typography>; |
| 18 | + } |
| 19 | + |
| 20 | + const { run, jobs, workflow } = selectedWorkflowRun; |
| 21 | + |
| 22 | + const formatDuration = (start, end) => { |
| 23 | + if (!start || !end) { |
| 24 | + return null; |
| 25 | + } |
| 26 | + |
| 27 | + const startTime = new Date(start); |
| 28 | + const endTime = new Date(end); |
| 29 | + const duration = (endTime - startTime) / 1000; // duration in seconds |
| 30 | + const minutes = Math.floor(duration / 60); |
| 31 | + const seconds = duration % 60; |
| 32 | + return `${minutes}m ${seconds}s`; |
| 33 | + }; |
| 34 | + |
| 35 | + return ( |
| 36 | + <Card variant="outlined" sx={{ padding: 2 }}> |
| 37 | + <CardContent> |
| 38 | + <Typography level="h4" sx={{ marginBottom: 1 }}> |
| 39 | + Workflow: {workflow.name} |
| 40 | + </Typography> |
| 41 | + <Typography level="body-md" sx={{ marginBottom: 2 }}> |
| 42 | + Status: <Chip>{run.status}</Chip> |
| 43 | + </Typography> |
| 44 | + <Typography level="body-md" sx={{ marginBottom: 2 }}> |
| 45 | + Created At: {run.created_at} | Updated At: {run.updated_at} |
| 46 | + </Typography> |
| 47 | + <Divider /> |
| 48 | + <Typography level="h4" sx={{ marginTop: 2, marginBottom: 1 }}> |
| 49 | + Tasks: |
| 50 | + </Typography> |
| 51 | + <List> |
| 52 | + {jobs.map((job) => ( |
| 53 | + <ListItem key={job.jobID}> |
| 54 | + <Box> |
| 55 | + <Typography |
| 56 | + level="title-md" |
| 57 | + startDecorator={<SquareCheckIcon />} |
| 58 | + >{`Task: ${job.taskName}`}</Typography> |
| 59 | + <Typography level="body-md" sx={{ color: 'text.secondary' }}> |
| 60 | + Status: <Chip>{job.status}</Chip> |
| 61 | + </Typography> |
| 62 | + <Typography level="body-md" sx={{ color: 'text.secondary' }}> |
| 63 | + {`Start: ${job?.jobStartTime} | End: ${job?.jobEndTime}`} |
| 64 | + </Typography> |
| 65 | + <Typography level="body-md" sx={{ color: 'text.secondary' }}> |
| 66 | + Duration: {formatDuration(job.jobStartTime, job.jobEndTime)} |
| 67 | + </Typography> |
| 68 | + <Divider sx={{ marginTop: 1 }} /> |
| 69 | + </Box> |
| 70 | + </ListItem> |
| 71 | + ))} |
| 72 | + </List> |
| 73 | + </CardContent> |
| 74 | + </Card> |
| 75 | + ); |
| 76 | +} |
0 commit comments