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

Commit 1659aae

Browse files
author
Noah Hanjun Lee
authored
Fix to handle any line break (#134)
1 parent 8a9bc50 commit 1659aae

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ui/src/components/DeployConfirm.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ interface CommitChangeProps {
137137
}
138138

139139
function CommitChange(props: CommitChangeProps): JSX.Element {
140-
const commit = props.commit
141-
const [message, description] = commit.message.split("\n\n", 2)
140+
const [message, ...description] = props.commit.message.split(/(\r\n|\n|\r)/g)
142141

143142
const [hide, setHide] = useState(true)
144143

@@ -148,8 +147,8 @@ function CommitChange(props: CommitChangeProps): JSX.Element {
148147

149148
return (
150149
<span >
151-
<a href={commit.htmlUrl} className="gitploy-link"><strong>{message.substring(0, 50)}</strong></a>
152-
{(description) ?
150+
<a href={props.commit.htmlUrl} className="gitploy-link"><strong>{message.substring(0, 50)}</strong></a>
151+
{(description.length) ?
153152
<Button size="small" type="text" onClick={onClickHide}>
154153
<Text className="gitploy-code" code>...</Text>
155154
</Button> :
@@ -158,16 +157,14 @@ function CommitChange(props: CommitChangeProps): JSX.Element {
158157
{(!hide) ?
159158
<Paragraph style={{margin: 0}}>
160159
<pre style={{marginBottom: 0, fontSize: 12}}>
161-
{description.split(/(\r\n)/g).map((line, idx) => {
162-
return (line !== "\r\n")? <Text key={idx}>{line}</Text> : <br/>
163-
})}
160+
{description.join("").trim()}
164161
</pre>
165162
</Paragraph> :
166163
null}
167164
<br />
168-
{(commit?.author) ?
165+
{(props.commit?.author) ?
169166
<span >
170-
<Text >&nbsp;<Avatar size="small" src={commit.author.avatarUrl} /> {commit.author.login}</Text> <Text >committed {moment(commit.author?.date).fromNow()}</Text>
167+
<Text >&nbsp;<Avatar size="small" src={props.commit.author.avatarUrl} /> {props.commit.author.login}</Text> <Text >committed {moment(props.commit.author?.date).fromNow()}</Text>
171168
</span> :
172169
null}
173170
</span>

0 commit comments

Comments
 (0)