1- import { Steps , Popover } from "antd"
1+ import { Timeline , Typography } from "antd"
22import moment from "moment"
33
4- import { Deployment } from "../models"
5- import DeploymentStatusBadge from "./DeploymentStatusBadge"
4+ import { DeploymentStatus } from "../models"
65
7- const { Step } = Steps
6+ const { Paragraph , Text , Link } = Typography
87
98interface DeploymentStatusStepsProps {
10- deployment : Deployment
9+ statuses : DeploymentStatus [ ]
1110}
1211
1312export default function DeploymentStatusSteps ( props : DeploymentStatusStepsProps ) : JSX . Element {
14- if ( typeof props . deployment . statuses === "undefined"
15- || props . deployment . statuses . length === 0 ) {
16- return (
17- < DeploymentStatusBadge deployment = { props . deployment } />
18- )
19- }
20-
2113 return (
22- < Steps
23- current = { props . deployment . statuses . length - 1 }
24- size = "small"
25- responsive
14+ < Timeline
15+ style = { {
16+ position : "relative" ,
17+ top : 15 ,
18+ paddingBottom : 0
19+ } }
2620 >
27- { props . deployment . statuses . map ( ( status , idx ) => {
28- const title = ( status . logUrl ) ?
29- < a href = { status . logUrl } > { status . status } </ a > :
30- < span > { status . status } </ span >
31-
32- const description = ( status . description ) ?
33- `${ status . description . replace ( / \. $ / , ' ' ) } at ${ moment ( status . createdAt ) . format ( 'HH:mm:ss' ) } ` :
34- moment ( status . createdAt ) . format ( 'HH:mm:ss' )
35-
36- return ( < Step
37- key = { idx }
38- style = { { width : "100px" } }
39- status = "finish"
40- icon = { < span > •</ span > }
41- title = { < Popover content = { description } > { title } </ Popover > }
42- /> )
21+ { props . statuses . map ( ( status , idx ) => {
22+ return (
23+ < Timeline . Item
24+ color = { getStatusColor ( status . status ) }
25+ style = { ( idx === props . statuses . length - 1 ) ? { paddingBottom : 0 } : { } }
26+ >
27+ < Paragraph style = { { margin : 0 } } >
28+ < Text strong > { status . description } </ Text >
29+ { ( status . logUrl !== "" ) ? < Link href = { status . logUrl } > View</ Link > : < > </ > } < br />
30+ < Text > Updated</ Text > < Text code className = "gitploy-code" > { status . status } </ Text > < Text > at { moment ( status . createdAt ) . format ( 'HH:mm:ss' ) } </ Text >
31+ </ Paragraph >
32+ </ Timeline . Item >
33+ )
4334 } ) }
44- </ Steps >
35+ </ Timeline >
4536 )
37+ }
38+
39+ const getStatusColor = ( status : string ) => {
40+ switch ( status ) {
41+ case "success" :
42+ return "green"
43+ case "failure" :
44+ return "red"
45+ default :
46+ return "#722ed1"
47+ }
4648}
0 commit comments