forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.tsx
More file actions
67 lines (61 loc) · 2.03 KB
/
Copy pathcomment.tsx
File metadata and controls
67 lines (61 loc) · 2.03 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
62
63
64
65
66
67
import * as React from 'react';
import { useContext } from 'react';
import Markdown from './markdown';
import { Spaced } from './space';
import { Avatar, AuthorLink } from './user';
import Timestamp from './timestamp';
import { Comment } from '../src/common/comment';
import { PullRequest } from './cache';
import PullRequestContext from './context';
export const CommentView = ({ user, htmlUrl, createdAt, bodyHTML, body }: Partial<Comment>) =>
<div className='comment-container comment review-comment'>
<div className='review-comment-container'>
<div className='review-comment-header'>
<Spaced>
<Avatar for={user} />
<AuthorLink for={user} />
commented
<Timestamp href={htmlUrl} date={createdAt} />
</Spaced>
</div>
<CommentBody bodyHTML={bodyHTML} body={body} />
</div>
</div>;
export interface Embodied {
bodyHTML?: string;
body?: string;
}
export const CommentBody = ({ bodyHTML, body }: Embodied) =>
bodyHTML
? <div className='comment-body'
dangerouslySetInnerHTML={ {__html: bodyHTML }} />
:
<Markdown className='comment-body' src={body} />;
export function AddComment({ pendingCommentText }: PullRequest) {
const { updatePR, comment } = useContext(PullRequestContext);
return <form id='comment-form' className='comment-form' onSubmit={onSubmit}>
<textarea id='comment-textarea'
name='body'
onInput={({ target }) =>
updatePR({ pendingCommentText: (target as any).value })}
value={pendingCommentText}
placeholder='Leave a comment' />
<div className='form-actions'>
<button id='close' className='secondary'>Close Pull Request</button>
<button id='request-changes'
disabled={!!pendingCommentText}
className='secondary'>Request Changes</button>
<button id='approve'
className='secondary'>Approve</button>
<input id='reply'
value='Comment'
type='submit'
className='reply-button'
disabled={!!pendingCommentText} />
</div>
</form>;
function onSubmit(evt) {
evt.preventDefault();
comment((evt.target as any).body.value);
}
}