forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.tsx
More file actions
49 lines (46 loc) · 1.43 KB
/
Copy pathheader.tsx
File metadata and controls
49 lines (46 loc) · 1.43 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
import * as React from 'react';
import { useContext } from 'react';
import { PullRequest } from './cache';
import { getStatus } from './pullRequestOverviewRenderer';
import { Avatar, AuthorLink } from './user';
import { Spaced } from './space';
import PullRequestContext from './context';
import { checkIcon } from './icon';
import Timestamp from './timestamp';
export const Header = ({ state, title, head, base, url, createdAt, author, isCurrentlyCheckedOut }: PullRequest) =>
<>
<div className='overview-title'>
<h2>{title}</h2>
<div className='button-group'>
<CheckoutButtons />
<button>Refresh</button>
</div>
</div>
<div className='subtitle'>
<div id='status'>{getStatus(state)}</div>
<Avatar for={author} />
<span className='author'>
<Spaced>
<AuthorLink for={author} /> wants to merge changes
from <code>{head}</code>
to <code>{base}</code>
</Spaced>.
</span>
<span className='created-at'>
<Spaced>
Created <Timestamp date={createdAt} href={url} />
</Spaced>
</span>
</div>
</>;
const CheckoutButtons = () => {
const { pr, exitReviewMode, checkout } = useContext(PullRequestContext);
if (pr.isCurrentlyCheckedOut) {
return <>
<button aria-live='polite' className='checkedOut' disabled>{checkIcon} Checked Out</button>
<button aria-live='polite' onClick={exitReviewMode}>Exit Review Mode</button>
</>;
} else {
return <button aria-live='polite' onClick={checkout}>Checkout</button>;
}
};