소스 검색

Coding style

master
Lyubo Marinov 8 년 전
부모
커밋
03b4a32dd7
2개의 변경된 파일27개의 추가작업 그리고 28개의 파일을 삭제
  1. 8
    12
      react/features/base/dialog/actions.js
  2. 19
    16
      react/features/base/dialog/components/DialogContainer.js

+ 8
- 12
react/features/base/dialog/actions.js 파일 보기

@@ -1,7 +1,4 @@
1
-import {
2
-    HIDE_DIALOG,
3
-    OPEN_DIALOG
4
-} from './actionTypes';
1
+import { HIDE_DIALOG, OPEN_DIALOG } from './actionTypes';
5 2
 
6 3
 /**
7 4
  * Signals Dialog to close its dialog.
@@ -20,7 +17,8 @@ export function hideDialog() {
20 17
  * Signals Dialog to open dialog.
21 18
  *
22 19
  * @param {Object} component - The component to display as dialog.
23
- * @param {Object} componentProps - The properties needed for that component.
20
+ * @param {Object} [componentProps] - The React <tt>Component</tt> props of the
21
+ * specified <tt>component</tt>.
24 22
  * @returns {Object}
25 23
  */
26 24
 export function openDialog(component, componentProps) {
@@ -33,19 +31,17 @@ export function openDialog(component, componentProps) {
33 31
 
34 32
 /**
35 33
  * Signals Dialog to open a dialog with the specified component if the component
36
- * is not already open. If it is open, then Dialog is signaled to close
37
- * its dialog.
34
+ * is not already open. If it is open, then Dialog is signaled to close its
35
+ * dialog.
38 36
  *
39 37
  * @param {Object} component - The component to display as dialog.
40
- * @param {Object} componentProps - The properties needed for that component.
38
+ * @param {Object} [componentProps] - The React <tt>Component</tt> props of the
39
+ * specified <tt>component</tt>.
41 40
  * @returns {Object}
42 41
  */
43 42
 export function toggleDialog(component, componentProps) {
44 43
     return (dispatch, getState) => {
45
-        const state = getState();
46
-        const dialogState = state['features/base/dialog'];
47
-
48
-        if (dialogState.component === component) {
44
+        if (getState()['features/base/dialog'].component === component) {
49 45
             dispatch(hideDialog());
50 46
         } else {
51 47
             dispatch(openDialog(component, componentProps));

+ 19
- 16
react/features/base/dialog/components/DialogContainer.js 파일 보기

@@ -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
 

Loading…
취소
저장