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
71 lines (65 loc) · 1.81 KB
/
index.tsx
File metadata and controls
71 lines (65 loc) · 1.81 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
68
69
70
71
import * as React from 'react'
import { connect, Connect } from '../../app'
import { Wrapper, Container } from './elements'
import Input from '../common/Input'
import Button from '../common/Button'
import Text from '../common/Text'
import Workspace from '../Workspace'
class Devtools extends React.Component<Connect> {
componentDidMount() {
this.props.app.actions.loadDevtools()
}
onPortSubmit = (event: React.FormEvent) => {
event.preventDefault()
this.props.app.actions.addConnection()
}
renderSetPort() {
const { app } = this.props
return (
<Wrapper>
<Container>
<Text variant="header" color="white">
Welcome to Devtools
</Text>
<Text variant="text" color="white">
The default port {app.state.port} is already taken. Please use an
available port and configure your app to use this custom port.
</Text>
<form onSubmit={this.onPortSubmit}>
<Input
autoFocus
value={app.state.newPortValue}
onChange={app.actions.changeNewPortValue}
length={6}
placeholder="port..."
addon={
<Button
type="submit"
disabled={!app.state.newPortValue}
primary
>
Connect
</Button>
}
/>
</form>
</Container>
</Wrapper>
)
}
render() {
const { app } = this.props
if (app.state.error === 'PORT_EXISTS') {
return this.renderSetPort()
}
if (app.state.isConnecting) {
return (
<Wrapper>
<h1>Waiting for an app to connect...</h1>
</Wrapper>
)
}
return <Workspace />
}
}
export default connect(Devtools)