Explorar el Código

feat(toolbox): create SettingsButton

Only on web, since there is currently no equivalent on mobile. It encapsulates
all funcionality related to opening the settings dialog / panel.
master
Saúl Ibarra Corretgé hace 7 años
padre
commit
c7d72ee3f6

+ 11
- 43
react/features/toolbox/components/Toolbox.web.js Ver fichero

18
 } from '../../base/participants';
18
 } from '../../base/participants';
19
 import { getLocalVideoTrack, toggleScreensharing } from '../../base/tracks';
19
 import { getLocalVideoTrack, toggleScreensharing } from '../../base/tracks';
20
 import { ChatCounter } from '../../chat';
20
 import { ChatCounter } from '../../chat';
21
-import { openDeviceSelectionDialog } from '../../device-selection';
22
 import { toggleDocument } from '../../etherpad';
21
 import { toggleDocument } from '../../etherpad';
23
 import { openFeedbackDialog } from '../../feedback';
22
 import { openFeedbackDialog } from '../../feedback';
24
 import {
23
 import {
30
 import { openKeyboardShortcutsDialog } from '../../keyboard-shortcuts';
29
 import { openKeyboardShortcutsDialog } from '../../keyboard-shortcuts';
31
 import { RECORDING_TYPES, toggleRecording } from '../../recording';
30
 import { RECORDING_TYPES, toggleRecording } from '../../recording';
32
 import { toggleSharedVideo } from '../../shared-video';
31
 import { toggleSharedVideo } from '../../shared-video';
33
-import { shouldShowOnlyDeviceSelection } from '../../settings';
34
-import { toggleChat, toggleProfile, toggleSettings } from '../../side-panel';
32
+import { toggleChat, toggleProfile } from '../../side-panel';
35
 import { SpeakerStats } from '../../speaker-stats';
33
 import { SpeakerStats } from '../../speaker-stats';
36
 import {
34
 import {
37
     OverflowMenuVideoQualityItem,
35
     OverflowMenuVideoQualityItem,
44
 import OverflowMenuItem from './OverflowMenuItem';
42
 import OverflowMenuItem from './OverflowMenuItem';
45
 import OverflowMenuProfileItem from './OverflowMenuProfileItem';
43
 import OverflowMenuProfileItem from './OverflowMenuProfileItem';
46
 import ToolbarButton from './ToolbarButton';
44
 import ToolbarButton from './ToolbarButton';
47
-import { AudioMuteButton, HangupButton, VideoMuteButton } from './buttons';
45
+import {
46
+    AudioMuteButton,
47
+    HangupButton,
48
+    SettingsButton,
49
+    VideoMuteButton
50
+} from './buttons';
48
 
51
 
49
 type Props = {
52
 type Props = {
50
 
53
 
227
             = this._onToolbarToggleRecording.bind(this);
230
             = this._onToolbarToggleRecording.bind(this);
228
         this._onToolbarToggleScreenshare
231
         this._onToolbarToggleScreenshare
229
             = this._onToolbarToggleScreenshare.bind(this);
232
             = this._onToolbarToggleScreenshare.bind(this);
230
-        this._onToolbarToggleSettings
231
-            = this._onToolbarToggleSettings.bind(this);
232
         this._onToolbarToggleSharedVideo
233
         this._onToolbarToggleSharedVideo
233
             = this._onToolbarToggleSharedVideo.bind(this);
234
             = this._onToolbarToggleSharedVideo.bind(this);
234
     }
235
     }
509
         }
510
         }
510
     }
511
     }
511
 
512
 
512
-    /**
513
-     * Dispatches an action to toggle display of settings, be it the settings
514
-     * panel or directly to device selection.
515
-     *
516
-     * @private
517
-     * @returns {void}
518
-     */
519
-    _doToggleSettings() {
520
-        if (shouldShowOnlyDeviceSelection()) {
521
-            this.props.dispatch(openDeviceSelectionDialog());
522
-        } else {
523
-            this.props.dispatch(toggleSettings());
524
-        }
525
-    }
526
-
527
     /**
513
     /**
528
      * Dispatches an action to toggle YouTube video sharing.
514
      * Dispatches an action to toggle YouTube video sharing.
529
      *
515
      *
862
         this._doToggleScreenshare();
848
         this._doToggleScreenshare();
863
     }
849
     }
864
 
850
 
865
-    _onToolbarToggleSettings: () => void;
866
-
867
-    /**
868
-     * Creates an analytics toolbar event and dispatches an action for toggling
869
-     * settings display.
870
-     *
871
-     * @private
872
-     * @returns {void}
873
-     */
874
-    _onToolbarToggleSettings() {
875
-        sendAnalytics(createToolbarEvent('settings'));
876
-
877
-        this._doToggleSettings();
878
-    }
879
-
880
     _onToolbarToggleSharedVideo: () => void;
851
     _onToolbarToggleSharedVideo: () => void;
881
 
852
 
882
     /**
853
     /**
993
                     text = { _editingDocument
964
                     text = { _editingDocument
994
                         ? t('toolbar.documentClose')
965
                         ? t('toolbar.documentClose')
995
                         : t('toolbar.documentOpen') } />,
966
                         : t('toolbar.documentOpen') } />,
996
-            this._shouldShowButton('settings')
997
-                && <OverflowMenuItem
998
-                    accessibilityLabel = 'Settings'
999
-                    icon = 'icon-settings'
1000
-                    key = 'settings'
1001
-                    onClick = { this._onToolbarToggleSettings }
1002
-                    text = { t('toolbar.Settings') } />,
967
+            <SettingsButton
968
+                key = 'settings'
969
+                showLabel = { true }
970
+                visible = { this._shouldShowButton('settings') } />,
1003
             this._shouldShowButton('stats')
971
             this._shouldShowButton('stats')
1004
                 && <OverflowMenuItem
972
                 && <OverflowMenuItem
1005
                     accessibilityLabel = 'Speaker stats'
973
                     accessibilityLabel = 'Speaker stats'

+ 1
- 0
react/features/toolbox/components/buttons/_.native.js Ver fichero

1
+export * from './native';

+ 1
- 0
react/features/toolbox/components/buttons/_.web.js Ver fichero

1
+export * from './web';

+ 2
- 0
react/features/toolbox/components/buttons/index.js Ver fichero

1
+export * from './_';
2
+
1
 export { default as AudioMuteButton } from './AudioMuteButton';
3
 export { default as AudioMuteButton } from './AudioMuteButton';
2
 export { default as HangupButton } from './HangupButton';
4
 export { default as HangupButton } from './HangupButton';
3
 export { default as VideoMuteButton } from './VideoMuteButton';
5
 export { default as VideoMuteButton } from './VideoMuteButton';

+ 0
- 0
react/features/toolbox/components/buttons/native/index.js Ver fichero


+ 92
- 0
react/features/toolbox/components/buttons/web/SettingsButton.js Ver fichero

1
+// @flow
2
+
3
+import { connect } from 'react-redux';
4
+
5
+import { createToolbarEvent, sendAnalytics } from '../../../../analytics';
6
+import { translate } from '../../../../base/i18n';
7
+import { openDeviceSelectionDialog } from '../../../../device-selection';
8
+import { toggleSettings } from '../../../../side-panel';
9
+
10
+import AbstractButton from '../AbstractButton';
11
+import type { Props as AbstractButtonProps } from '../AbstractButton';
12
+
13
+declare var interfaceConfig: Object;
14
+
15
+type Props = AbstractButtonProps & {
16
+
17
+    /**
18
+     * Whether we are in filmstrip only mode or not.
19
+     */
20
+    _filmStripOnly: boolean,
21
+
22
+    /**
23
+     * Array containing the enabled settings sections.
24
+     */
25
+    _sections: Array<string>,
26
+
27
+    /**
28
+     * The redux {@code dispatch} function.
29
+     */
30
+    dispatch: Function
31
+}
32
+
33
+/**
34
+ * An abstract implementation of a button for accessing settings.
35
+ */
36
+class SettingsButton extends AbstractButton<Props, *> {
37
+    accessibilityLabel = 'Settings';
38
+    iconName = 'icon-settings';
39
+    label = 'toolbar.Settings';
40
+    tooltip = 'toolbar.Settings';
41
+
42
+    /**
43
+     * Handles clicking / pressing the button, and opens the appropriate dialog.
44
+     *
45
+     * @private
46
+     * @returns {void}
47
+     */
48
+    _handleClick() {
49
+        const { _filmStripOnly, _sections, dispatch } = this.props;
50
+
51
+        sendAnalytics(createToolbarEvent('settings'));
52
+        if (_filmStripOnly
53
+                || (_sections.length === 1 && _sections.includes('devices'))) {
54
+            dispatch(openDeviceSelectionDialog());
55
+        } else {
56
+            dispatch(toggleSettings());
57
+        }
58
+    }
59
+
60
+    /**
61
+     * Indicates whether this button is disabled or not.
62
+     *
63
+     * @override
64
+     * @private
65
+     * @returns {boolean}
66
+     */
67
+    _isDisabled() {
68
+        return false;
69
+    }
70
+}
71
+
72
+/**
73
+ * Maps (parts of) the redux state to the associated props for the
74
+ * {@code SettingsButton} component.
75
+ *
76
+ * @param {Object} state - The Redux state.
77
+ * @private
78
+ * @returns {{
79
+ *     _filmStripOnly: boolean
80
+ * }}
81
+ */
82
+function _mapStateToProps(state): Object { // eslint-disable-line no-unused-vars
83
+    // XXX: We are not currently using state here, but in the future, when
84
+    // interfaceConfig is part of redux we will.
85
+
86
+    return {
87
+        _filmStripOnly: Boolean(interfaceConfig.filmStripOnly),
88
+        _sections: interfaceConfig.SETTINGS_SECTIONS || []
89
+    };
90
+}
91
+
92
+export default translate(connect(_mapStateToProps)(SettingsButton));

+ 1
- 0
react/features/toolbox/components/buttons/web/index.js Ver fichero

1
+export { default as SettingsButton } from './SettingsButton';

+ 1
- 0
react/features/toolbox/components/index.js Ver fichero

1
 export { default as ToolbarButton } from './ToolbarButton';
1
 export { default as ToolbarButton } from './ToolbarButton';
2
 export { default as ToolboxFilmstrip } from './ToolboxFilmstrip';
2
 export { default as ToolboxFilmstrip } from './ToolboxFilmstrip';
3
 export { default as Toolbox } from './Toolbox';
3
 export { default as Toolbox } from './Toolbox';
4
+export * from './buttons';

Loading…
Cancelar
Guardar