-
Notifications
You must be signed in to change notification settings - Fork 25
/
StoreExplorer.js
62 lines (54 loc) · 1.29 KB
/
StoreExplorer.js
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
import AltStore from './debug/AltStore'
import DebugActions from './debug/DebugActions'
import React from 'react'
import PropTypes from 'prop-types';
import connectToStores from './connectToStores'
class StoreExplorer extends React.Component {
static propTypes = {
alt: PropTypes.obj.isRequired,
stores: PropTypes.array.isRequired,
}
componentDidMount() {
DebugActions.setAlt(this.props.alt)
}
constructor() {
super()
this.selectStore = this.selectStore.bind(this)
}
selectStore(ev) {
const data = ev.target.dataset
const store = this.props.alt.stores[data.name]
if (store) DebugActions.selectData(store.getState())
}
render() {
return (
<div>
<h3>Stores</h3>
<ul>
{this.props.stores.map((store) => {
return (
<li
key={store.displayName}
onClick={this.selectStore}
data-name={store.displayName}
style={{ cursor: 'pointer' }}
>
{store.displayName}
</li>
)
})}
</ul>
</div>
)
}
}
export default connectToStores({
getPropsFromStores() {
return {
stores: AltStore.stores(),
}
},
getStores() {
return [AltStore]
},
}, StoreExplorer)