-
Notifications
You must be signed in to change notification settings - Fork 7
/
LeftSideBar.jsx
101 lines (92 loc) · 3.71 KB
/
LeftSideBar.jsx
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
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import VarList from '../components/VarList.jsx'
import GMList from '../components/GMList.jsx'
import TemplateList from '../components/TemplateList.jsx'
import Actions from '../constants/Actions.js'
import {connect} from 'react-redux'
class LeftSideBar extends Component {
render() {
return (
<div id='left-side-bar'>
<VarList variables={this.props.variables}
loadVariables={this.props.loadVariables}
cachedFiles={this.props.cached_files}
removeVariable={this.props.removeVariable}
selectVariable={this.props.selectVariable}
selected_variable={this.props.selected_variable}
startTour={this.props.startTour}
/>
<GMList
updateGraphicsMethod={this.props.updateGraphicsMethod}
colormaps={this.props.colormaps}
defaultMethods={this.props.default_methods}
selected_graphics_type={this.props.selected_graphics_type}
selected_graphics_method={this.props.selected_graphics_method}
selectGraphicsMethod={this.props.selectGraphicsMethod}
/>
<TemplateList
templates={this.props.templates}
selected_template={this.props.selected_template}
selectTemplate={this.props.selectTemplate}
updateTemplate={this.props.updateTemplate}
removeTemplate={this.props.removeTemplate}
/>
</div>
)
}
}
LeftSideBar.propTypes ={
cached_files: PropTypes.object,
getColormaps: PropTypes.func,
loadVariables: PropTypes.func,
templates: PropTypes.arrayOf(PropTypes.string),
variables: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object
]),
colormaps: PropTypes.object,
sheets_model: PropTypes.object,
selectTemplate: PropTypes.func,
selected_template: PropTypes.string,
updateTemplate: PropTypes.func,
removeTemplate: PropTypes.func,
removeVariable: PropTypes.func,
selectVariable: PropTypes.func,
selected_variable: PropTypes.string,
updateGraphicsMethod: PropTypes.func,
default_methods: PropTypes.any,
selected_graphics_type: PropTypes.any,
selected_graphics_method: PropTypes.func,
selectGraphicsMethod: PropTypes.func,
startTour: PropTypes.func,
}
const mapStateToProps = (state) => {
return {
variables: state.present.variables,
templates: state.present.templates,
selected_template: state.present.ui.selected_template,
cached_files: state.present.cached_files,
sheets_model: state.present.sheets_model,
colormaps: state.present.colormaps,
default_methods: state.present.default_methods,
selected_variable: state.present.selected_variable,
}
}
const mapDispatchToProps = (dispatch) => {
return {
loadVariables: (var_list) => dispatch(Actions.loadVariables(var_list)),
removeVariable: (var_name) => {
if(var_name){
dispatch(Actions.removeVariable(var_name))
}
else{
// error handling here. No variable selected when delete was pressed
}
},
selectTemplate: (name) => dispatch(Actions.selectTemplate(name)),
updateTemplate: (template) => dispatch(Actions.updateTemplate(template)),
removeTemplate: (name) => dispatch(Actions.removeTemplate(name)),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(LeftSideBar);