Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 6d4e825

Browse files
author
noah
committed
Add ActivityHistory
1 parent e476652 commit 6d4e825

File tree

6 files changed

+71
-26
lines changed

6 files changed

+71
-26
lines changed

ui/src/components/ActivityHistory.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Timeline, Typography } from 'antd'
2+
import moment from "moment"
3+
4+
import { Deployment } from "../models"
5+
import DeploymentStatusBadge from "./DeploymentStatusBadge"
6+
import UserAvatar from './UserAvatar'
7+
import DeploymentRefCode from './DeploymentRefCode'
8+
import { getStatusColor } from "./partials"
9+
10+
const { Text } = Typography
11+
12+
interface ActivityHistoryProps {
13+
deployments: Deployment[]
14+
}
15+
16+
export default function ActivityHistory(props: ActivityHistoryProps): JSX.Element {
17+
return (
18+
<Timeline>
19+
{props.deployments.map((d, idx) => {
20+
return (
21+
<Timeline.Item key={idx} color={getStatusColor(d.status)}>
22+
<p>
23+
<Text strong>
24+
{`${d.repo?.namespace} / ${d.repo?.name}`}
25+
</Text>&nbsp;
26+
<a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}>
27+
#{d.number}
28+
</a>
29+
</p>
30+
<p>
31+
<UserAvatar user={d.deployer} /> deployed <DeploymentRefCode deployment={d}/>&nbsp;
32+
to <Text strong>{d.env}</Text>&nbsp;
33+
on {moment(d.createdAt).format("LLL")} <DeploymentStatusBadge deployment={d}/>
34+
</p>
35+
</Timeline.Item>
36+
)
37+
})}
38+
</Timeline>
39+
)
40+
}

ui/src/components/ActivityLogs.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Deployment, DeploymentStatusEnum } from "../models"
66
import DeploymentStatusBadge from "./DeploymentStatusBadge"
77
import UserAvatar from './UserAvatar'
88
import DeploymentRefCode from './DeploymentRefCode'
9+
import { getStatusColor } from "./partials"
910

1011
const { Text } = Typography
1112

@@ -36,25 +37,3 @@ export default function ActivityLogs(props: ActivityLogsProps): JSX.Element {
3637
</Timeline>
3738
)
3839
}
39-
40-
// https://ant.design/components/timeline/#Timeline.Item
41-
const getStatusColor = (status: DeploymentStatusEnum) => {
42-
switch (status) {
43-
case DeploymentStatusEnum.Waiting:
44-
return "gray"
45-
case DeploymentStatusEnum.Created:
46-
return "purple"
47-
case DeploymentStatusEnum.Queued:
48-
return "purple"
49-
case DeploymentStatusEnum.Running:
50-
return "purple"
51-
case DeploymentStatusEnum.Success:
52-
return "green"
53-
case DeploymentStatusEnum.Failure:
54-
return "red"
55-
case DeploymentStatusEnum.Canceled:
56-
return "gray"
57-
default:
58-
return "gray"
59-
}
60-
}

ui/src/components/DeploymentRefCode.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ interface DeploymentRefCodeProps {
1111
export default function DeploymentRefCode(props: DeploymentRefCodeProps): JSX.Element {
1212
let ref: string
1313
if (props.deployment.type === DeploymentType.Commit) {
14-
ref = props.deployment.ref.substr(0, 7)
14+
ref = props.deployment.ref.substring(0, 7)
1515
} else if (props.deployment.type === DeploymentType.Branch && props.deployment.sha !== "") {
16-
ref = `${props.deployment.ref}(${props.deployment.sha.substr(0, 7)})`
16+
ref = `${props.deployment.ref}(${props.deployment.sha.substring(0, 7)})`
1717
} else {
1818
ref = props.deployment.ref
1919
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { DeploymentStatusEnum } from "../../models"
2+
3+
// https://ant.design/components/timeline/#Timeline.Item
4+
export const getStatusColor = (status: DeploymentStatusEnum): string => {
5+
switch (status) {
6+
case DeploymentStatusEnum.Waiting:
7+
return "gray"
8+
case DeploymentStatusEnum.Created:
9+
return "purple"
10+
case DeploymentStatusEnum.Queued:
11+
return "purple"
12+
case DeploymentStatusEnum.Running:
13+
return "purple"
14+
case DeploymentStatusEnum.Success:
15+
return "green"
16+
case DeploymentStatusEnum.Failure:
17+
return "red"
18+
case DeploymentStatusEnum.Canceled:
19+
return "gray"
20+
default:
21+
return "gray"
22+
}
23+
}

ui/src/components/partials/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { getStatusColor } from "./deploymentStatus"
2+
3+
export { getStatusColor }

ui/src/views/Activities.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { perPage, activitiesSlice, searchDeployments } from "../redux/activities
77

88
import Main from "./Main"
99
import SearchActivities from "../components/SearchActivities"
10-
import ActivityLogs from "../components/ActivityLogs"
10+
import ActivityHistory from "../components/ActivityHistory"
1111
import Pagination from "../components/Pagination"
1212
import Spin from '../components/Spin'
1313

@@ -59,7 +59,7 @@ export default function Activities(): JSX.Element {
5959
<Spin />
6060
</div>
6161
:
62-
<ActivityLogs deployments={deployments}/>}
62+
<ActivityHistory deployments={deployments}/>}
6363
</div>
6464
</div>
6565
<div style={{marginTop: 30, textAlign: "center"}}>

0 commit comments

Comments
 (0)