Browse Source

fix(record):web/mobile match disable functionality

master
Hristo Terezov 5 years ago
parent
commit
a2c4d17e4d

+ 43
- 2
react/features/recording/components/LiveStream/AbstractLiveStreamButton.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { openDialog } from '../../../base/dialog';
3
 import { openDialog } from '../../../base/dialog';
4
+import { IconLiveStreaming } from '../../../base/icons';
4
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
5
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
5
 import { getLocalParticipant } from '../../../base/participants';
6
 import { getLocalParticipant } from '../../../base/participants';
6
 import {
7
 import {
30
      */
31
      */
31
     _disabled: Boolean,
32
     _disabled: Boolean,
32
 
33
 
34
+    /**
35
+     * The tooltip to display when hovering over the button.
36
+     */
37
+    _tooltip: ?String,
38
+
33
     /**
39
     /**
34
      * The redux {@code dispatch} function.
40
      * The redux {@code dispatch} function.
35
      */
41
      */
44
 /**
50
 /**
45
  * An abstract class of a button for starting and stopping live streaming.
51
  * An abstract class of a button for starting and stopping live streaming.
46
  */
52
  */
47
-export default class AbstractLiveStreamButton<P: Props>
48
-    extends AbstractButton<P, *> {
53
+export default class AbstractLiveStreamButton<P: Props> extends AbstractButton<P, *> {
49
     accessibilityLabel = 'dialog.accessibilityLabel.liveStreaming';
54
     accessibilityLabel = 'dialog.accessibilityLabel.liveStreaming';
55
+    icon = IconLiveStreaming;
50
     label = 'dialog.startLiveStreaming';
56
     label = 'dialog.startLiveStreaming';
51
     toggledLabel = 'dialog.stopLiveStreaming';
57
     toggledLabel = 'dialog.stopLiveStreaming';
52
 
58
 
59
+    /**
60
+     * Returns the tooltip that should be displayed when the button is disabled.
61
+     *
62
+     * @private
63
+     * @returns {string}
64
+     */
65
+    _getTooltip() {
66
+        return this.props._tooltip || '';
67
+    }
68
+
53
     /**
69
     /**
54
      * Handles clicking / pressing the button.
70
      * Handles clicking / pressing the button.
55
      *
71
      *
65
         ));
81
         ));
66
     }
82
     }
67
 
83
 
84
+    /**
85
+     * Returns a boolean value indicating if this button is disabled or not.
86
+     *
87
+     * @protected
88
+     * @returns {boolean}
89
+     */
90
+    _isDisabled() {
91
+        return this.props._disabled;
92
+    }
93
+
68
     /**
94
     /**
69
      * Indicates whether this button is in toggled state or not.
95
      * Indicates whether this button is in toggled state or not.
70
      *
96
      *
96
     // A button can be disabled/enabled only if enableFeaturesBasedOnToken
122
     // A button can be disabled/enabled only if enableFeaturesBasedOnToken
97
     // is on or if the recording is running.
123
     // is on or if the recording is running.
98
     let _disabled;
124
     let _disabled;
125
+    let _tooltip = '';
99
 
126
 
100
     if (typeof visible === 'undefined') {
127
     if (typeof visible === 'undefined') {
101
         // If the containing component provides the visible prop, that is one
128
         // If the containing component provides the visible prop, that is one
112
         if (enableFeaturesBasedOnToken) {
139
         if (enableFeaturesBasedOnToken) {
113
             visible = visible && String(features.livestreaming) === 'true';
140
             visible = visible && String(features.livestreaming) === 'true';
114
             _disabled = String(features.livestreaming) === 'disabled';
141
             _disabled = String(features.livestreaming) === 'disabled';
142
+
143
+            if (!visible && !_disabled) {
144
+                _disabled = true;
145
+                visible = true;
146
+
147
+                // button and tooltip
148
+                if (state['features/base/jwt'].isGuest) {
149
+                    _tooltip = 'dialog.liveStreamingDisabledForGuestTooltip';
150
+                } else {
151
+                    _tooltip = 'dialog.liveStreamingDisabledTooltip';
152
+                }
153
+            }
115
         }
154
         }
116
     }
155
     }
117
 
156
 
118
     // disable the button if the recording is running.
157
     // disable the button if the recording is running.
119
     if (getActiveSession(state, JitsiRecordingConstants.mode.FILE)) {
158
     if (getActiveSession(state, JitsiRecordingConstants.mode.FILE)) {
120
         _disabled = true;
159
         _disabled = true;
160
+        _tooltip = 'dialog.liveStreamingDisabledBecauseOfActiveRecordingTooltip';
121
     }
161
     }
122
 
162
 
123
     return {
163
     return {
124
         _disabled,
164
         _disabled,
125
         _isLiveStreamRunning: Boolean(
165
         _isLiveStreamRunning: Boolean(
126
             getActiveSession(state, JitsiRecordingConstants.mode.STREAM)),
166
             getActiveSession(state, JitsiRecordingConstants.mode.STREAM)),
167
+        _tooltip,
127
         visible
168
         visible
128
     };
169
     };
129
 }
170
 }

+ 2
- 13
react/features/recording/components/LiveStream/native/LiveStreamButton.js View File

2
 
2
 
3
 import { LIVE_STREAMING_ENABLED, getFeatureFlag } from '../../../../base/flags';
3
 import { LIVE_STREAMING_ENABLED, getFeatureFlag } from '../../../../base/flags';
4
 import { translate } from '../../../../base/i18n';
4
 import { translate } from '../../../../base/i18n';
5
-import { IconLiveStreaming } from '../../../../base/icons';
6
 import { connect } from '../../../../base/redux';
5
 import { connect } from '../../../../base/redux';
7
-import AbstractLiveStreamButton, {
8
-    _mapStateToProps as _abstractMapStateToProps,
9
-    type Props
10
-} from '../AbstractLiveStreamButton';
11
-
12
-/**
13
- * An implementation of a button for starting and stopping live streaming.
14
- */
15
-class LiveStreamButton extends AbstractLiveStreamButton<Props> {
16
-    icon = IconLiveStreaming;
17
-}
6
+import AbstractLiveStreamButton, { _mapStateToProps as _abstractMapStateToProps } from '../AbstractLiveStreamButton';
18
 
7
 
19
 /**
8
 /**
20
  * Maps (parts of) the redux state to the associated props for this component.
9
  * Maps (parts of) the redux state to the associated props for this component.
35
     };
24
     };
36
 }
25
 }
37
 
26
 
38
-export default translate(connect(mapStateToProps)(LiveStreamButton));
27
+export default translate(connect(mapStateToProps)(AbstractLiveStreamButton));

+ 3
- 73
react/features/recording/components/LiveStream/web/LiveStreamButton.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { translate } from '../../../../base/i18n';
3
 import { translate } from '../../../../base/i18n';
4
-import { IconLiveStreaming } from '../../../../base/icons';
5
 import { connect } from '../../../../base/redux';
4
 import { connect } from '../../../../base/redux';
6
 import AbstractLiveStreamButton, {
5
 import AbstractLiveStreamButton, {
7
     _mapStateToProps as _abstractMapStateToProps,
6
     _mapStateToProps as _abstractMapStateToProps,
8
-    type Props as AbstractProps
7
+    type Props
9
 } from '../AbstractLiveStreamButton';
8
 } from '../AbstractLiveStreamButton';
10
 
9
 
11
 declare var interfaceConfig: Object;
10
 declare var interfaceConfig: Object;
12
 
11
 
13
-type Props = AbstractProps & {
14
-
15
-    /**
16
-     * True if the button should be disabled, false otherwise.
17
-     *
18
-     * NOTE: On web, if the feature is not disabled on purpose, then we still
19
-     * show the button but disabled and with a tooltip rendered on it,
20
-     * explaining why it's not available.
21
-     */
22
-    _disabled: boolean,
23
-
24
-    /**
25
-     * Tooltip for the button when it's disabled in a certain way.
26
-     */
27
-    _liveStreamDisabledTooltipKey: ?string
28
-}
29
-
30
-/**
31
- * An implementation of a button for starting and stopping live streaming.
32
- */
33
-class LiveStreamButton extends AbstractLiveStreamButton<Props> {
34
-    icon = IconLiveStreaming;
35
-
36
-    /**
37
-     * Returns the tooltip that should be displayed when the button is disabled.
38
-     *
39
-     * @private
40
-     * @returns {string}
41
-     */
42
-    _getTooltip() {
43
-        return this.props._liveStreamDisabledTooltipKey || '';
44
-    }
45
-
46
-    /**
47
-     * Helper function to be implemented by subclasses, which must return a
48
-     * boolean value indicating if this button is disabled or not.
49
-     *
50
-     * @override
51
-     * @protected
52
-     * @returns {boolean}
53
-     */
54
-    _isDisabled() {
55
-        return this.props._disabled;
56
-    }
57
-}
58
-
59
 /**
12
 /**
60
  * Maps (parts of) the redux state to the associated props for the
13
  * Maps (parts of) the redux state to the associated props for the
61
  * {@code LiveStreamButton} component.
14
  * {@code LiveStreamButton} component.
74
     const abstractProps = _abstractMapStateToProps(state, ownProps);
27
     const abstractProps = _abstractMapStateToProps(state, ownProps);
75
     let { visible } = ownProps;
28
     let { visible } = ownProps;
76
 
29
 
77
-    let { _disabled } = abstractProps;
78
-    let _liveStreamDisabledTooltipKey;
79
-
80
-    if (!abstractProps.visible && _disabled !== undefined && !_disabled) {
81
-        _disabled = true;
82
-
83
-        // button and tooltip
84
-        if (state['features/base/jwt'].isGuest) {
85
-            _liveStreamDisabledTooltipKey
86
-                = 'dialog.liveStreamingDisabledForGuestTooltip';
87
-        } else {
88
-            _liveStreamDisabledTooltipKey
89
-                = 'dialog.liveStreamingDisabledTooltip';
90
-        }
91
-    } else if (_disabled) {
92
-        _liveStreamDisabledTooltipKey = 'dialog.liveStreamingDisabledBecauseOfActiveRecordingTooltip';
93
-    } else {
94
-        _disabled = false;
95
-    }
96
-
97
     if (typeof visible === 'undefined') {
30
     if (typeof visible === 'undefined') {
98
-        visible = interfaceConfig.TOOLBAR_BUTTONS.includes('livestreaming')
99
-            && (abstractProps.visible || Boolean(_liveStreamDisabledTooltipKey));
31
+        visible = interfaceConfig.TOOLBAR_BUTTONS.includes('livestreaming') && abstractProps.visible;
100
     }
32
     }
101
 
33
 
102
     return {
34
     return {
103
         ...abstractProps,
35
         ...abstractProps,
104
-        _disabled,
105
-        _liveStreamDisabledTooltipKey,
106
         visible
36
         visible
107
     };
37
     };
108
 }
38
 }
109
 
39
 
110
-export default translate(connect(_mapStateToProps)(LiveStreamButton));
40
+export default translate(connect(_mapStateToProps)(AbstractLiveStreamButton));

+ 33
- 3
react/features/recording/components/Recording/AbstractRecordButton.js View File

5
     sendAnalytics
5
     sendAnalytics
6
 } from '../../../analytics';
6
 } from '../../../analytics';
7
 import { openDialog } from '../../../base/dialog';
7
 import { openDialog } from '../../../base/dialog';
8
+import { IconToggleRecording } from '../../../base/icons';
8
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
9
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
9
 import {
10
 import {
10
     getLocalParticipant,
11
     getLocalParticipant,
34
      */
35
      */
35
     _isRecordingRunning: boolean,
36
     _isRecordingRunning: boolean,
36
 
37
 
38
+    /**
39
+     * The tooltip to display when hovering over the button.
40
+     */
41
+    _tooltip: ?String,
42
+
37
     /**
43
     /**
38
      * The redux {@code dispatch} function.
44
      * The redux {@code dispatch} function.
39
      */
45
      */
48
 /**
54
 /**
49
  * An abstract implementation of a button for starting and stopping recording.
55
  * An abstract implementation of a button for starting and stopping recording.
50
  */
56
  */
51
-export default class AbstractRecordButton<P: Props>
52
-    extends AbstractButton<P, *> {
57
+export default class AbstractRecordButton<P: Props> extends AbstractButton<P, *> {
53
     accessibilityLabel = 'toolbar.accessibilityLabel.recording';
58
     accessibilityLabel = 'toolbar.accessibilityLabel.recording';
59
+    icon = IconToggleRecording;
54
     label = 'dialog.startRecording';
60
     label = 'dialog.startRecording';
55
     toggledLabel = 'dialog.stopRecording';
61
     toggledLabel = 'dialog.stopRecording';
56
 
62
 
63
+    /**
64
+     * Returns the tooltip that should be displayed when the button is disabled.
65
+     *
66
+     * @private
67
+     * @returns {string}
68
+     */
69
+    _getTooltip() {
70
+        return this.props._tooltip || '';
71
+    }
72
+
57
     /**
73
     /**
58
      * Handles clicking / pressing the button.
74
      * Handles clicking / pressing the button.
59
      *
75
      *
85
      * @returns {boolean}
101
      * @returns {boolean}
86
      */
102
      */
87
     _isDisabled() {
103
     _isDisabled() {
88
-        return false;
104
+        return this.props._disabled;
89
     }
105
     }
90
 
106
 
91
     /**
107
     /**
119
     // a button can be disabled/enabled if enableFeaturesBasedOnToken
135
     // a button can be disabled/enabled if enableFeaturesBasedOnToken
120
     // is on or if the livestreaming is running.
136
     // is on or if the livestreaming is running.
121
     let _disabled;
137
     let _disabled;
138
+    let _tooltip = '';
122
 
139
 
123
     if (typeof visible === 'undefined') {
140
     if (typeof visible === 'undefined') {
124
         // If the containing component provides the visible prop, that is one
141
         // If the containing component provides the visible prop, that is one
136
         if (enableFeaturesBasedOnToken) {
153
         if (enableFeaturesBasedOnToken) {
137
             visible = visible && String(features.recording) === 'true';
154
             visible = visible && String(features.recording) === 'true';
138
             _disabled = String(features.recording) === 'disabled';
155
             _disabled = String(features.recording) === 'disabled';
156
+            if (!visible && !_disabled) {
157
+                _disabled = true;
158
+                visible = true;
159
+
160
+                // button and tooltip
161
+                if (state['features/base/jwt'].isGuest) {
162
+                    _tooltip = 'dialog.recordingDisabledForGuestTooltip';
163
+                } else {
164
+                    _tooltip = 'dialog.recordingDisabledTooltip';
165
+                }
166
+            }
139
         }
167
         }
140
     }
168
     }
141
 
169
 
142
     // disable the button if the livestreaming is running.
170
     // disable the button if the livestreaming is running.
143
     if (getActiveSession(state, JitsiRecordingConstants.mode.STREAM)) {
171
     if (getActiveSession(state, JitsiRecordingConstants.mode.STREAM)) {
144
         _disabled = true;
172
         _disabled = true;
173
+        _tooltip = 'dialog.recordingDisabledBecauseOfActiveLiveStreamingTooltip';
145
     }
174
     }
146
 
175
 
147
     return {
176
     return {
148
         _disabled,
177
         _disabled,
149
         _isRecordingRunning: Boolean(getActiveSession(state, JitsiRecordingConstants.mode.FILE)),
178
         _isRecordingRunning: Boolean(getActiveSession(state, JitsiRecordingConstants.mode.FILE)),
179
+        _tooltip,
150
         visible
180
         visible
151
     };
181
     };
152
 }
182
 }

+ 2
- 13
react/features/recording/components/Recording/native/RecordButton.js View File

4
 
4
 
5
 import { IOS_RECORDING_ENABLED, RECORDING_ENABLED, getFeatureFlag } from '../../../../base/flags';
5
 import { IOS_RECORDING_ENABLED, RECORDING_ENABLED, getFeatureFlag } from '../../../../base/flags';
6
 import { translate } from '../../../../base/i18n';
6
 import { translate } from '../../../../base/i18n';
7
-import { IconToggleRecording } from '../../../../base/icons';
8
 import { connect } from '../../../../base/redux';
7
 import { connect } from '../../../../base/redux';
9
-import AbstractRecordButton, {
10
-    _mapStateToProps as _abstractMapStateToProps,
11
-    type Props
12
-} from '../AbstractRecordButton';
13
-
14
-/**
15
- * An implementation of a button for starting and stopping recording.
16
- */
17
-class RecordButton extends AbstractRecordButton<Props> {
18
-    icon = IconToggleRecording;
19
-}
8
+import AbstractRecordButton, { _mapStateToProps as _abstractMapStateToProps } from '../AbstractRecordButton';
20
 
9
 
21
 /**
10
 /**
22
  * Maps (parts of) the redux state to the associated props for this component.
11
  * Maps (parts of) the redux state to the associated props for this component.
38
     };
27
     };
39
 }
28
 }
40
 
29
 
41
-export default translate(connect(mapStateToProps)(RecordButton));
30
+export default translate(connect(mapStateToProps)(AbstractRecordButton));

+ 4
- 72
react/features/recording/components/Recording/web/RecordButton.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { translate } from '../../../../base/i18n';
3
 import { translate } from '../../../../base/i18n';
4
-import { IconToggleRecording } from '../../../../base/icons';
5
 import { connect } from '../../../../base/redux';
4
 import { connect } from '../../../../base/redux';
6
 import AbstractRecordButton, {
5
 import AbstractRecordButton, {
7
     _mapStateToProps as _abstractMapStateToProps,
6
     _mapStateToProps as _abstractMapStateToProps,
8
-    type Props as AbstractProps
7
+    type Props
9
 } from '../AbstractRecordButton';
8
 } from '../AbstractRecordButton';
10
 
9
 
11
 declare var interfaceConfig: Object;
10
 declare var interfaceConfig: Object;
12
 
11
 
13
-type Props = AbstractProps & {
14
-
15
-    /**
16
-     * True if the button should be disabled, false otherwise.
17
-     *
18
-     * NOTE: On web, if the feature is not disabled on purpose, then we still
19
-     * show the button but disabled and with a tooltip rendered on it,
20
-     * explaining why it's not available.
21
-     */
22
-    _disabled: boolean,
23
-
24
-    /**
25
-     * Tooltip for the button when it's disabled in a certain way.
26
-     */
27
-    _fileRecordingsDisabledTooltipKey: ?string
28
-}
29
-
30
-/**
31
- * An implementation of a button for starting and stopping recording.
32
- */
33
-class RecordButton extends AbstractRecordButton<Props> {
34
-    icon = IconToggleRecording;
35
-
36
-    /**
37
-     * Returns the tooltip that should be displayed when the button is disabled.
38
-     *
39
-     * @private
40
-     * @returns {string}
41
-     */
42
-    _getTooltip() {
43
-        return this.props._fileRecordingsDisabledTooltipKey || '';
44
-    }
45
-
46
-    /**
47
-     * Helper function to be implemented by subclasses, which must return a
48
-     * boolean value indicating if this button is disabled or not.
49
-     *
50
-     * @override
51
-     * @protected
52
-     * @returns {boolean}
53
-     */
54
-    _isDisabled() {
55
-        return this.props._disabled;
56
-    }
57
-}
58
-
59
 /**
12
 /**
60
  * Maps (parts of) the redux state to the associated props for the
13
  * Maps (parts of) the redux state to the associated props for the
61
  * {@code RecordButton} component.
14
  * {@code RecordButton} component.
74
     const abstractProps = _abstractMapStateToProps(state, ownProps);
27
     const abstractProps = _abstractMapStateToProps(state, ownProps);
75
     let { visible } = ownProps;
28
     let { visible } = ownProps;
76
 
29
 
77
-    let { _disabled } = abstractProps;
78
-    let _fileRecordingsDisabledTooltipKey;
79
-
80
-    if (!abstractProps.visible && _disabled !== undefined && !_disabled) {
81
-        _disabled = true;
82
-
83
-        // button and tooltip
84
-        if (state['features/base/jwt'].isGuest) {
85
-            _fileRecordingsDisabledTooltipKey = 'dialog.recordingDisabledForGuestTooltip';
86
-        } else {
87
-            _fileRecordingsDisabledTooltipKey = 'dialog.recordingDisabledTooltip';
88
-        }
89
-    } else if (_disabled) {
90
-        _fileRecordingsDisabledTooltipKey = 'dialog.recordingDisabledBecauseOfActiveLiveStreamingTooltip';
91
-    } else {
92
-        _disabled = false;
93
-    }
94
-
95
     if (typeof visible === 'undefined') {
30
     if (typeof visible === 'undefined') {
96
-        visible = interfaceConfig.TOOLBAR_BUTTONS.includes('recording')
97
-            && (abstractProps.visible || Boolean(_fileRecordingsDisabledTooltipKey));
31
+        visible = interfaceConfig.TOOLBAR_BUTTONS.includes('recording') && abstractProps.visible;
98
     }
32
     }
99
 
33
 
100
     return {
34
     return {
101
         ...abstractProps,
35
         ...abstractProps,
102
-        visible,
103
-        _disabled,
104
-        _fileRecordingsDisabledTooltipKey
36
+        visible
105
     };
37
     };
106
 }
38
 }
107
 
39
 
108
-export default translate(connect(_mapStateToProps)(RecordButton));
40
+export default translate(connect(_mapStateToProps)(AbstractRecordButton));

Loading…
Cancel
Save