Browse Source

Turn TranscribingLabel a self-containing component

master
Bettenbuk Zoltan 7 years ago
parent
commit
d604cdfe27

+ 3
- 14
react/features/large-video/components/AbstractLabels.js View File

20
      */
20
      */
21
     _filmstripVisible: boolean,
21
     _filmstripVisible: boolean,
22
 
22
 
23
-    /**
24
-     * Whether the video quality label should be displayed.
25
-     */
26
-    _showTranscribingLabel: boolean,
27
-
28
     /**
23
     /**
29
      * Whether the video quality label should be displayed.
24
      * Whether the video quality label should be displayed.
30
      */
25
      */
71
      * @returns {React$Element}
66
      * @returns {React$Element}
72
      */
67
      */
73
     _renderTranscribingLabel() {
68
     _renderTranscribingLabel() {
74
-        if (this.props._showTranscribingLabel) {
75
-            return (
76
-                <TranscribingLabel />
77
-            );
78
-        }
79
-
80
-        return null;
69
+        return (
70
+            <TranscribingLabel />
71
+        );
81
     }
72
     }
82
 
73
 
83
     /**
74
     /**
101
  * @private
92
  * @private
102
  * @returns {{
93
  * @returns {{
103
  *     _filmstripVisible: boolean,
94
  *     _filmstripVisible: boolean,
104
- *     _showTranscribingLabel: boolean,
105
  *     _showVideoQualityLabel: boolean
95
  *     _showVideoQualityLabel: boolean
106
  * }}
96
  * }}
107
  */
97
  */
108
 export function _abstractMapStateToProps(state: Object) {
98
 export function _abstractMapStateToProps(state: Object) {
109
     return {
99
     return {
110
         _filmstripVisible: isFilmstripVisible(state),
100
         _filmstripVisible: isFilmstripVisible(state),
111
-        _showTranscribingLabel: state['features/transcribing'].isTranscribing,
112
         _showVideoQualityLabel: !shouldDisplayTileView(state)
101
         _showVideoQualityLabel: !shouldDisplayTileView(state)
113
     };
102
     };
114
 }
103
 }

+ 21
- 0
react/features/transcribing/components/AbstractTranscribingLabel.js View File

5
  */
5
  */
6
 export type Props = {
6
 export type Props = {
7
 
7
 
8
+    /**
9
+     * True if the label needs to be rendered, false otherwise.
10
+     */
11
+    _showLabel: boolean,
12
+
8
     /**
13
     /**
9
      * Invoked to obtain translated strings.
14
      * Invoked to obtain translated strings.
10
      */
15
      */
11
     t: Function
16
     t: Function
12
 };
17
 };
18
+
19
+/**
20
+ * Maps (parts of) the redux state to the associated props of the
21
+ * {@link AbstractTranscribingLabel} {@code Component}.
22
+ *
23
+ * @param {Object} state - The redux state.
24
+ * @private
25
+ * @returns {{
26
+ *     _showLabel: boolean
27
+ * }}
28
+ */
29
+export function _mapStateToProps(state: Object) {
30
+    return {
31
+        _showLabel: state['features/transcribing'].isTranscribing
32
+    };
33
+}

+ 7
- 2
react/features/transcribing/components/TranscribingLabel.native.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
+import { connect } from 'react-redux';
4
 
5
 
5
 import { translate } from '../../base/i18n';
6
 import { translate } from '../../base/i18n';
6
 import { CircularLabel } from '../../base/label';
7
 import { CircularLabel } from '../../base/label';
7
 
8
 
8
-import { type Props } from './AbstractTranscribingLabel';
9
+import { _mapStateToProps, type Props } from './AbstractTranscribingLabel';
9
 
10
 
10
 /**
11
 /**
11
  * React {@code Component} for displaying a label when a transcriber is in the
12
  * React {@code Component} for displaying a label when a transcriber is in the
21
      * @inheritdoc
22
      * @inheritdoc
22
      */
23
      */
23
     render() {
24
     render() {
25
+        if (!this.props._showLabel) {
26
+            return null;
27
+        }
28
+
24
         return (
29
         return (
25
             <CircularLabel
30
             <CircularLabel
26
                 label = { this.props.t('transcribing.tr') } />
31
                 label = { this.props.t('transcribing.tr') } />
28
     }
33
     }
29
 }
34
 }
30
 
35
 
31
-export default translate(TranscribingLabel);
36
+export default translate(connect(_mapStateToProps)(TranscribingLabel));

+ 7
- 2
react/features/transcribing/components/TranscribingLabel.web.js View File

2
 
2
 
3
 import Tooltip from '@atlaskit/tooltip';
3
 import Tooltip from '@atlaskit/tooltip';
4
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
5
+import { connect } from 'react-redux';
5
 
6
 
6
 import { translate } from '../../base/i18n';
7
 import { translate } from '../../base/i18n';
7
 import { CircularLabel } from '../../base/label';
8
 import { CircularLabel } from '../../base/label';
8
 
9
 
9
-import { type Props } from './AbstractTranscribingLabel';
10
+import { _mapStateToProps, type Props } from './AbstractTranscribingLabel';
10
 
11
 
11
 /**
12
 /**
12
  * React {@code Component} for displaying a label when a transcriber is in the
13
  * React {@code Component} for displaying a label when a transcriber is in the
23
      * @returns {ReactElement}
24
      * @returns {ReactElement}
24
      */
25
      */
25
     render() {
26
     render() {
27
+        if (!this.props._showLabel) {
28
+            return null;
29
+        }
30
+
26
         return (
31
         return (
27
             <Tooltip
32
             <Tooltip
28
                 content = { this.props.t('transcribing.labelToolTip') }
33
                 content = { this.props.t('transcribing.labelToolTip') }
36
 
41
 
37
 }
42
 }
38
 
43
 
39
-export default translate(TranscribingLabel);
44
+export default translate(connect(_mapStateToProps)(TranscribingLabel));

Loading…
Cancel
Save