Ver código fonte

fix(profile_button): unclickable

master
hristoterezov 7 anos atrás
pai
commit
66da77bcf5

+ 1
- 5
modules/UI/UI.js Ver arquivo

@@ -1248,11 +1248,7 @@ const UIListeners = new Map([
1248 1248
     ], [
1249 1249
         UIEvents.TOGGLE_PROFILE,
1250 1250
         () => {
1251
-            const {
1252
-                isGuest
1253
-            } = APP.store.getState()['features/jwt'];
1254
-
1255
-            isGuest && UI.toggleSidePanel('profile_container');
1251
+            UI.toggleSidePanel('profile_container');
1256 1252
         }
1257 1253
     ], [
1258 1254
         UIEvents.TOGGLE_FILMSTRIP,

+ 3
- 31
react/features/toolbox/actions.web.js Ver arquivo

@@ -100,11 +100,10 @@ export function dockToolbox(dock: boolean): Function {
100 100
  * closure.
101 101
  *
102 102
  * @param {Function} dispatch - Redux action dispatcher.
103
- * @param {Function} getState - The function fetching the Redux state.
104 103
  * @returns {Object} Button on mount/unmount handlers.
105 104
  * @private
106 105
  */
107
-function _getButtonHandlers(dispatch, getState) {
106
+function _getButtonHandlers(dispatch) {
108 107
     const localRaiseHandHandler
109 108
         = (...args) => dispatch(changeLocalRaiseHand(...args));
110 109
     const toggleFullScreenHandler
@@ -136,17 +135,6 @@ function _getButtonHandlers(dispatch, getState) {
136 135
                     toggleFullScreenHandler)
137 136
         },
138 137
 
139
-        /**
140
-         * Mount handler for profile button.
141
-         *
142
-         * @type {Object}
143
-         */
144
-        profile: {
145
-            onMount: () =>
146
-                getState()['features/jwt']
147
-                    || dispatch(setProfileButtonUnclickable(true))
148
-        },
149
-
150 138
         /**
151 139
          * Mount/Unmount handlers for raisehand button.
152 140
          *
@@ -246,9 +234,9 @@ export function setButtonPopupTimeout(buttonName, popupName, timeout) {
246 234
  * @returns {Function}
247 235
  */
248 236
 export function setDefaultToolboxButtons(): Function {
249
-    return (dispatch: Dispatch, getState: Function) => {
237
+    return (dispatch: Dispatch) => {
250 238
         // Save dispatch function in closure.
251
-        const buttonHandlers = _getButtonHandlers(dispatch, getState);
239
+        const buttonHandlers = _getButtonHandlers(dispatch);
252 240
         const toolboxButtons = getDefaultToolboxButtons(buttonHandlers);
253 241
 
254 242
         dispatch({
@@ -258,22 +246,6 @@ export function setDefaultToolboxButtons(): Function {
258 246
     };
259 247
 }
260 248
 
261
-/**
262
- * Signals that unclickable property of profile button should change its value.
263
- *
264
- * @param {boolean} unclickable - Shows whether button is unclickable.
265
- * @returns {Function}
266
- */
267
-export function setProfileButtonUnclickable(unclickable: boolean): Function {
268
-    return (dispatch: Dispatch<*>) => {
269
-        const buttonName = 'profile';
270
-
271
-        dispatch(setToolbarButton(buttonName, {
272
-            unclickable
273
-        }));
274
-    };
275
-}
276
-
277 249
 /**
278 250
  * Shows desktop sharing button.
279 251
  *

+ 0
- 0
react/features/toolbox/components/ProfileButton.native.js Ver arquivo


+ 126
- 0
react/features/toolbox/components/ProfileButton.web.js Ver arquivo

@@ -0,0 +1,126 @@
1
+/* @flow */
2
+
3
+import React, { Component } from 'react';
4
+import { connect } from 'react-redux';
5
+
6
+import { DEFAULT_AVATAR_RELATIVE_PATH } from '../../base/participants';
7
+import UIEvents from '../../../../service/UI/UIEvents';
8
+
9
+import ToolbarButton from './ToolbarButton';
10
+
11
+declare var APP: Object;
12
+declare var JitsiMeetJS: Object;
13
+
14
+/**
15
+ * The default configuration for the button.
16
+ *
17
+ * @type {Object}
18
+ */
19
+const DEFAULT_BUTTON_CONFIGURATION = {
20
+    buttonName: 'profile',
21
+    classNames: [ 'button' ],
22
+    enabled: true,
23
+    id: 'toolbar_button_profile',
24
+    tooltipKey: 'profile.setDisplayNameLabel'
25
+};
26
+
27
+/**
28
+ * React {@code Component} for the profile button.
29
+ *
30
+ * @extends Component
31
+ */
32
+class ProfileButton extends Component {
33
+    _onClick: Function;
34
+
35
+    /**
36
+     * {@code ProfileButton}'s property types.
37
+     *
38
+     * @static
39
+     */
40
+    static propTypes = {
41
+        /**
42
+         * Whether the button support clicking or not.
43
+         */
44
+        _unclickable: React.PropTypes.bool,
45
+
46
+        /**
47
+         * Whether the side panel is opened or not.
48
+         */
49
+        toggled: React.PropTypes.bool,
50
+
51
+        /**
52
+         * From which side tooltips should display. Will be re-used for
53
+         * displaying the inline dialog for video quality adjustment.
54
+         */
55
+        tooltipPosition: React.PropTypes.string
56
+    };
57
+
58
+    /**
59
+     * Initializes a new {@code ProfileButton} instance.
60
+     *
61
+     * @param {Object} props - The read-only properties with which the new
62
+     * instance is to be initialized.
63
+     */
64
+    constructor(props) {
65
+        super(props);
66
+
67
+        // Bind event handlers so they are only bound once for every instance.
68
+        this._onClick = this._onClick.bind(this);
69
+    }
70
+
71
+    /**
72
+     * Implements React's {@link Component#render()}.
73
+     *
74
+     * @inheritdoc
75
+     * @returns {ReactElement}
76
+     */
77
+    render() {
78
+        const { _unclickable, tooltipPosition, toggled } = this.props;
79
+        const buttonConfiguration = {
80
+            ...DEFAULT_BUTTON_CONFIGURATION,
81
+            unclickable: _unclickable,
82
+            toggled
83
+        };
84
+
85
+        return (
86
+            <ToolbarButton
87
+                button = { buttonConfiguration }
88
+                onClick = { this._onClick }
89
+                tooltipPosition = { tooltipPosition }>
90
+                <img
91
+                    id = 'avatar'
92
+                    src = { DEFAULT_AVATAR_RELATIVE_PATH } />
93
+            </ToolbarButton>
94
+        );
95
+    }
96
+
97
+    /**
98
+     * Click handler for the button.
99
+     *
100
+     * @returns {void}
101
+     */
102
+    _onClick() {
103
+        if (!this.props._unclickable) {
104
+            JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
105
+            APP.UI.emitEvent(UIEvents.TOGGLE_PROFILE);
106
+        }
107
+    }
108
+}
109
+
110
+/**
111
+ * Maps (parts of) the Redux state to the associated {@code ProfileButton}
112
+ * component's props.
113
+ *
114
+ * @param {Object} state - The Redux state.
115
+ * @private
116
+ * @returns {{
117
+ *     _unclickable: boolean
118
+ * }}
119
+ */
120
+function _mapStateToProps(state) {
121
+    return {
122
+        _unclickable: !state['features/jwt'].isGuest
123
+    };
124
+}
125
+
126
+export default connect(_mapStateToProps)(ProfileButton);

+ 3
- 41
react/features/toolbox/components/StatelessToolbarButton.js Ver arquivo

@@ -68,12 +68,7 @@ export default class StatelessToolbarButton extends AbstractToolbarButton {
68 68
         /**
69 69
          * Object describing button.
70 70
          */
71
-        button: React.PropTypes.object.isRequired,
72
-
73
-        /**
74
-         * Handler for button's reference.
75
-         */
76
-        createRefToButton: React.PropTypes.func
71
+        button: React.PropTypes.object.isRequired
77 72
     };
78 73
 
79 74
     /**
@@ -102,10 +97,8 @@ export default class StatelessToolbarButton extends AbstractToolbarButton {
102 97
         return (
103 98
             <a
104 99
                 { ...attributes }
105
-                onClick = { this._onClick }
106
-                ref = { this.props.createRefToButton }>
107
-                { this._renderInnerElementsIfRequired() }
108
-                { this._renderChildComponentIfRequired() }
100
+                onClick = { this._onClick }>
101
+                { this.props.children }
109 102
             </a>
110 103
         );
111 104
     }
@@ -131,35 +124,4 @@ export default class StatelessToolbarButton extends AbstractToolbarButton {
131 124
             onClick(event);
132 125
         }
133 126
     }
134
-
135
-    /**
136
-     * Render any configured child component for the toolbar button.
137
-     *
138
-     * @returns {ReactElement|null}
139
-     * @private
140
-     */
141
-    _renderChildComponentIfRequired(): ReactElement<*> | null {
142
-        if (this.props.button.childComponent) {
143
-            const Child = this.props.button.childComponent;
144
-
145
-            return <Child />;
146
-        }
147
-
148
-        return null;
149
-    }
150
-
151
-    /**
152
-     * If toolbar button should contain children elements
153
-     * renders them.
154
-     *
155
-     * @returns {ReactElement|null}
156
-     * @private
157
-     */
158
-    _renderInnerElementsIfRequired(): ReactElement<*> | null {
159
-        if (this.props.button.html) {
160
-            return this.props.button.html;
161
-        }
162
-
163
-        return null;
164
-    }
165 127
 }

+ 12
- 2
react/features/toolbox/components/Toolbar.web.js Ver arquivo

@@ -128,15 +128,22 @@ class Toolbar extends Component {
128 128
         const [ key, button ] = keyValuePair;
129 129
 
130 130
         if (button.component) {
131
+
131 132
             return (
132 133
                 <button.component
133 134
                     key = { key }
135
+                    toggled = { button.toggled }
134 136
                     tooltipPosition = { this.props.tooltipPosition } />
135 137
             );
136 138
         }
137 139
 
138 140
         const { tooltipPosition } = this.props;
139
-        const { onClick, onMount, onUnmount } = button;
141
+        const {
142
+            childComponent: ChildComponent,
143
+            onClick,
144
+            onMount,
145
+            onUnmount
146
+        } = button;
140 147
         const onClickWithDispatch = (...args) =>
141 148
             onClick && onClick(this.props.dispatch, ...args);
142 149
 
@@ -147,7 +154,10 @@ class Toolbar extends Component {
147 154
                 onClick = { onClickWithDispatch }
148 155
                 onMount = { onMount }
149 156
                 onUnmount = { onUnmount }
150
-                tooltipPosition = { tooltipPosition } />
157
+                tooltipPosition = { tooltipPosition }>
158
+                { button.html || null }
159
+                { ChildComponent ? <ChildComponent /> : null }
160
+            </ToolbarButton>
151 161
         );
152 162
     }
153 163
 }

+ 4
- 32
react/features/toolbox/components/ToolbarButton.web.js Ver arquivo

@@ -32,7 +32,6 @@ const TOOLTIP_TO_POPUP_POSITION = {
32 32
  */
33 33
 class ToolbarButton extends Component {
34 34
     button: Object;
35
-    _createRefToButton: Function;
36 35
 
37 36
     _onClick: Function;
38 37
 
@@ -99,7 +98,6 @@ class ToolbarButton extends Component {
99 98
         };
100 99
 
101 100
         // Bind methods to save the context
102
-        this._createRefToButton = this._createRefToButton.bind(this);
103 101
         this._onClick = this._onClick.bind(this);
104 102
         this._onMouseOut = this._onMouseOut.bind(this);
105 103
         this._onMouseOver = this._onMouseOver.bind(this);
@@ -142,8 +140,7 @@ class ToolbarButton extends Component {
142 140
         const { button, t, tooltipPosition } = this.props;
143 141
         const props = {
144 142
             ...this.props,
145
-            onClick: this._onClick,
146
-            createRefToButton: this._createRefToButton
143
+            onClick: this._onClick
147 144
         };
148 145
 
149 146
         const buttonComponent = ( // eslint-disable-line no-extra-parens
@@ -153,7 +150,9 @@ class ToolbarButton extends Component {
153 150
                 onMouseOver = { this._onMouseOver }
154 151
                 position = { tooltipPosition }
155 152
                 visible = { this.state.showTooltip }>
156
-                <StatelessToolbarButton { ...props } />
153
+                <StatelessToolbarButton { ...props }>
154
+                    { this.props.children }
155
+                </StatelessToolbarButton>
157 156
             </Tooltip>
158 157
         );
159 158
         let children = buttonComponent;
@@ -192,18 +191,6 @@ class ToolbarButton extends Component {
192 191
         this.setState({ showTooltip: false });
193 192
     }
194 193
 
195
-    /**
196
-     * Creates reference to current toolbar button.
197
-     *
198
-     * @param {HTMLElement} element - HTMLElement representing the toolbar
199
-     * button.
200
-     * @returns {void}
201
-     * @private
202
-     */
203
-    _createRefToButton(element: HTMLElement): void {
204
-        this.button = element;
205
-    }
206
-
207 194
     /**
208 195
      * Parses the props and state to find any popup that should be displayed
209 196
      * and returns an object describing how the popup should display.
@@ -230,21 +217,6 @@ class ToolbarButton extends Component {
230 217
             });
231 218
     }
232 219
 
233
-    /**
234
-     * If toolbar button should contain children elements
235
-     * renders them.
236
-     *
237
-     * @returns {ReactElement|null}
238
-     * @private
239
-     */
240
-    _renderInnerElementsIfRequired(): ReactElement<*> | null {
241
-        if (this.props.button.html) {
242
-            return this.props.button.html;
243
-        }
244
-
245
-        return null;
246
-    }
247
-
248 220
     /**
249 221
      * Hides any displayed tooltip.
250 222
      *

+ 5
- 16
react/features/toolbox/defaultToolbarButtons.web.js Ver arquivo

@@ -2,15 +2,14 @@
2 2
 
3 3
 import React from 'react';
4 4
 
5
-import { DEFAULT_AVATAR_RELATIVE_PATH } from '../base/participants';
5
+import { ParticipantCounter } from '../contact-list';
6 6
 import { openDeviceSelectionDialog } from '../device-selection';
7 7
 import { openDialOutDialog } from '../dial-out';
8 8
 import { openAddPeopleDialog, openInviteDialog } from '../invite';
9
-import { VideoQualityButton } from '../video-quality';
10
-
11 9
 import UIEvents from '../../../service/UI/UIEvents';
10
+import { VideoQualityButton } from '../video-quality';
12 11
 
13
-import { ParticipantCounter } from '../contact-list';
12
+import ProfileButton from './components/ProfileButton';
14 13
 
15 14
 declare var APP: Object;
16 15
 declare var interfaceConfig: Object;
@@ -328,18 +327,8 @@ const buttons: Object = {
328 327
      * The descriptor of the profile toolbar button.
329 328
      */
330 329
     profile: {
331
-        classNames: [ 'button' ],
332
-        enabled: true,
333
-        html: <img
334
-            id = 'avatar'
335
-            src = { DEFAULT_AVATAR_RELATIVE_PATH } />,
336
-        id: 'toolbar_button_profile',
337
-        onClick() {
338
-            JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
339
-            APP.UI.emitEvent(UIEvents.TOGGLE_PROFILE);
340
-        },
341
-        sideContainerId: 'profile_container',
342
-        tooltipKey: 'profile.setDisplayNameLabel'
330
+        component: ProfileButton,
331
+        sideContainerId: 'profile_container'
343 332
     },
344 333
 
345 334
     /**

Carregando…
Cancelar
Salvar