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
120 lines (111 loc) · 2.78 KB
/
index.tsx
File metadata and controls
120 lines (111 loc) · 2.78 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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()
}
/*
storeCurrentApps(apps) {
jsonStorage.set(
'apps',
Object.keys(apps).reduce((appsToStore, port) => {
appsToStore[port] = {
name: apps[port].name,
type: apps[port].type,
ssl: apps[port].ssl,
}
return appsToStore
}, {})
)
}
addNewPort() {
this.setState({
showAddApp: true,
})
}
cancelAddNewPort() {
this.setState({
showAddApp: false,
})
}
changePort(port) {
this.setState({
currentPort: port,
})
}
removePort(portToRemove) {
const newApps = Object.keys(this.state.apps)
.filter((port) => port !== portToRemove)
.reduce((apps, remainingPort) => {
apps[remainingPort] = this.state.apps[remainingPort]
return apps
}, {})
this.setState({
apps: newApps,
currentPort:
portToRemove === this.state.currentPort
? Object.keys(newApps)[0]
: this.state.currentPort,
})
connector.removePort(portToRemove)
this.storeCurrentApps(newApps)
}
*/
onPortSubmit = (event: React.FormEvent) => {
event.preventDefault()
this.props.app.actions.addPort()
}
renderAddPort() {
const { app } = this.props
return (
<Wrapper>
<Container>
<Text variant="header" color="white">
Welcome to Devtools
</Text>
<Text variant="text" color="white">
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
value={app.state.newPortValue}
onChange={app.actions.changeNewPortValue}
length={4}
placeholder="port..."
addon={
<Button
type="submit"
disabled={!app.state.newPortValue}
primary
>
Add
</Button>
}
/>
</form>
</Container>
</Wrapper>
)
}
render() {
const { app } = this.props
if (app.state.isLoading) {
return (
<Wrapper>
<h1>loading...</h1>
</Wrapper>
)
}
if (Object.keys(app.state.apps).length) {
return <Workspace />
}
return this.renderAddPort()
}
}
export default connect(Devtools)