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

Commit b5da8f0

Browse files
author
noah
committed
Add the commit changes
1 parent dddab73 commit b5da8f0

File tree

3 files changed

+91
-5
lines changed

3 files changed

+91
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { useState } from "react"
2+
import { Button, Typography, List, Avatar } from "antd"
3+
import moment from "moment"
4+
5+
import { Commit } from "../../models"
6+
7+
interface CommitChangesProps {
8+
changes:Commit[]
9+
}
10+
11+
export default function CommitChanges(props: CommitChangesProps): JSX.Element {
12+
return (
13+
<List
14+
style={{
15+
maxHeight: 400,
16+
overflow: "auto",
17+
}}
18+
bordered
19+
dataSource={props.changes}
20+
renderItem={(commit, idx) => {
21+
return (
22+
<CommitChange key={idx} commit={commit}/>
23+
)
24+
}}
25+
/>
26+
)
27+
}
28+
29+
function CommitChange(props: {commit: Commit}): JSX.Element {
30+
const [message, ...description] = props.commit.message.split(/(\r\n|\n|\r)/g)
31+
32+
const [hide, setHide] = useState(true)
33+
34+
const onClickHide = () => {
35+
setHide(!hide)
36+
}
37+
38+
return (
39+
<List.Item>
40+
<List.Item.Meta
41+
title={
42+
<>
43+
<a href={props.commit.htmlUrl} target="_blank">{message}</a>
44+
{/* Display the description when the button is clicked. */}
45+
{(description.length)?
46+
<Button size="small" type="text" onClick={onClickHide}>
47+
<Typography.Text className="gitploy-code" code>...</Typography.Text>
48+
</Button>
49+
:
50+
<></>}
51+
{(!hide) ?
52+
<Typography.Paragraph style={{margin: 0}}>
53+
<pre style={{marginBottom: 0, fontSize: 12}}>
54+
{description.join("").trim()}
55+
</pre>
56+
</Typography.Paragraph>
57+
:
58+
<></>}
59+
</>
60+
}
61+
description={(props.commit?.author)?
62+
<>
63+
<Avatar size="small" src={props.commit.author.avatarUrl} />&nbsp;
64+
<Typography.Text strong>{props.commit.author.login}</Typography.Text> committed&nbsp;
65+
{moment(props.commit.author?.date).fromNow()}
66+
</>
67+
:
68+
<></>
69+
}
70+
/>
71+
<div style={{marginLeft: 30}}>
72+
<Button
73+
href={props.commit.htmlUrl}
74+
target="_blank"
75+
>
76+
{props.commit.sha.substring(0, 7)}
77+
</Button>
78+
</div>
79+
</List.Item>
80+
)
81+
}

ui/src/components/DeploymentDescriptor/DeploymentDescriptor.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ import moment from "moment"
33

44
import DeploymentStatusBadge from "../DeploymentStatusBadge"
55
import UserAvatar from "../UserAvatar"
6+
import CommitChanges from "./CommitChanges"
67

7-
import { Deployment } from "../../models"
8+
import { Commit, Deployment } from "../../models"
89
import { getShortRef } from "../../libs"
910
import { useState } from "react"
1011

1112
const { Text } = Typography
1213

1314
interface DeploymentDescriptorProps {
1415
deployment: Deployment
16+
commits: Commit[]
1517
}
1618

1719
export default function DeploymentDescriptor(props: DeploymentDescriptorProps): JSX.Element {
@@ -51,10 +53,13 @@ export default function DeploymentDescriptor(props: DeploymentDescriptorProps):
5153
<Modal
5254
title="Changes"
5355
visible={visible}
54-
width={1000}
56+
width={800}
57+
// Hide OK Button
58+
okButtonProps={{style: {display: "none"}}}
59+
cancelText="Close"
5560
onCancel={hideModal}
5661
>
57-
TODO: Show commits
62+
<CommitChanges changes={props.commits}/>
5863
</Modal>
5964
</Descriptions.Item>
6065
</Descriptions>

ui/src/views/Deployment.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ export default function DeploymentView(): JSX.Element {
154154
</div>
155155
<Row>
156156
<Col span={23} offset={1} lg={{span: 13, offset: 1}}>
157-
<DeploymentDescriptor deployment={deployment}/>
157+
<DeploymentDescriptor commits={changes} deployment={deployment}/>
158158
</Col>
159159
<Col span={23} offset={1} lg={{span: 6, offset: 2}}>
160160
<ReviewerList reviews={reviews}/>
161161
</Col>
162162
</Row>
163163
<Row style={{marginTop: 40}}>
164-
<Col offset={2} span={22}>
164+
<Col offset={1} span={22} md={{offset: 2}}>
165165
{deployment.statuses?
166166
<DeploymentStatusSteps statuses={deployment.statuses}/>
167167
:

0 commit comments

Comments
 (0)