瀏覽代碼

fix(participants-pane): Use selector for displaying chat context item

master
Gabriel Imre 4 年之前
父節點
當前提交
db5d6a56b8

+ 11
- 0
react/features/base/config/functions.web.js 查看文件

44
 
44
 
45
     return Array.isArray(toolbarButtons) ? toolbarButtons : TOOLBAR_BUTTONS;
45
     return Array.isArray(toolbarButtons) ? toolbarButtons : TOOLBAR_BUTTONS;
46
 }
46
 }
47
+
48
+/**
49
+ * Curried selector to check if the specified button is enabled.
50
+ *
51
+ * @param {string} buttonName - The name of the button.
52
+ * {@link interfaceConfig}.
53
+ * @returns {Function} - Selector that returns a boolean.
54
+ */
55
+export const isToolbarButtonEnabled = (buttonName: string) =>
56
+    (state: Object): boolean =>
57
+        getToolbarButtons(state).includes(buttonName);

+ 8
- 4
react/features/participants-pane/components/MeetingParticipantContextMenu.js 查看文件

4
 import { useTranslation } from 'react-i18next';
4
 import { useTranslation } from 'react-i18next';
5
 import { useDispatch, useSelector } from 'react-redux';
5
 import { useDispatch, useSelector } from 'react-redux';
6
 
6
 
7
+import { isToolbarButtonEnabled } from '../../base/config/functions.web';
7
 import { openDialog } from '../../base/dialog';
8
 import { openDialog } from '../../base/dialog';
8
 import {
9
 import {
9
     IconCloseCircle,
10
     IconCloseCircle,
65
     const dispatch = useDispatch();
66
     const dispatch = useDispatch();
66
     const containerRef = useRef(null);
67
     const containerRef = useRef(null);
67
     const isLocalModerator = useSelector(isLocalParticipantModerator);
68
     const isLocalModerator = useSelector(isLocalParticipantModerator);
69
+    const isChatButtonEnabled = useSelector(isToolbarButtonEnabled('chat'));
68
     const isParticipantVideoMuted = useSelector(getIsParticipantVideoMuted(participant));
70
     const isParticipantVideoMuted = useSelector(getIsParticipantVideoMuted(participant));
69
     const [ isHidden, setIsHidden ] = useState(true);
71
     const [ isHidden, setIsHidden ] = useState(true);
70
     const { t } = useTranslation();
72
     const { t } = useTranslation();
156
                         <span>{t('videothumbnail.kick')}</span>
158
                         <span>{t('videothumbnail.kick')}</span>
157
                     </ContextMenuItem>
159
                     </ContextMenuItem>
158
                 )}
160
                 )}
159
-                <ContextMenuItem onClick = { sendPrivateMessage }>
160
-                    <ContextMenuIcon src = { IconMessage } />
161
-                    <span>{t('toolbar.accessibilityLabel.privateMessage')}</span>
162
-                </ContextMenuItem>
161
+                {isChatButtonEnabled && (
162
+                    <ContextMenuItem onClick = { sendPrivateMessage }>
163
+                        <ContextMenuIcon src = { IconMessage } />
164
+                        <span>{t('toolbar.accessibilityLabel.privateMessage')}</span>
165
+                    </ContextMenuItem>
166
+                )}
163
             </ContextMenuItemGroup>
167
             </ContextMenuItemGroup>
164
         </ContextMenu>
168
         </ContextMenu>
165
     );
169
     );

+ 44
- 51
react/features/toolbox/components/web/Toolbox.js 查看文件

9
     sendAnalytics
9
     sendAnalytics
10
 } from '../../../analytics';
10
 } from '../../../analytics';
11
 import { getToolbarButtons } from '../../../base/config';
11
 import { getToolbarButtons } from '../../../base/config';
12
+import { isToolbarButtonEnabled } from '../../../base/config/functions.web';
12
 import { openDialog, toggleDialog } from '../../../base/dialog';
13
 import { openDialog, toggleDialog } from '../../../base/dialog';
13
 import { isMobileBrowser } from '../../../base/environment/utils';
14
 import { isMobileBrowser } from '../../../base/environment/utils';
14
 import { translate } from '../../../base/i18n';
15
 import { translate } from '../../../base/i18n';
212
      */
213
      */
213
     _visibleButtons: Array<string>,
214
     _visibleButtons: Array<string>,
214
 
215
 
216
+    /**
217
+     * Handler to check if a button is enabled.
218
+     */
219
+     _shouldShowButton: Function,
220
+
215
     /**
221
     /**
216
      * Invoked to active other features of the app.
222
      * Invoked to active other features of the app.
217
      */
223
      */
276
      */
282
      */
277
     componentDidMount() {
283
     componentDidMount() {
278
         const KEYBOARD_SHORTCUTS = [
284
         const KEYBOARD_SHORTCUTS = [
279
-            this._shouldShowButton('videoquality') && {
285
+            this.props._shouldShowButton('videoquality') && {
280
                 character: 'A',
286
                 character: 'A',
281
                 exec: this._onShortcutToggleVideoQuality,
287
                 exec: this._onShortcutToggleVideoQuality,
282
                 helpDescription: 'toolbar.callQuality'
288
                 helpDescription: 'toolbar.callQuality'
283
             },
289
             },
284
-            this._shouldShowButton('chat') && {
290
+            this.props._shouldShowButton('chat') && {
285
                 character: 'C',
291
                 character: 'C',
286
                 exec: this._onShortcutToggleChat,
292
                 exec: this._onShortcutToggleChat,
287
                 helpDescription: 'keyboardShortcuts.toggleChat'
293
                 helpDescription: 'keyboardShortcuts.toggleChat'
288
             },
294
             },
289
-            this._shouldShowButton('desktop') && {
295
+            this.props._shouldShowButton('desktop') && {
290
                 character: 'D',
296
                 character: 'D',
291
                 exec: this._onShortcutToggleScreenshare,
297
                 exec: this._onShortcutToggleScreenshare,
292
                 helpDescription: 'keyboardShortcuts.toggleScreensharing'
298
                 helpDescription: 'keyboardShortcuts.toggleScreensharing'
293
             },
299
             },
294
-            this._shouldShowButton('participants-pane') && {
300
+            this.props._shouldShowButton('participants-pane') && {
295
                 character: 'P',
301
                 character: 'P',
296
                 exec: this._onShortcutToggleParticipantsPane,
302
                 exec: this._onShortcutToggleParticipantsPane,
297
                 helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
303
                 helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
298
             },
304
             },
299
-            this._shouldShowButton('raisehand') && {
305
+            this.props._shouldShowButton('raisehand') && {
300
                 character: 'R',
306
                 character: 'R',
301
                 exec: this._onShortcutToggleRaiseHand,
307
                 exec: this._onShortcutToggleRaiseHand,
302
                 helpDescription: 'keyboardShortcuts.raiseHand'
308
                 helpDescription: 'keyboardShortcuts.raiseHand'
303
             },
309
             },
304
-            this._shouldShowButton('fullscreen') && {
310
+            this.props._shouldShowButton('fullscreen') && {
305
                 character: 'S',
311
                 character: 'S',
306
                 exec: this._onShortcutToggleFullScreen,
312
                 exec: this._onShortcutToggleFullScreen,
307
                 helpDescription: 'keyboardShortcuts.fullScreen'
313
                 helpDescription: 'keyboardShortcuts.fullScreen'
308
             },
314
             },
309
-            this._shouldShowButton('tileview') && {
315
+            this.props._shouldShowButton('tileview') && {
310
                 character: 'W',
316
                 character: 'W',
311
                 exec: this._onShortcutToggleTileView,
317
                 exec: this._onShortcutToggleTileView,
312
                 helpDescription: 'toolbar.tileViewToggle'
318
                 helpDescription: 'toolbar.tileViewToggle'
943
         return (
949
         return (
944
             (_desktopSharingEnabled
950
             (_desktopSharingEnabled
945
             || _desktopSharingDisabledTooltipKey)
951
             || _desktopSharingDisabledTooltipKey)
946
-            && this._shouldShowButton('desktop')
952
+            && this.props._shouldShowButton('desktop')
947
         );
953
         );
948
     }
954
     }
949
 
955
 
955
     _isEmbedMeetingVisible() {
961
     _isEmbedMeetingVisible() {
956
         return !this.props._isVpaasMeeting
962
         return !this.props._isVpaasMeeting
957
             && !this.props._isMobile
963
             && !this.props._isMobile
958
-            && this._shouldShowButton('embedmeeting');
964
+            && this.props._shouldShowButton('embedmeeting');
959
     }
965
     }
960
 
966
 
961
     /**
967
     /**
964
      * @returns {boolean}
970
      * @returns {boolean}
965
      */
971
      */
966
     _isProfileVisible() {
972
     _isProfileVisible() {
967
-        return !this.props._isProfileDisabled && this._shouldShowButton('profile');
973
+        return !this.props._isProfileDisabled && this.props._shouldShowButton('profile');
968
     }
974
     }
969
 
975
 
970
     /**
976
     /**
987
         const group1 = [
993
         const group1 = [
988
             ...additionalButtons,
994
             ...additionalButtons,
989
 
995
 
990
-            this._shouldShowButton('toggle-camera')
996
+            this.props._shouldShowButton('toggle-camera')
991
                 && <ToggleCameraButton
997
                 && <ToggleCameraButton
992
                     key = 'toggle-camera'
998
                     key = 'toggle-camera'
993
                     showLabel = { true } />,
999
                     showLabel = { true } />,
994
-            this._shouldShowButton('videoquality')
1000
+            this.props._shouldShowButton('videoquality')
995
                 && <OverflowMenuVideoQualityItem
1001
                 && <OverflowMenuVideoQualityItem
996
                     key = 'videoquality'
1002
                     key = 'videoquality'
997
                     onClick = { this._onToolbarOpenVideoQuality } />,
1003
                     onClick = { this._onToolbarOpenVideoQuality } />,
998
-            this._shouldShowButton('fullscreen')
1004
+            this.props._shouldShowButton('fullscreen')
999
                 && !_isMobile
1005
                 && !_isMobile
1000
                 && <OverflowMenuItem
1006
                 && <OverflowMenuItem
1001
                     accessibilityLabel = { t('toolbar.accessibilityLabel.fullScreen') }
1007
                     accessibilityLabel = { t('toolbar.accessibilityLabel.fullScreen') }
1003
                     key = 'fullscreen'
1009
                     key = 'fullscreen'
1004
                     onClick = { this._onToolbarToggleFullScreen }
1010
                     onClick = { this._onToolbarToggleFullScreen }
1005
                     text = { _fullScreen ? t('toolbar.exitFullScreen') : t('toolbar.enterFullScreen') } />,
1011
                     text = { _fullScreen ? t('toolbar.exitFullScreen') : t('toolbar.enterFullScreen') } />,
1006
-            (this._shouldShowButton('security') || this._shouldShowButton('info'))
1012
+            (this.props._shouldShowButton('security') || this.props._shouldShowButton('info'))
1007
             && <SecurityDialogButton
1013
             && <SecurityDialogButton
1008
                 key = 'security'
1014
                 key = 'security'
1009
                 showLabel = { true } />,
1015
                 showLabel = { true } />,
1010
-            this._shouldShowButton('closedcaptions')
1016
+            this.props._shouldShowButton('closedcaptions')
1011
             && <ClosedCaptionButton
1017
             && <ClosedCaptionButton
1012
                 key = 'closed-captions'
1018
                 key = 'closed-captions'
1013
                 showLabel = { true } />,
1019
                 showLabel = { true } />,
1014
-            this._shouldShowButton('recording')
1020
+            this.props._shouldShowButton('recording')
1015
                 && <RecordButton
1021
                 && <RecordButton
1016
                     key = 'record'
1022
                     key = 'record'
1017
                     showLabel = { true } />,
1023
                     showLabel = { true } />,
1018
-            this._shouldShowButton('localrecording')
1024
+            this.props._shouldShowButton('localrecording')
1019
                 && <OverflowMenuItem
1025
                 && <OverflowMenuItem
1020
                     accessibilityLabel = { t('toolbar.accessibilityLabel.localRecording') }
1026
                     accessibilityLabel = { t('toolbar.accessibilityLabel.localRecording') }
1021
                     icon = { IconRec }
1027
                     icon = { IconRec }
1022
                     key = 'localrecording'
1028
                     key = 'localrecording'
1023
                     onClick = { this._onToolbarOpenLocalRecordingInfoDialog }
1029
                     onClick = { this._onToolbarOpenLocalRecordingInfoDialog }
1024
                     text = { t('localRecording.dialogTitle') } />,
1030
                     text = { t('localRecording.dialogTitle') } />,
1025
-            this._shouldShowButton('mute-everyone')
1031
+            this.props._shouldShowButton('mute-everyone')
1026
                 && <MuteEveryoneButton
1032
                 && <MuteEveryoneButton
1027
                     key = 'mute-everyone'
1033
                     key = 'mute-everyone'
1028
                     showLabel = { true } />,
1034
                     showLabel = { true } />,
1029
-            this._shouldShowButton('mute-video-everyone')
1035
+            this.props._shouldShowButton('mute-video-everyone')
1030
                 && <MuteEveryonesVideoButton
1036
                 && <MuteEveryonesVideoButton
1031
                     key = 'mute-everyones-video'
1037
                     key = 'mute-everyones-video'
1032
                     showLabel = { true } />,
1038
                     showLabel = { true } />,
1033
-            this._shouldShowButton('livestreaming')
1039
+            this.props._shouldShowButton('livestreaming')
1034
                 && <LiveStreamButton
1040
                 && <LiveStreamButton
1035
                     key = 'livestreaming'
1041
                     key = 'livestreaming'
1036
                     showLabel = { true } />
1042
                     showLabel = { true } />
1037
         ];
1043
         ];
1038
 
1044
 
1039
         const group2 = [
1045
         const group2 = [
1040
-            this._shouldShowButton('sharedvideo')
1046
+            this.props._shouldShowButton('sharedvideo')
1041
                 && <SharedVideoButton
1047
                 && <SharedVideoButton
1042
                     key = 'sharedvideo'
1048
                     key = 'sharedvideo'
1043
                     showLabel = { true } />,
1049
                     showLabel = { true } />,
1044
-            this._shouldShowButton('shareaudio')
1050
+            this.props._shouldShowButton('shareaudio')
1045
                 && _desktopSharingEnabled
1051
                 && _desktopSharingEnabled
1046
                 && isScreenAudioSupported()
1052
                 && isScreenAudioSupported()
1047
                 && <OverflowMenuItem
1053
                 && <OverflowMenuItem
1050
                     key = 'shareaudio'
1056
                     key = 'shareaudio'
1051
                     onClick = { this._onToolbarToggleShareAudio }
1057
                     onClick = { this._onToolbarToggleShareAudio }
1052
                     text = { t('toolbar.shareaudio') } />,
1058
                     text = { t('toolbar.shareaudio') } />,
1053
-            this._shouldShowButton('etherpad')
1059
+            this.props._shouldShowButton('etherpad')
1054
                 && <SharedDocumentButton
1060
                 && <SharedDocumentButton
1055
                     key = 'etherpad'
1061
                     key = 'etherpad'
1056
                     showLabel = { true } />,
1062
                     showLabel = { true } />,
1057
-            (this._shouldShowButton('select-background') || this._shouldShowButton('videobackgroundblur'))
1063
+            (this.props._shouldShowButton('select-background') || this.props._shouldShowButton('videobackgroundblur'))
1058
                 && <VideoBackgroundButton
1064
                 && <VideoBackgroundButton
1059
                     key = { 'select-background' }
1065
                     key = { 'select-background' }
1060
                     showLabel = { true }
1066
                     showLabel = { true }
1061
                     visible = { !_screensharing && checkBlurSupport() } />,
1067
                     visible = { !_screensharing && checkBlurSupport() } />,
1062
-            this._shouldShowButton('stats')
1068
+            this.props._shouldShowButton('stats')
1063
                 && <OverflowMenuItem
1069
                 && <OverflowMenuItem
1064
                     accessibilityLabel = { t('toolbar.accessibilityLabel.speakerStats') }
1070
                     accessibilityLabel = { t('toolbar.accessibilityLabel.speakerStats') }
1065
                     icon = { IconPresentation }
1071
                     icon = { IconPresentation }
1091
                 className = 'overflow-menu-hr'
1097
                 className = 'overflow-menu-hr'
1092
                 key = 'hr3' />,
1098
                 key = 'hr3' />,
1093
 
1099
 
1094
-            this._shouldShowButton('settings')
1100
+            this.props._shouldShowButton('settings')
1095
                 && <SettingsButton
1101
                 && <SettingsButton
1096
                     key = 'settings'
1102
                     key = 'settings'
1097
                     showLabel = { true } />,
1103
                     showLabel = { true } />,
1098
-            this._shouldShowButton('shortcuts')
1104
+            this.props._shouldShowButton('shortcuts')
1099
                 && !_isMobile
1105
                 && !_isMobile
1100
                 && <OverflowMenuItem
1106
                 && <OverflowMenuItem
1101
                     accessibilityLabel = { t('toolbar.accessibilityLabel.shortcuts') }
1107
                     accessibilityLabel = { t('toolbar.accessibilityLabel.shortcuts') }
1110
                     key = 'embed'
1116
                     key = 'embed'
1111
                     onClick = { this._onToolbarOpenEmbedMeeting }
1117
                     onClick = { this._onToolbarOpenEmbedMeeting }
1112
                     text = { t('toolbar.embedMeeting') } />,
1118
                     text = { t('toolbar.embedMeeting') } />,
1113
-            this._shouldShowButton('feedback')
1119
+            this.props._shouldShowButton('feedback')
1114
                 && _feedbackConfigured
1120
                 && _feedbackConfigured
1115
                 && <OverflowMenuItem
1121
                 && <OverflowMenuItem
1116
                     accessibilityLabel = { t('toolbar.accessibilityLabel.feedback') }
1122
                     accessibilityLabel = { t('toolbar.accessibilityLabel.feedback') }
1118
                     key = 'feedback'
1124
                     key = 'feedback'
1119
                     onClick = { this._onToolbarOpenFeedback }
1125
                     onClick = { this._onToolbarOpenFeedback }
1120
                     text = { t('toolbar.feedback') } />,
1126
                     text = { t('toolbar.feedback') } />,
1121
-            this._shouldShowButton('download')
1127
+            this.props._shouldShowButton('download')
1122
                 && <DownloadButton
1128
                 && <DownloadButton
1123
                     key = 'download'
1129
                     key = 'download'
1124
                     showLabel = { true } />,
1130
                     showLabel = { true } />,
1125
-            this._shouldShowButton('help')
1131
+            this.props._shouldShowButton('help')
1126
                 && <HelpButton
1132
                 && <HelpButton
1127
                     key = 'help'
1133
                     key = 'help'
1128
                     showLabel = { true } />
1134
                     showLabel = { true } />
1169
                     text = { t(`toolbar.${_screensharing ? 'stopScreenSharing' : 'startScreenSharing'}`) } />);
1175
                     text = { t(`toolbar.${_screensharing ? 'stopScreenSharing' : 'startScreenSharing'}`) } />);
1170
         }
1176
         }
1171
 
1177
 
1172
-        if (this._shouldShowButton('chat')) {
1178
+        if (this.props._shouldShowButton('chat')) {
1173
             buttons.has('chat')
1179
             buttons.has('chat')
1174
                 ? mainMenuAdditionalButtons.push(<div
1180
                 ? mainMenuAdditionalButtons.push(<div
1175
                     className = 'toolbar-button-with-badge'
1181
                     className = 'toolbar-button-with-badge'
1190
                     text = { t(`toolbar.${_chatOpen ? 'closeChat' : 'openChat'}`) } />);
1196
                     text = { t(`toolbar.${_chatOpen ? 'closeChat' : 'openChat'}`) } />);
1191
         }
1197
         }
1192
 
1198
 
1193
-        if (this._shouldShowButton('raisehand')) {
1199
+        if (this.props._shouldShowButton('raisehand')) {
1194
             buttons.has('raisehand')
1200
             buttons.has('raisehand')
1195
                 ? mainMenuAdditionalButtons.push(<ToolbarButton
1201
                 ? mainMenuAdditionalButtons.push(<ToolbarButton
1196
                     accessibilityLabel = { t('toolbar.accessibilityLabel.raiseHand') }
1202
                     accessibilityLabel = { t('toolbar.accessibilityLabel.raiseHand') }
1207
                     text = { t(`toolbar.${_raisedHand ? 'lowerYourHand' : 'raiseYourHand'}`) } />);
1213
                     text = { t(`toolbar.${_raisedHand ? 'lowerYourHand' : 'raiseYourHand'}`) } />);
1208
         }
1214
         }
1209
 
1215
 
1210
-        if (this._shouldShowButton('participants-pane') || this._shouldShowButton('invite')) {
1216
+        if (this.props._shouldShowButton('participants-pane') || this.props._shouldShowButton('invite')) {
1211
             buttons.has('participants-pane')
1217
             buttons.has('participants-pane')
1212
                 ? mainMenuAdditionalButtons.push(
1218
                 ? mainMenuAdditionalButtons.push(
1213
                     <ToolbarButton
1219
                     <ToolbarButton
1226
                 );
1232
                 );
1227
         }
1233
         }
1228
 
1234
 
1229
-        if (this._shouldShowButton('tileview')) {
1235
+        if (this.props._shouldShowButton('tileview')) {
1230
             buttons.has('tileview')
1236
             buttons.has('tileview')
1231
                 ? mainMenuAdditionalButtons.push(
1237
                 ? mainMenuAdditionalButtons.push(
1232
                     <TileViewButton
1238
                     <TileViewButton
1250
      * @returns {ReactElement}
1256
      * @returns {ReactElement}
1251
      */
1257
      */
1252
     _renderAudioButton() {
1258
     _renderAudioButton() {
1253
-        return this._shouldShowButton('microphone')
1259
+        return this.props._shouldShowButton('microphone')
1254
             ? <AudioSettingsButton
1260
             ? <AudioSettingsButton
1255
                 key = 'asb'
1261
                 key = 'asb'
1256
                 visible = { true } />
1262
                 visible = { true } />
1263
      * @returns {ReactElement}
1269
      * @returns {ReactElement}
1264
      */
1270
      */
1265
     _renderVideoButton() {
1271
     _renderVideoButton() {
1266
-        return this._shouldShowButton('camera')
1272
+        return this.props._shouldShowButton('camera')
1267
             ? <VideoSettingsButton
1273
             ? <VideoSettingsButton
1268
                 key = 'vsb'
1274
                 key = 'vsb'
1269
                 visible = { true } />
1275
                 visible = { true } />
1317
                         </OverflowMenuButton>}
1323
                         </OverflowMenuButton>}
1318
                         <HangupButton
1324
                         <HangupButton
1319
                             customClass = 'hangup-button'
1325
                             customClass = 'hangup-button'
1320
-                            visible = { this._shouldShowButton('hangup') } />
1326
+                            visible = { this.props._shouldShowButton('hangup') } />
1321
                     </div>
1327
                     </div>
1322
                 </div>
1328
                 </div>
1323
             </div>
1329
             </div>
1324
         );
1330
         );
1325
     }
1331
     }
1326
-
1327
-    _shouldShowButton: (string) => boolean;
1328
-
1329
-    /**
1330
-     * Returns if a button name has been explicitly configured to be displayed.
1331
-     *
1332
-     * @param {string} buttonName - The name of the button, as expected in
1333
-     * {@link interfaceConfig}.
1334
-     * @private
1335
-     * @returns {boolean} True if the button should be displayed.
1336
-     */
1337
-    _shouldShowButton(buttonName) {
1338
-        return this.props._visibleButtons.includes(buttonName);
1339
-    }
1340
 }
1332
 }
1341
 
1333
 
1342
 /**
1334
 /**
1394
         _participantsPaneOpen: getParticipantsPaneOpen(state),
1386
         _participantsPaneOpen: getParticipantsPaneOpen(state),
1395
         _raisedHand: localParticipant.raisedHand,
1387
         _raisedHand: localParticipant.raisedHand,
1396
         _screensharing: (localVideo && localVideo.videoType === 'desktop') || isScreenAudioShared(state),
1388
         _screensharing: (localVideo && localVideo.videoType === 'desktop') || isScreenAudioShared(state),
1389
+        _shouldShowButton: buttonName => isToolbarButtonEnabled(buttonName)(state),
1397
         _visible: isToolboxVisible(state),
1390
         _visible: isToolboxVisible(state),
1398
         _visibleButtons: getToolbarButtons(state)
1391
         _visibleButtons: getToolbarButtons(state)
1399
     };
1392
     };

Loading…
取消
儲存