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
76 lines (71 loc) · 2.08 KB
/
index.tsx
File metadata and controls
76 lines (71 loc) · 2.08 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
72
73
74
75
76
import * as React from 'react'
import { connect, Connect } from '../../app'
import { Wrapper, Container, Cancel } from './elements'
import Input from '../common/Input'
import Button from '../common/Button'
import Text from '../common/Text'
import Workspace from '../Workspace'
import Icon from '../common/Icon'
class Devtools extends React.Component<Connect> {
componentDidMount() {
this.props.app.actions.loadDevtools()
}
onPortSubmit = (event: React.FormEvent) => {
event.preventDefault()
this.props.app.actions.addPort()
}
renderAddPort(hasOtherApps) {
const { app } = this.props
return (
<Wrapper>
<Container>
<Text variant="header" color="white">
{hasOtherApps ? 'Add new application' : 'Welcome to Devtools'}
</Text>
<Text variant="text" color="white">
{hasOtherApps ? null : 'You have not added any applications yet. '}Please
add a port number which will be connected to by one of your apps.
</Text>
<form onSubmit={this.onPortSubmit}>
<Input
autoFocus
value={app.state.newPortValue}
onChange={app.actions.changeNewPortValue}
length={4}
placeholder="port..."
addon={
<Button
type="submit"
disabled={!app.state.newPortValue}
primary
>
Add
</Button>
}
/>
</form>
{hasOtherApps ? (
<Cancel onClick={() => app.actions.cancelConfigurePort()}>
<Icon>close</Icon>
</Cancel>
) : null}
</Container>
</Wrapper>
)
}
render() {
const { app } = this.props
if (app.state.isLoading) {
return (
<Wrapper>
<h1>loading...</h1>
</Wrapper>
)
}
if (app.state.isAddingPort) {
return this.renderAddPort(Boolean(Object.keys(app.state.apps).length))
}
return <Workspace />
}
}
export default connect(Devtools)