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

Commit d0bbec1

Browse files
author
Noah Hanjun Lee
authored
Fix the status foldable in UI (#172)
1 parent c50de57 commit d0bbec1

File tree

2 files changed

+50
-36
lines changed

2 files changed

+50
-36
lines changed

ui/src/components/DeployConfirm.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useState } from "react"
44

55
import { Deployment, Commit } from "../models"
66
import DeploymentRefCode from "./DeploymentRefCode"
7+
import DeploymentStatusBadge from "./DeploymentStatusBadge"
78
import DeploymentStatusSteps from "./DeploymentStatusSteps"
89

910
const { Paragraph, Text } = Typography
@@ -48,7 +49,18 @@ export default function DeployConfirm(props: DeployConfirmProps): JSX.Element {
4849
{...layout}
4950
label="Status"
5051
>
51-
<DeploymentStatusSteps deployment={props.deployment}/>
52+
{(props.deployment.statuses)?
53+
<Collapse ghost>
54+
<Panel
55+
key={1}
56+
header={<DeploymentStatusBadge deployment={props.deployment} />}
57+
style={{position: "relative", top: "-5px", left: "-15px"}}
58+
>
59+
<DeploymentStatusSteps statuses={props.deployment.statuses}/>
60+
</Panel>
61+
</Collapse> :
62+
<DeploymentStatusBadge deployment={props.deployment} />
63+
}
5264
</Form.Item>
5365
<Form.Item
5466
{...layout}
@@ -83,7 +95,7 @@ export default function DeployConfirm(props: DeployConfirmProps): JSX.Element {
8395
<Collapse ghost >
8496
<Panel
8597
key={1}
86-
header="Click"
98+
header="Show"
8799
// Fix the position to align with the field.
88100
style={{position: "relative", top: "-5px", left: "-15px"}}
89101
>
@@ -123,7 +135,7 @@ function CommitChanges(props: CommitChangesProps): JSX.Element {
123135

124136
return (
125137
<Timeline>
126-
{props.changes.slice(0, 10).map((change, idx) => {
138+
{props.changes.map((change, idx) => {
127139
return <Timeline.Item key={idx} color="gray">
128140
<CommitChange commit={change} />
129141
</Timeline.Item>
Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1-
import { Steps, Popover } from "antd"
1+
import { Timeline, Typography } from "antd"
22
import 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

98
interface DeploymentStatusStepsProps {
10-
deployment: Deployment
9+
statuses: DeploymentStatus[]
1110
}
1211

1312
export 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

Comments
 (0)