This repository was archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathActivityLogs.tsx
More file actions
61 lines (55 loc) · 2.17 KB
/
ActivityLogs.tsx
File metadata and controls
61 lines (55 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { Timeline, Typography } from 'antd'
import { SyncOutlined } from '@ant-design/icons'
import moment from "moment"
import { Deployment, DeploymentStatusEnum } from "../../models"
import DeploymentStatusBadge from "../../components/DeploymentStatusBadge"
import UserAvatar from '../../components/UserAvatar'
import DeploymentRefCode from '../../components/DeploymentRefCode'
const { Text } = Typography
export interface ActivityLogsProps {
deployments: Deployment[]
}
export default function ActivityLogs({ deployments }: ActivityLogsProps): JSX.Element {
return (
<Timeline>
{deployments.map((d, idx) => {
const dot = (d.status === DeploymentStatusEnum.Running)?
<SyncOutlined style={{color: "purple"}} spin />
:
null
const avatar = <UserAvatar user={d.deployer} />
return (
<Timeline.Item key={idx} color={getStatusColor(d.status)} dot={dot}>
<p>
<Text strong>{d.env}</Text> <DeploymentRefCode deployment={d}/> <a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}>• View detail #{d.number}</a>
</p>
<p>
Deployed by {avatar} {moment(d.createdAt).fromNow()} <DeploymentStatusBadge deployment={d}/>
</p>
</Timeline.Item>
)
})}
</Timeline>
)
}
// https://ant.design/components/timeline/#Timeline.Item
const getStatusColor = (status: DeploymentStatusEnum) => {
switch (status) {
case DeploymentStatusEnum.Waiting:
return "gray"
case DeploymentStatusEnum.Created:
return "purple"
case DeploymentStatusEnum.Queued:
return "purple"
case DeploymentStatusEnum.Running:
return "purple"
case DeploymentStatusEnum.Success:
return "green"
case DeploymentStatusEnum.Failure:
return "red"
case DeploymentStatusEnum.Canceled:
return "gray"
default:
return "gray"
}
}