瀏覽代碼

Disable buttons only when token features is enabled. Fixes #3355. (#3443)

* Disable buttons only when token features is enabled. Fixes #3355.

* squash: update disabled check.

* squash: update disabled and disabledByFeatures.
master
Дамян Минков 7 年之前
父節點
當前提交
fd30481ac2

+ 11
- 3
react/features/recording/components/LiveStream/AbstractLiveStreamButton.js 查看文件

109
 export function _mapStateToProps(state: Object, ownProps: Props) {
109
 export function _mapStateToProps(state: Object, ownProps: Props) {
110
     let { visible } = ownProps;
110
     let { visible } = ownProps;
111
 
111
 
112
+    // a button can be disabled/enabled only if enableFeaturesBasedOnToken
113
+    // is on
114
+    let disabledByFeatures;
115
+
112
     if (typeof visible === 'undefined') {
116
     if (typeof visible === 'undefined') {
113
         // If the containing component provides the visible prop, that is one
117
         // If the containing component provides the visible prop, that is one
114
         // above all, but if not, the button should be autonomus and decide on
118
         // above all, but if not, the button should be autonomus and decide on
119
         } = state['features/base/config'];
123
         } = state['features/base/config'];
120
         const { features = {} } = getLocalParticipant(state);
124
         const { features = {} } = getLocalParticipant(state);
121
 
125
 
122
-        visible = liveStreamingEnabled
123
-            && (!enableFeaturesBasedOnToken
124
-                || String(features.livestreaming) === 'true');
126
+        visible = liveStreamingEnabled;
127
+
128
+        if (enableFeaturesBasedOnToken) {
129
+            visible = visible && String(features.livestreaming) === 'true';
130
+            disabledByFeatures = String(features.livestreaming) === 'disabled';
131
+        }
125
     }
132
     }
126
 
133
 
127
     return {
134
     return {
128
         _isLiveStreamRunning: Boolean(
135
         _isLiveStreamRunning: Boolean(
129
             getActiveSession(state, JitsiRecordingConstants.mode.STREAM)),
136
             getActiveSession(state, JitsiRecordingConstants.mode.STREAM)),
137
+        disabledByFeatures,
130
         visible
138
         visible
131
     };
139
     };
132
 }
140
 }

+ 4
- 5
react/features/recording/components/LiveStream/LiveStreamButton.web.js 查看文件

3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 
4
 
5
 import { translate } from '../../../base/i18n';
5
 import { translate } from '../../../base/i18n';
6
-import { getLocalParticipant } from '../../../base/participants';
7
 
6
 
8
 import AbstractLiveStreamButton, {
7
 import AbstractLiveStreamButton, {
9
     _mapStateToProps as _abstractMapStateToProps,
8
     _mapStateToProps as _abstractMapStateToProps,
85
  */
84
  */
86
 function _mapStateToProps(state: Object, ownProps: Props) {
85
 function _mapStateToProps(state: Object, ownProps: Props) {
87
     const abstractProps = _abstractMapStateToProps(state, ownProps);
86
     const abstractProps = _abstractMapStateToProps(state, ownProps);
88
-    const localParticipant = getLocalParticipant(state);
89
-    const { features = {} } = localParticipant;
90
     let { visible } = ownProps;
87
     let { visible } = ownProps;
91
 
88
 
89
+    const _disabledByFeatures = abstractProps.disabledByFeatures;
92
     let _disabled = false;
90
     let _disabled = false;
93
     let _liveStreamDisabledTooltipKey;
91
     let _liveStreamDisabledTooltipKey;
94
 
92
 
95
     if (!abstractProps.visible
93
     if (!abstractProps.visible
96
-            && String(features.livestreaming) !== 'disabled') {
94
+            && _disabledByFeatures !== undefined && !_disabledByFeatures) {
97
         _disabled = true;
95
         _disabled = true;
98
 
96
 
99
         // button and tooltip
97
         // button and tooltip
108
 
106
 
109
     if (typeof visible === 'undefined') {
107
     if (typeof visible === 'undefined') {
110
         visible = interfaceConfig.TOOLBAR_BUTTONS.includes('livestreaming')
108
         visible = interfaceConfig.TOOLBAR_BUTTONS.includes('livestreaming')
111
-            && (abstractProps.visible || _liveStreamDisabledTooltipKey);
109
+            && (abstractProps.visible
110
+                    || Boolean(_liveStreamDisabledTooltipKey));
112
     }
111
     }
113
 
112
 
114
     return {
113
     return {

+ 10
- 2
react/features/recording/components/Recording/AbstractRecordButton.js 查看文件

113
 export function _mapStateToProps(state: Object, ownProps: Props): Object {
113
 export function _mapStateToProps(state: Object, ownProps: Props): Object {
114
     let { visible } = ownProps;
114
     let { visible } = ownProps;
115
 
115
 
116
+    // a button can be disabled/enabled only if enableFeaturesBasedOnToken
117
+    // is on
118
+    let disabledByFeatures;
119
+
116
     if (typeof visible === 'undefined') {
120
     if (typeof visible === 'undefined') {
117
         // If the containing component provides the visible prop, that is one
121
         // If the containing component provides the visible prop, that is one
118
         // above all, but if not, the button should be autonomus and decide on
122
         // above all, but if not, the button should be autonomus and decide on
127
 
131
 
128
         visible = isModerator
132
         visible = isModerator
129
             && fileRecordingsEnabled
133
             && fileRecordingsEnabled
130
-            && (!enableFeaturesBasedOnToken
131
-                || String(features.recording) === 'true')
132
             && typeof dropbox.clientId === 'string';
134
             && typeof dropbox.clientId === 'string';
135
+
136
+        if (enableFeaturesBasedOnToken) {
137
+            visible = visible && String(features.recording) === 'true';
138
+            disabledByFeatures = String(features.recording) === 'disabled';
139
+        }
133
     }
140
     }
134
 
141
 
135
     return {
142
     return {
136
         _isRecordingRunning:
143
         _isRecordingRunning:
137
             Boolean(getActiveSession(state, JitsiRecordingConstants.mode.FILE)),
144
             Boolean(getActiveSession(state, JitsiRecordingConstants.mode.FILE)),
145
+        disabledByFeatures,
138
         visible
146
         visible
139
     };
147
     };
140
 }
148
 }

+ 4
- 5
react/features/recording/components/Recording/RecordButton.web.js 查看文件

3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 
4
 
5
 import { translate } from '../../../base/i18n';
5
 import { translate } from '../../../base/i18n';
6
-import { getLocalParticipant } from '../../../base/participants';
7
 
6
 
8
 import AbstractRecordButton, {
7
 import AbstractRecordButton, {
9
     _mapStateToProps as _abstractMapStateToProps,
8
     _mapStateToProps as _abstractMapStateToProps,
85
  */
84
  */
86
 export function _mapStateToProps(state: Object, ownProps: Props): Object {
85
 export function _mapStateToProps(state: Object, ownProps: Props): Object {
87
     const abstractProps = _abstractMapStateToProps(state, ownProps);
86
     const abstractProps = _abstractMapStateToProps(state, ownProps);
88
-    const localParticipant = getLocalParticipant(state);
89
-    const { features = {} } = localParticipant;
90
     let { visible } = ownProps;
87
     let { visible } = ownProps;
91
 
88
 
89
+    const _disabledByFeatures = abstractProps.disabledByFeatures;
92
     let _disabled = false;
90
     let _disabled = false;
93
     let _fileRecordingsDisabledTooltipKey;
91
     let _fileRecordingsDisabledTooltipKey;
94
 
92
 
95
     if (!abstractProps.visible
93
     if (!abstractProps.visible
96
-            && String(features.recording) !== 'disabled') {
94
+            && _disabledByFeatures !== undefined && !_disabledByFeatures) {
97
         _disabled = true;
95
         _disabled = true;
98
 
96
 
99
         // button and tooltip
97
         // button and tooltip
108
 
106
 
109
     if (typeof visible === 'undefined') {
107
     if (typeof visible === 'undefined') {
110
         visible = interfaceConfig.TOOLBAR_BUTTONS.includes('recording')
108
         visible = interfaceConfig.TOOLBAR_BUTTONS.includes('recording')
111
-            && (abstractProps.visible || _fileRecordingsDisabledTooltipKey);
109
+            && (abstractProps.visible
110
+                    || Boolean(_fileRecordingsDisabledTooltipKey));
112
     }
111
     }
113
 
112
 
114
     return {
113
     return {

Loading…
取消
儲存