Parcourir la source

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
Дамян Минков il y a 7 ans
Parent
révision
fd30481ac2

+ 11
- 3
react/features/recording/components/LiveStream/AbstractLiveStreamButton.js Voir le fichier

@@ -109,6 +109,10 @@ export default class AbstractLiveStreamButton<P: Props>
109 109
 export function _mapStateToProps(state: Object, ownProps: Props) {
110 110
     let { visible } = ownProps;
111 111
 
112
+    // a button can be disabled/enabled only if enableFeaturesBasedOnToken
113
+    // is on
114
+    let disabledByFeatures;
115
+
112 116
     if (typeof visible === 'undefined') {
113 117
         // If the containing component provides the visible prop, that is one
114 118
         // above all, but if not, the button should be autonomus and decide on
@@ -119,14 +123,18 @@ export function _mapStateToProps(state: Object, ownProps: Props) {
119 123
         } = state['features/base/config'];
120 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 134
     return {
128 135
         _isLiveStreamRunning: Boolean(
129 136
             getActiveSession(state, JitsiRecordingConstants.mode.STREAM)),
137
+        disabledByFeatures,
130 138
         visible
131 139
     };
132 140
 }

+ 4
- 5
react/features/recording/components/LiveStream/LiveStreamButton.web.js Voir le fichier

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

+ 10
- 2
react/features/recording/components/Recording/AbstractRecordButton.js Voir le fichier

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

+ 4
- 5
react/features/recording/components/Recording/RecordButton.web.js Voir le fichier

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

Chargement…
Annuler
Enregistrer