|
@@ -1,115 +1,25 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
|
-import React, { Component } from 'react';
|
4
|
3
|
import { connect } from 'react-redux';
|
5
|
|
-import { translate } from '../../base/i18n/index';
|
6
|
|
-
|
7
|
|
-import { ToolbarButton } from '../../toolbox/';
|
8
|
|
-
|
9
|
|
-import { toggleRequestingSubtitles } from '../actions';
|
10
|
|
-import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
11
|
|
-
|
12
|
|
-
|
13
|
|
-/**
|
14
|
|
- * The type of the React {@code Component} props of {@link TranscribingLabel}.
|
15
|
|
- */
|
16
|
|
-type Props = {
|
17
|
|
-
|
18
|
|
- /**
|
19
|
|
- * Invoked to obtain translated strings.
|
20
|
|
- */
|
21
|
|
- t: Function,
|
22
|
|
-
|
23
|
|
- /**
|
24
|
|
- * Invoked to Dispatch an Action to the redux store.
|
25
|
|
- */
|
26
|
|
- dispatch: Function,
|
27
|
|
-
|
28
|
|
- /**
|
29
|
|
- * Whether the local participant is currently requesting subtitles.
|
30
|
|
- */
|
31
|
|
- _requestingSubtitles: Boolean
|
32
|
|
-};
|
33
|
|
-
|
34
|
|
-/**
|
35
|
|
- * React Component for displaying a label when a transcriber is in the
|
36
|
|
- * conference.
|
37
|
|
- *
|
38
|
|
- * @extends Component
|
39
|
|
- */
|
40
|
|
-class ClosedCaptionButton extends Component<Props> {
|
41
|
|
-
|
42
|
|
- /**
|
43
|
|
- * Initializes a new {@code ClosedCaptionButton} instance.
|
44
|
|
- *
|
45
|
|
- * @param {Props} props - The read-only properties with which the new
|
46
|
|
- * instance is to be initialized.
|
47
|
|
- */
|
48
|
|
- constructor(props: Props) {
|
49
|
|
- super(props);
|
50
|
|
-
|
51
|
|
- // Bind event handler so it is only bound once for every instance.
|
52
|
|
- this._onToggleButton = this._onToggleButton.bind(this);
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- /**
|
56
|
|
- * Implements React's {@link Component#render()}.
|
57
|
|
- *
|
58
|
|
- * @inheritdoc
|
59
|
|
- * @returns {ReactElement}
|
60
|
|
- */
|
61
|
|
- render() {
|
62
|
|
- const { _requestingSubtitles, t } = this.props;
|
63
|
|
- const iconClass = `icon-closed_caption ${_requestingSubtitles
|
64
|
|
- ? 'toggled' : ''}`;
|
65
|
|
-
|
66
|
|
- return (
|
67
|
|
- <ToolbarButton
|
68
|
|
- accessibilityLabel
|
69
|
|
- = { t('toolbar.accessibilityLabel.cc') }
|
70
|
|
- iconName = { iconClass }
|
71
|
|
- onClick = { this._onToggleButton }
|
72
|
|
- tooltip = { t('transcribing.ccButtonTooltip') } />
|
73
|
|
- );
|
74
|
|
- }
|
75
|
4
|
|
76
|
|
- _onToggleButton: () => void;
|
77
|
|
-
|
78
|
|
- /**
|
79
|
|
- * Dispatch actions for starting or stopping transcription, based on
|
80
|
|
- * current state.
|
81
|
|
- *
|
82
|
|
- * @private
|
83
|
|
- * @returns {void}
|
84
|
|
- */
|
85
|
|
- _onToggleButton() {
|
86
|
|
- const { _requestingSubtitles, dispatch } = this.props;
|
87
|
|
-
|
88
|
|
- sendAnalytics(createToolbarEvent('transcribing.ccButton',
|
89
|
|
- {
|
90
|
|
- 'requesting_subtitles': Boolean(_requestingSubtitles)
|
91
|
|
- }));
|
92
|
|
-
|
93
|
|
- dispatch(toggleRequestingSubtitles());
|
94
|
|
- }
|
|
5
|
+import { translate } from '../../base/i18n/index';
|
95
|
6
|
|
96
|
|
-}
|
|
7
|
+import {
|
|
8
|
+ AbstractClosedCaptionButton,
|
|
9
|
+ _abstractMapStateToProps
|
|
10
|
+} from './AbstractClosedCaptionButton';
|
97
|
11
|
|
98
|
12
|
/**
|
99
|
|
- * Maps (parts of) the Redux state to the associated props for the
|
100
|
|
- * {@code ClosedCaptionButton} component.
|
101
|
|
- *
|
102
|
|
- * @param {Object} state - The Redux state.
|
103
|
|
- * @private
|
104
|
|
- * @returns {{
|
105
|
|
- * }}
|
|
13
|
+ * A button which starts/stops the transcriptions.
|
106
|
14
|
*/
|
107
|
|
-function _mapStateToProps(state) {
|
108
|
|
- const { _requestingSubtitles } = state['features/subtitles'];
|
|
15
|
+class ClosedCaptionButton
|
|
16
|
+ extends AbstractClosedCaptionButton {
|
109
|
17
|
|
110
|
|
- return {
|
111
|
|
- _requestingSubtitles
|
112
|
|
- };
|
|
18
|
+ accessibilityLabel = 'toolbar.accessibilityLabel.cc';
|
|
19
|
+ iconName = 'icon-closed_caption';
|
|
20
|
+ toggledIconName = 'icon-closed_caption toggled';
|
|
21
|
+ tooltip = 'transcribing.ccButtonTooltip';
|
113
|
22
|
}
|
114
|
23
|
|
115
|
|
-export default translate(connect(_mapStateToProps)(ClosedCaptionButton));
|
|
24
|
+export default translate(connect(_abstractMapStateToProps)(
|
|
25
|
+ ClosedCaptionButton));
|