forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
63 lines (56 loc) · 1.67 KB
/
index.tsx
File metadata and controls
63 lines (56 loc) · 1.67 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
import { createElement, SFC } from 'react'
import { useOvermind } from '../../overmind'
import * as styles from './styles'
import * as text from '../../styles/text'
import Input from '../common/Input'
import Button from '../common/Button'
import Workspace from '../Workspace'
import { css } from 'emotion'
const Devtools: SFC = () => {
const { state, actions } = useOvermind()
function onPortSubmit(event: React.ChangeEvent<HTMLFormElement>) {
event.preventDefault()
actions.addConnection()
}
function renderSetPort() {
return (
<div className={styles.wrapper}>
<div className={styles.container}>
<span className={css(text.header, text.white)}>
Welcome to Devtools
</span>
<span className={css(text.normal, text.white)}>
The default port {state.port} is already taken. Please use an
available port and configure your app to use this custom port.
</span>
<form onSubmit={onPortSubmit}>
<Input
autoFocus
value={state.newPortValue}
onChange={actions.changeNewPortValue}
length={6}
placeholder="port..."
addon={
<Button type="submit" disabled={!state.newPortValue}>
Connect
</Button>
}
/>
</form>
</div>
</div>
)
}
if (state.error === 'PORT_EXISTS') {
return renderSetPort()
}
if (state.isConnecting) {
return (
<div className={styles.wrapper}>
<h1>Waiting for an app to connect...</h1>
</div>
)
}
return <Workspace />
}
export default Devtools