|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+import PropTypes from 'prop-types';
|
|
1
|
2
|
import React, { Component } from 'react';
|
|
2
|
3
|
import { connect } from 'react-redux';
|
|
3
|
4
|
|
|
4
|
5
|
/**
|
|
5
|
|
- * Implements a DialogContainer that will be responsible for
|
|
6
|
|
- * showing all dialogs. We will need a separate container so we can handle
|
|
7
|
|
- * multiple dialogs, showing them simultaneously or queueing them.
|
|
|
6
|
+ * Implements a DialogContainer responsible for showing all dialogs. We will
|
|
|
7
|
+ * need a separate container so we can handle multiple dialogs by showing them
|
|
|
8
|
+ * simultaneously or queuing them.
|
|
8
|
9
|
*/
|
|
9
|
10
|
export class DialogContainer extends Component {
|
|
10
|
|
-
|
|
11
|
11
|
/**
|
|
12
|
12
|
* DialogContainer component's property types.
|
|
13
|
13
|
*
|
|
|
@@ -17,12 +17,12 @@ export class DialogContainer extends Component {
|
|
17
|
17
|
/**
|
|
18
|
18
|
* The component to render.
|
|
19
|
19
|
*/
|
|
20
|
|
- _component: React.PropTypes.func,
|
|
|
20
|
+ _component: PropTypes.func,
|
|
21
|
21
|
|
|
22
|
22
|
/**
|
|
23
|
23
|
* The props to pass to the component that will be rendered.
|
|
24
|
24
|
*/
|
|
25
|
|
- _componentProps: React.PropTypes.object
|
|
|
25
|
+ _componentProps: PropTypes.object
|
|
26
|
26
|
};
|
|
27
|
27
|
|
|
28
|
28
|
/**
|
|
|
@@ -32,29 +32,32 @@ export class DialogContainer extends Component {
|
|
32
|
32
|
* @returns {ReactElement}
|
|
33
|
33
|
*/
|
|
34
|
34
|
render() {
|
|
35
|
|
- if (!this.props._component) {
|
|
36
|
|
- return null;
|
|
37
|
|
- }
|
|
|
35
|
+ const { _component: component } = this.props;
|
|
38
|
36
|
|
|
39
|
|
- return React.createElement(
|
|
40
|
|
- this.props._component, this.props._componentProps);
|
|
|
37
|
+ return (
|
|
|
38
|
+ component
|
|
|
39
|
+ ? React.createElement(component, this.props._componentProps)
|
|
|
40
|
+ : null);
|
|
41
|
41
|
}
|
|
42
|
42
|
}
|
|
43
|
43
|
|
|
44
|
44
|
/**
|
|
45
|
|
- * Maps (parts of) the Redux state to the associated Dialog's props.
|
|
|
45
|
+ * Maps (parts of) the redux state to the associated <tt>DialogContainer</tt>'s
|
|
|
46
|
+ * props.
|
|
46
|
47
|
*
|
|
47
|
|
- * @param {Object} state - The Redux state.
|
|
|
48
|
+ * @param {Object} state - The redux state.
|
|
48
|
49
|
* @private
|
|
49
|
50
|
* @returns {{
|
|
50
|
51
|
* _component: React.Component,
|
|
51
|
|
- * _props: React.PropTypes.object
|
|
|
52
|
+ * _componentProps: Object
|
|
52
|
53
|
* }}
|
|
53
|
54
|
*/
|
|
54
|
55
|
function _mapStateToProps(state) {
|
|
|
56
|
+ const stateFeaturesBaseDialog = state['features/base/dialog'];
|
|
|
57
|
+
|
|
55
|
58
|
return {
|
|
56
|
|
- _component: state['features/base/dialog'].component,
|
|
57
|
|
- _componentProps: state['features/base/dialog'].componentProps
|
|
|
59
|
+ _component: stateFeaturesBaseDialog.component,
|
|
|
60
|
+ _componentProps: stateFeaturesBaseDialog.componentProps
|
|
58
|
61
|
};
|
|
59
|
62
|
}
|
|
60
|
63
|
|