Browse Source

ref(overlays): Replace the abstract class for overlays with overlay frame component

In this case makes more sense to have overlay frame included in every overlay instead
of abstract class that implements the overlay frame and have to be extended by every
overlay. In addition, mapStateToProps isn't working well with inheritance.
j8
hristoterezov 8 years ago
parent
commit
c461e8b63c

+ 0
- 80
react/features/overlay/components/AbstractOverlay.js View File

1
-/* global APP */
2
-
3
-import React, { Component } from 'react';
4
-
5
-/**
6
- * Implements an abstract React Component for overlay - the components which are
7
- * displayed on top of the application covering the whole screen.
8
- *
9
- * @abstract
10
- */
11
-export default class AbstractOverlay extends Component {
12
-    /**
13
-     * Initializes a new AbstractOverlay instance.
14
-     *
15
-     * @param {Object} props - The read-only properties with which the new
16
-     * instance is to be initialized.
17
-     * @public
18
-     */
19
-    constructor(props) {
20
-        super(props);
21
-
22
-        this.state = {
23
-            /**
24
-             * Indicates the CSS style of the overlay. If true, then ighter;
25
-             * darker, otherwise.
26
-             *
27
-             * @type {boolean}
28
-             */
29
-            isLightOverlay: false
30
-        };
31
-    }
32
-
33
-    /**
34
-     * Implements React's {@link Component#render()}.
35
-     *
36
-     * @inheritdoc
37
-     * @returns {ReactElement|null}
38
-     */
39
-    render() {
40
-        const containerClass
41
-            = this.state.isLightOverlay
42
-                ? 'overlay__container-light'
43
-                : 'overlay__container';
44
-
45
-        return (
46
-            <div
47
-                className = { containerClass }
48
-                id = 'overlay'>
49
-                <div className = 'overlay__content'>
50
-                    {
51
-                        this._renderOverlayContent()
52
-                    }
53
-                </div>
54
-            </div>
55
-        );
56
-    }
57
-
58
-    /**
59
-     * Reloads the page.
60
-     *
61
-     * @returns {void}
62
-     * @protected
63
-     */
64
-    _reconnectNow() {
65
-        // FIXME: In future we should dispatch an action here that will result
66
-        // in reload.
67
-        APP.ConferenceUrl.reload();
68
-    }
69
-
70
-    /**
71
-     * Abstract method which should be used by subclasses to provide the overlay
72
-     * content.
73
-     *
74
-     * @returns {ReactElement|null}
75
-     * @protected
76
-     */
77
-    _renderOverlayContent() {
78
-        return null;
79
-    }
80
-}

+ 52
- 0
react/features/overlay/components/OverlayFrame.js View File

1
+import React, { Component } from 'react';
2
+
3
+/**
4
+ * Implements an abstract React Component for overlay - the components which are
5
+ * displayed on top of the application covering the whole screen.
6
+ *
7
+ * @abstract
8
+ */
9
+export default class OverlayFrame extends Component {
10
+    /**
11
+     * OverlayFrame component's property types.
12
+     *
13
+     * @static
14
+     */
15
+    static propTypes = {
16
+        /**
17
+         * The children components to be displayed into the overlay frame.
18
+         */
19
+        children: React.PropTypes.node.isRequired,
20
+
21
+        /**
22
+         * Indicates the css style of the overlay. If true, then lighter;
23
+         * darker, otherwise.
24
+         *
25
+         * @type {boolean}
26
+         */
27
+        isLightOverlay: React.PropTypes.bool
28
+    }
29
+
30
+    /**
31
+     * Implements React's {@link Component#render()}.
32
+     *
33
+     * @inheritdoc
34
+     * @returns {ReactElement|null}
35
+     */
36
+    render() {
37
+        const containerClass = this.props.isLightOverlay
38
+            ? 'overlay__container-light' : 'overlay__container';
39
+
40
+        return (
41
+            <div
42
+                className = { containerClass }
43
+                id = 'overlay'>
44
+                <div className = 'overlay__content'>
45
+                    {
46
+                        this.props.children
47
+                    }
48
+                </div>
49
+            </div>
50
+        );
51
+    }
52
+}

+ 36
- 32
react/features/overlay/components/PageReloadOverlay.js View File

1
-import React from 'react';
1
+import React, { Component } from 'react';
2
 
2
 
3
 import { translate } from '../../base/i18n';
3
 import { translate } from '../../base/i18n';
4
 import { randomInt } from '../../base/util';
4
 import { randomInt } from '../../base/util';
5
 
5
 
6
-import AbstractOverlay from './AbstractOverlay';
6
+import OverlayFrame from './OverlayFrame';
7
+import { reconnectNow } from '../functions';
7
 import ReloadTimer from './ReloadTimer';
8
 import ReloadTimer from './ReloadTimer';
8
 
9
 
9
 declare var APP: Object;
10
 declare var APP: Object;
15
  * conference is reloaded. Shows a warning message and counts down towards the
16
  * conference is reloaded. Shows a warning message and counts down towards the
16
  * reload.
17
  * reload.
17
  */
18
  */
18
-class PageReloadOverlay extends AbstractOverlay {
19
+class PageReloadOverlay extends Component {
19
     /**
20
     /**
20
      * PageReloadOverlay component's property types.
21
      * PageReloadOverlay component's property types.
21
      *
22
      *
32
 
33
 
33
         /**
34
         /**
34
          * The reason for the error that will cause the reload.
35
          * The reason for the error that will cause the reload.
35
-         * NOTE: Used by PageReloadOverlay only.
36
          * @public
36
          * @public
37
          * @type {string}
37
          * @type {string}
38
          */
38
          */
39
-        reason: React.PropTypes.string
39
+        reason: React.PropTypes.string,
40
+
41
+        /**
42
+         * The function to translate human-readable text.
43
+         *
44
+         * @public
45
+         * @type {Function}
46
+         */
47
+        t: React.PropTypes.func
40
     }
48
     }
41
 
49
 
42
     /**
50
     /**
69
         }
77
         }
70
 
78
 
71
         this.state = {
79
         this.state = {
72
-            ...this.state,
73
-
74
             /**
80
             /**
75
              * Indicates the css style of the overlay. If true, then lighter;
81
              * Indicates the css style of the overlay. If true, then lighter;
76
              * darker, otherwise.
82
              * darker, otherwise.
110
      * @returns {void}
116
      * @returns {void}
111
      */
117
      */
112
     componentDidMount() {
118
     componentDidMount() {
113
-        super.componentDidMount();
114
-
115
         // FIXME (CallStats - issue) This event will not make it to CallStats
119
         // FIXME (CallStats - issue) This event will not make it to CallStats
116
         // because the log queue is not flushed before "fabric terminated" is
120
         // because the log queue is not flushed before "fabric terminated" is
117
         // sent to the backed.
121
         // sent to the backed.
143
                 <button
147
                 <button
144
                     className = { className }
148
                     className = { className }
145
                     id = 'reconnectNow'
149
                     id = 'reconnectNow'
146
-                    onClick = { this._reconnectNow }>
150
+                    onClick = { reconnectNow }>
147
                     { t('dialog.reconnectNow') }
151
                     { t('dialog.reconnectNow') }
148
                 </button>
152
                 </button>
149
             );
153
             );
156
     }
160
     }
157
 
161
 
158
     /**
162
     /**
159
-     * Constructs overlay body with the warning message and count down towards
160
-     * the conference reload.
163
+     * Implements React's {@link Component#render()}.
161
      *
164
      *
165
+     * @inheritdoc
162
      * @returns {ReactElement|null}
166
      * @returns {ReactElement|null}
163
-     * @override
164
-     * @protected
165
      */
167
      */
166
-    _renderOverlayContent() {
168
+    render() {
167
         const { t } = this.props;
169
         const { t } = this.props;
168
 
170
 
169
         /* eslint-disable react/jsx-handler-names */
171
         /* eslint-disable react/jsx-handler-names */
170
 
172
 
171
         return (
173
         return (
172
-            <div className = 'inlay'>
173
-                <span
174
-                    className = 'reload_overlay_title'>
175
-                    { t(this.state.title) }
176
-                </span>
177
-                <span
178
-                    className = 'reload_overlay_text'>
179
-                    { t(this.state.message) }
180
-                </span>
181
-                <ReloadTimer
182
-                    end = { 0 }
183
-                    interval = { 1 }
184
-                    onFinish = { this._reconnectNow }
185
-                    start = { this.state.timeoutSeconds }
186
-                    step = { -1 } />
187
-                { this._renderButton() }
188
-            </div>
174
+            <OverlayFrame isLightOverlay = { this.state.isLightOverlay }>
175
+                <div className = 'inlay'>
176
+                    <span
177
+                        className = 'reload_overlay_title'>
178
+                        { t(this.state.title) }
179
+                    </span>
180
+                    <span
181
+                        className = 'reload_overlay_text'>
182
+                        { t(this.state.message) }
183
+                    </span>
184
+                    <ReloadTimer
185
+                        end = { 0 }
186
+                        interval = { 1 }
187
+                        onFinish = { reconnectNow }
188
+                        start = { this.state.timeoutSeconds }
189
+                        step = { -1 } />
190
+                    { this._renderButton() }
191
+                </div>
192
+            </OverlayFrame>
189
         );
193
         );
190
 
194
 
191
         /* eslint-enable react/jsx-handler-names */
195
         /* eslint-enable react/jsx-handler-names */

+ 18
- 12
react/features/overlay/components/UserMediaPermissionsOverlay.js View File

1
 /* global interfaceConfig */
1
 /* global interfaceConfig */
2
 
2
 
3
-import React from 'react';
3
+import React, { Component } from 'react';
4
 
4
 
5
 import { translate, translateToHTML } from '../../base/i18n';
5
 import { translate, translateToHTML } from '../../base/i18n';
6
 
6
 
7
-import AbstractOverlay from './AbstractOverlay';
7
+import OverlayFrame from './OverlayFrame';
8
 
8
 
9
 /**
9
 /**
10
  * Implements a React Component for overlay with guidance how to proceed with
10
  * Implements a React Component for overlay with guidance how to proceed with
11
  * gUM prompt.
11
  * gUM prompt.
12
  */
12
  */
13
-class UserMediaPermissionsOverlay extends AbstractOverlay {
13
+class UserMediaPermissionsOverlay extends Component {
14
     /**
14
     /**
15
      * UserMediaPermissionsOverlay component's property types.
15
      * UserMediaPermissionsOverlay component's property types.
16
      *
16
      *
24
          * @public
24
          * @public
25
          * @type {string}
25
          * @type {string}
26
          */
26
          */
27
-        browser: React.PropTypes.string
27
+        browser: React.PropTypes.string,
28
+
29
+        /**
30
+         * The function to translate human-readable text.
31
+         *
32
+         * @public
33
+         * @type {Function}
34
+         */
35
+        t: React.PropTypes.func
28
     }
36
     }
29
 
37
 
30
     /**
38
     /**
48
     }
56
     }
49
 
57
 
50
     /**
58
     /**
51
-     * Constructs overlay body with the message with guidance how to proceed
52
-     * with gUM prompt.
59
+     * Implements React's {@link Component#render()}.
53
      *
60
      *
61
+     * @inheritdoc
54
      * @returns {ReactElement|null}
62
      * @returns {ReactElement|null}
55
-     * @override
56
-     * @protected
57
      */
63
      */
58
-    _renderOverlayContent() {
64
+    render() {
59
         const { browser, t } = this.props;
65
         const { browser, t } = this.props;
60
 
66
 
61
         return (
67
         return (
62
-            <div>
68
+            <OverlayFrame>
63
                 <div className = 'inlay'>
69
                 <div className = 'inlay'>
64
                     <span className = 'inlay__icon icon-microphone' />
70
                     <span className = 'inlay__icon icon-microphone' />
65
                     <span className = 'inlay__icon icon-camera' />
71
                     <span className = 'inlay__icon icon-camera' />
80
                 </div>
86
                 </div>
81
                 <div className = 'policy overlay__policy'>
87
                 <div className = 'policy overlay__policy'>
82
                     <p className = 'policy__text'>
88
                     <p className = 'policy__text'>
83
-                        { t('startupoverlay.policyText') }
89
+                        { translateToHTML(t, 'startupoverlay.policyText') }
84
                     </p>
90
                     </p>
85
                     {
91
                     {
86
                         this._renderPolicyLogo()
92
                         this._renderPolicyLogo()
87
                     }
93
                     }
88
                 </div>
94
                 </div>
89
-            </div>
95
+            </OverlayFrame>
90
         );
96
         );
91
     }
97
     }
92
 
98
 

+ 12
- 0
react/features/overlay/functions.js View File

1
+/* global APP */
2
+/**
3
+ * Reloads the page.
4
+ *
5
+ * @returns {void}
6
+ * @protected
7
+ */
8
+export function reconnectNow() {
9
+    // FIXME: In future we should dispatch an action here that will result
10
+    // in reload.
11
+    APP.ConferenceUrl.reload();
12
+}

Loading…
Cancel
Save