|
@@ -23,17 +23,6 @@ class Toolbar extends Component {
|
23
|
23
|
* @static
|
24
|
24
|
*/
|
25
|
25
|
static propTypes = {
|
26
|
|
-
|
27
|
|
- /**
|
28
|
|
- * Handler for mouse out event.
|
29
|
|
- */
|
30
|
|
- _onMouseOut: React.PropTypes.func,
|
31
|
|
-
|
32
|
|
- /**
|
33
|
|
- * Handler for mouse over event.
|
34
|
|
- */
|
35
|
|
- _onMouseOver: React.PropTypes.func,
|
36
|
|
-
|
37
|
26
|
/**
|
38
|
27
|
* Children of current React component.
|
39
|
28
|
*/
|
|
@@ -44,6 +33,12 @@ class Toolbar extends Component {
|
44
|
33
|
*/
|
45
|
34
|
className: React.PropTypes.string,
|
46
|
35
|
|
|
36
|
+ /**
|
|
37
|
+ * Used to dispatch an action when a button is clicked or on mouse
|
|
38
|
+ * out/in event.
|
|
39
|
+ */
|
|
40
|
+ dispatch: React.PropTypes.func,
|
|
41
|
+
|
47
|
42
|
/**
|
48
|
43
|
* Map with toolbar buttons.
|
49
|
44
|
*/
|
|
@@ -80,11 +75,11 @@ class Toolbar extends Component {
|
80
|
75
|
return (
|
81
|
76
|
<div
|
82
|
77
|
className = { `toolbar ${className}` }
|
83
|
|
- onMouseOut = { this.props._onMouseOut }
|
84
|
|
- onMouseOver = { this.props._onMouseOver }>
|
|
78
|
+ onMouseOut = { this._onMouseOut }
|
|
79
|
+ onMouseOver = { this._onMouseOver }>
|
85
|
80
|
{
|
86
|
81
|
[ ...this.props.toolbarButtons.entries() ]
|
87
|
|
- .reduce(this._renderToolbarButton, [])
|
|
82
|
+ .reduce(this._renderToolbarButton, [])
|
88
|
83
|
}
|
89
|
84
|
{
|
90
|
85
|
this.props.children
|
|
@@ -93,6 +88,26 @@ class Toolbar extends Component {
|
93
|
88
|
);
|
94
|
89
|
}
|
95
|
90
|
|
|
91
|
+ /**
|
|
92
|
+ * Dispatches an action signalling that toolbar is no being hovered.
|
|
93
|
+ *
|
|
94
|
+ * @protected
|
|
95
|
+ * @returns {Object} Dispatched action.
|
|
96
|
+ */
|
|
97
|
+ _onMouseOut() {
|
|
98
|
+ this.props.dispatch(setToolbarHovered(false));
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ /**
|
|
102
|
+ * Dispatches an action signalling that toolbar is now being hovered.
|
|
103
|
+ *
|
|
104
|
+ * @protected
|
|
105
|
+ * @returns {Object} Dispatched action.
|
|
106
|
+ */
|
|
107
|
+ _onMouseOver() {
|
|
108
|
+ this.props.dispatch(setToolbarHovered(true));
|
|
109
|
+ }
|
|
110
|
+
|
96
|
111
|
/**
|
97
|
112
|
* Renders toolbar button. Method is passed to reduce function.
|
98
|
113
|
*
|
|
@@ -120,11 +135,15 @@ class Toolbar extends Component {
|
120
|
135
|
|
121
|
136
|
const { onClick, onMount, onUnmount } = button;
|
122
|
137
|
|
|
138
|
+ const onClickHandler
|
|
139
|
+ = (...args) =>
|
|
140
|
+ onClick(this.props.dispatch, ...args);
|
|
141
|
+
|
123
|
142
|
acc.push(
|
124
|
143
|
<ToolbarButton
|
125
|
144
|
button = { button }
|
126
|
145
|
key = { key }
|
127
|
|
- onClick = { onClick }
|
|
146
|
+ onClick = { onClickHandler }
|
128
|
147
|
onMount = { onMount }
|
129
|
148
|
onUnmount = { onUnmount }
|
130
|
149
|
tooltipPosition = { tooltipPosition } />
|
|
@@ -134,35 +153,4 @@ class Toolbar extends Component {
|
134
|
153
|
}
|
135
|
154
|
}
|
136
|
155
|
|
137
|
|
-/**
|
138
|
|
- * Maps part of Redux actions to component's props.
|
139
|
|
- *
|
140
|
|
- * @param {Function} dispatch - Redux action dispatcher.
|
141
|
|
- * @private
|
142
|
|
- * @returns {Object}
|
143
|
|
- */
|
144
|
|
-function _mapDispatchToProps(dispatch: Function): Object {
|
145
|
|
- return {
|
146
|
|
- /**
|
147
|
|
- * Dispatches an action signalling that toolbar is no being hovered.
|
148
|
|
- *
|
149
|
|
- * @protected
|
150
|
|
- * @returns {Object} Dispatched action.
|
151
|
|
- */
|
152
|
|
- _onMouseOut() {
|
153
|
|
- dispatch(setToolbarHovered(false));
|
154
|
|
- },
|
155
|
|
-
|
156
|
|
- /**
|
157
|
|
- * Dispatches an action signalling that toolbar is now being hovered.
|
158
|
|
- *
|
159
|
|
- * @protected
|
160
|
|
- * @returns {Object} Dispatched action.
|
161
|
|
- */
|
162
|
|
- _onMouseOver() {
|
163
|
|
- dispatch(setToolbarHovered(true));
|
164
|
|
- }
|
165
|
|
- };
|
166
|
|
-}
|
167
|
|
-
|
168
|
|
-export default connect(undefined, _mapDispatchToProps)(Toolbar);
|
|
156
|
+export default connect()(Toolbar);
|