Browse Source

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

master
Gabriel Imre 4 years ago
parent
commit
db5d6a56b8

+ 11
- 0
react/features/base/config/functions.web.js View File

@@ -44,3 +44,14 @@ export function getToolbarButtons(state: Object): Array<string> {
44 44
 
45 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 View File

@@ -4,6 +4,7 @@ import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
4 4
 import { useTranslation } from 'react-i18next';
5 5
 import { useDispatch, useSelector } from 'react-redux';
6 6
 
7
+import { isToolbarButtonEnabled } from '../../base/config/functions.web';
7 8
 import { openDialog } from '../../base/dialog';
8 9
 import {
9 10
     IconCloseCircle,
@@ -65,6 +66,7 @@ export const MeetingParticipantContextMenu = ({
65 66
     const dispatch = useDispatch();
66 67
     const containerRef = useRef(null);
67 68
     const isLocalModerator = useSelector(isLocalParticipantModerator);
69
+    const isChatButtonEnabled = useSelector(isToolbarButtonEnabled('chat'));
68 70
     const isParticipantVideoMuted = useSelector(getIsParticipantVideoMuted(participant));
69 71
     const [ isHidden, setIsHidden ] = useState(true);
70 72
     const { t } = useTranslation();
@@ -156,10 +158,12 @@ export const MeetingParticipantContextMenu = ({
156 158
                         <span>{t('videothumbnail.kick')}</span>
157 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 167
             </ContextMenuItemGroup>
164 168
         </ContextMenu>
165 169
     );

+ 44
- 51
react/features/toolbox/components/web/Toolbox.js View File

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

Loading…
Cancel
Save