Selaa lähdekoodia

ref(toolbar): allow OverflowMenuItem to show beta tag

master
Leonard Kim 7 vuotta sitten
vanhempi
commit
f035861617

+ 80
- 53
react/features/toolbox/components/web/OverflowMenuItem.js Näytä tiedosto

1
+// @flow
2
+
1
 import Tooltip from '@atlaskit/tooltip';
3
 import Tooltip from '@atlaskit/tooltip';
2
-import PropTypes from 'prop-types';
3
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
4
 
5
 
6
+/**
7
+ * The type of the React {@code Component} props of {@link OverflowMenuItem}.
8
+ */
9
+type Props = {
10
+
11
+    /**
12
+     * A succinct description of what the item does. Used by accessibility tools
13
+     * and torture tests.
14
+     */
15
+    accessibilityLabel: string,
16
+
17
+    /**
18
+     * Whether menu item is disabled or not.
19
+     */
20
+    disabled: boolean,
21
+
22
+    /**
23
+     * A React Element to display at the end of {@code OverflowMenuItem}.
24
+     */
25
+    elementAfter?: React$Node,
26
+
27
+    /**
28
+     * The icon class to use for displaying an icon before the link text.
29
+     */
30
+    icon: string,
31
+
32
+    /**
33
+     * The callback to invoke when {@code OverflowMenuItem} is clicked.
34
+     */
35
+    onClick: Function,
36
+
37
+    /**
38
+     * The text to display in the {@code OverflowMenuItem}.
39
+     */
40
+    text: string,
41
+
42
+    /**
43
+     * The text to display in the tooltip.
44
+     */
45
+    tooltip?: string,
46
+
47
+    /**
48
+     * From which direction the tooltip should appear, relative to the button.
49
+     */
50
+    tooltipPosition: string
51
+};
52
+
5
 /**
53
 /**
6
  * A React {@code Component} for displaying a link to interact with other
54
  * A React {@code Component} for displaying a link to interact with other
7
  * features of the application.
55
  * features of the application.
8
  *
56
  *
9
  * @extends Component
57
  * @extends Component
10
  */
58
  */
11
-class OverflowMenuItem extends Component {
59
+class OverflowMenuItem extends Component<Props> {
12
     /**
60
     /**
13
      * Default values for {@code OverflowMenuItem} component's properties.
61
      * Default values for {@code OverflowMenuItem} component's properties.
14
      *
62
      *
19
         disabled: false
67
         disabled: false
20
     };
68
     };
21
 
69
 
22
-    /**
23
-     * {@code OverflowMenuItem} component's property types.
24
-     *
25
-     * @static
26
-     */
27
-    static propTypes = {
28
-        /**
29
-         * A succinct description of what the item does. Used by accessibility
30
-         * tools and torture tests.
31
-         */
32
-        accessibilityLabel: PropTypes.string,
33
-
34
-        /**
35
-         * Whether menu item is disabled or not.
36
-         */
37
-        disabled: PropTypes.bool,
38
-
39
-        /**
40
-         * The icon class to use for displaying an icon before the link text.
41
-         */
42
-        icon: PropTypes.string,
43
-
44
-        /**
45
-         * The callback to invoke when {@code OverflowMenuItem} is clicked.
46
-         */
47
-        onClick: PropTypes.func,
48
-
49
-        /**
50
-         * The text to display in the {@code OverflowMenuItem}.
51
-         */
52
-        text: PropTypes.string,
53
-
54
-        /**
55
-         * The text to display in the tooltip.
56
-         */
57
-        tooltip: PropTypes.string,
58
-
59
-        /**
60
-         * From which direction the tooltip should appear, relative to the
61
-         * button.
62
-         */
63
-        tooltipPosition: PropTypes.string
64
-    };
65
-
66
     /**
70
     /**
67
      * Implements React's {@link Component#render()}.
71
      * Implements React's {@link Component#render()}.
68
      *
72
      *
82
                 <span className = 'overflow-menu-item-icon'>
86
                 <span className = 'overflow-menu-item-icon'>
83
                     <i className = { this.props.icon } />
87
                     <i className = { this.props.icon } />
84
                 </span>
88
                 </span>
85
-                { this.props.tooltip
86
-                    ? <Tooltip
87
-                        content = { this.props.tooltip }
88
-                        position = { this.props.tooltipPosition }>
89
-                        <span>{ this.props.text }</span>
90
-                    </Tooltip>
91
-                    : this.props.text }
89
+                { this._renderText() }
90
+                {
91
+                    this.props.elementAfter || null
92
+                }
92
             </li>
93
             </li>
93
         );
94
         );
94
     }
95
     }
96
+
97
+    /**
98
+     * Renders the text label to display in the {@code OverflowMenuItem}.
99
+     *
100
+     * @private
101
+     * @returns {ReactElement}
102
+     */
103
+    _renderText() {
104
+        const textElement = ( // eslint-disable-line no-extra-parens
105
+            <span className = 'overflow-menu-item-text'>
106
+                { this.props.text }
107
+            </span>
108
+        );
109
+
110
+        if (this.props.tooltip) {
111
+            return (
112
+                <Tooltip
113
+                    content = { this.props.tooltip }
114
+                    position = { this.props.tooltipPosition }>
115
+                    { textElement }
116
+                </Tooltip>
117
+            );
118
+        }
119
+
120
+        return textElement;
121
+    }
95
 }
122
 }
96
 
123
 
97
 export default OverflowMenuItem;
124
 export default OverflowMenuItem;

+ 0
- 113
react/features/toolbox/components/web/OverflowMenuLiveStreamingItem.js Näytä tiedosto

1
-import Tooltip from '@atlaskit/tooltip';
2
-import PropTypes from 'prop-types';
3
-import React, { Component } from 'react';
4
-
5
-import { translate } from '../../../base/i18n';
6
-
7
-/**
8
- * React {@code Component} for starting or stopping a live streaming of the
9
- * current conference and displaying the current state of live streaming.
10
- *
11
- * @extends Component
12
- */
13
-class OverflowMenuLiveStreamingItem extends Component {
14
-    /**
15
-     * Default values for {@code OverflowMenuLiveStreamingItem}
16
-     * component's properties.
17
-     *
18
-     * @static
19
-     */
20
-    static defaultProps = {
21
-        tooltipPosition: 'left',
22
-        disabled: false
23
-    };
24
-
25
-    /**
26
-     * The type of the React {@code Component} props of
27
-     * {@link OverflowMenuLiveStreamingItem}.
28
-     */
29
-    static propTypes = {
30
-
31
-        /**
32
-         * Whether menu item is disabled or not.
33
-         */
34
-        disabled: PropTypes.bool,
35
-
36
-        /**
37
-         * The callback to invoke when {@code OverflowMenuLiveStreamingItem} is
38
-         * clicked.
39
-         */
40
-        onClick: Function,
41
-
42
-        /**
43
-         * The current live streaming session, if any.
44
-         */
45
-        session: PropTypes.object,
46
-
47
-        /**
48
-         * Invoked to obtain translated strings.
49
-         */
50
-        t: Function,
51
-
52
-        /**
53
-         * The text to display in the tooltip.
54
-         */
55
-        tooltip: PropTypes.string,
56
-
57
-        /**
58
-         * From which direction the tooltip should appear, relative to the
59
-         * button.
60
-         */
61
-        tooltipPosition: PropTypes.string
62
-    };
63
-
64
-    /**
65
-     * Implements React's {@link Component#render()}.
66
-     *
67
-     * @inheritdoc
68
-     * @returns {ReactElement}
69
-     */
70
-    render() {
71
-        const { disabled, onClick, session, t, tooltip, tooltipPosition }
72
-            = this.props;
73
-
74
-        const translationKey = session
75
-            ? 'dialog.stopLiveStreaming'
76
-            : 'dialog.startLiveStreaming';
77
-
78
-        let className = 'overflow-menu-item';
79
-
80
-        className += disabled ? ' disabled' : '';
81
-
82
-        const button = (// eslint-disable-line no-extra-parens
83
-            <span>
84
-                <span className = 'profile-text'>
85
-                    { t(translationKey) }
86
-                </span>
87
-                <span className = 'beta-tag'>
88
-                    { t('recording.beta') }
89
-                </span>
90
-            </span>
91
-        );
92
-
93
-        return (
94
-            <li
95
-                aria-label = { t('dialog.accessibilityLabel.liveStreaming') }
96
-                className = { className }
97
-                onClick = { disabled ? null : onClick }>
98
-                <span className = 'overflow-menu-item-icon'>
99
-                    <i className = 'icon-public' />
100
-                </span>
101
-                { tooltip
102
-                    ? <Tooltip
103
-                        content = { tooltip }
104
-                        position = { tooltipPosition }>
105
-                        { button }
106
-                    </Tooltip>
107
-                    : button }
108
-            </li>
109
-        );
110
-    }
111
-}
112
-
113
-export default translate(OverflowMenuLiveStreamingItem);

+ 39
- 9
react/features/toolbox/components/web/Toolbox.js Näytä tiedosto

58
 import HangupButton from '../HangupButton';
58
 import HangupButton from '../HangupButton';
59
 import OverflowMenuButton from './OverflowMenuButton';
59
 import OverflowMenuButton from './OverflowMenuButton';
60
 import OverflowMenuItem from './OverflowMenuItem';
60
 import OverflowMenuItem from './OverflowMenuItem';
61
-import OverflowMenuLiveStreamingItem from './OverflowMenuLiveStreamingItem';
62
 import OverflowMenuProfileItem from './OverflowMenuProfileItem';
61
 import OverflowMenuProfileItem from './OverflowMenuProfileItem';
63
 import ToolbarButton from './ToolbarButton';
62
 import ToolbarButton from './ToolbarButton';
64
 import VideoMuteButton from '../VideoMuteButton';
63
 import VideoMuteButton from '../VideoMuteButton';
973
         );
972
         );
974
     }
973
     }
975
 
974
 
975
+    /**
976
+     * Renders an {@code OverflowMenuItem} to start or stop live streaming of
977
+     * the current conference.
978
+     *
979
+     * @private
980
+     * @returns {ReactElement}
981
+     */
982
+    _renderLiveStreamingButton() {
983
+        const {
984
+            _liveStreamingDisabledTooltipKey,
985
+            _liveStreamingEnabled,
986
+            _liveStreamingSession,
987
+            t
988
+        } = this.props;
989
+
990
+        const translationKey = _liveStreamingSession
991
+            ? 'dialog.stopLiveStreaming'
992
+            : 'dialog.startLiveStreaming';
993
+
994
+        return (
995
+            <OverflowMenuItem
996
+                accessibilityLabel
997
+                    = { t('dialog.accessibilityLabel.liveStreaming') }
998
+                disabled = { !_liveStreamingEnabled }
999
+                elementAfter = {
1000
+                    <span className = 'beta-tag'>
1001
+                        { t('recording.beta') }
1002
+                    </span>
1003
+                }
1004
+                icon = 'icon-public'
1005
+                key = 'livestreaming'
1006
+                onClick = { this._onToolbarToggleLiveStreaming }
1007
+                text = { t(translationKey) }
1008
+                tooltip = { t(_liveStreamingDisabledTooltipKey) } />
1009
+        );
1010
+    }
1011
+
976
     /**
1012
     /**
977
      * Renders the list elements of the overflow menu.
1013
      * Renders the list elements of the overflow menu.
978
      *
1014
      *
990
             _isGuest,
1026
             _isGuest,
991
             _liveStreamingDisabledTooltipKey,
1027
             _liveStreamingDisabledTooltipKey,
992
             _liveStreamingEnabled,
1028
             _liveStreamingEnabled,
993
-            _liveStreamingSession,
994
             _sharingVideo,
1029
             _sharingVideo,
995
             t
1030
             t
996
         } = this.props;
1031
         } = this.props;
1019
                         : t('toolbar.enterFullScreen') } />,
1054
                         : t('toolbar.enterFullScreen') } />,
1020
             (_liveStreamingEnabled || _liveStreamingDisabledTooltipKey)
1055
             (_liveStreamingEnabled || _liveStreamingDisabledTooltipKey)
1021
                 && this._shouldShowButton('livestreaming')
1056
                 && this._shouldShowButton('livestreaming')
1022
-                && <OverflowMenuLiveStreamingItem
1023
-                    disabled = { !_liveStreamingEnabled }
1024
-                    key = 'livestreaming'
1025
-                    onClick = { this._onToolbarToggleLiveStreaming }
1026
-                    session = { _liveStreamingSession }
1027
-                    tooltip = { t(_liveStreamingDisabledTooltipKey) } />,
1057
+                && this._renderLiveStreamingButton(),
1028
             (_fileRecordingsEnabled || _fileRecordingsDisabledTooltipKey)
1058
             (_fileRecordingsEnabled || _fileRecordingsDisabledTooltipKey)
1029
                 && this._shouldShowButton('recording')
1059
                 && this._shouldShowButton('recording')
1030
                 && this._renderRecordingButton(),
1060
                 && this._renderRecordingButton(),
1086
      * current conference.
1116
      * current conference.
1087
      *
1117
      *
1088
      * @private
1118
      * @private
1089
-     * @returns {ReactElement|null}
1119
+     * @returns {ReactElement}
1090
      */
1120
      */
1091
     _renderRecordingButton() {
1121
     _renderRecordingButton() {
1092
         const {
1122
         const {

Loading…
Peruuta
Tallenna