瀏覽代碼

fix(profile_button): unclickable

j8
hristoterezov 8 年之前
父節點
當前提交
66da77bcf5

+ 1
- 5
modules/UI/UI.js 查看文件

1248
     ], [
1248
     ], [
1249
         UIEvents.TOGGLE_PROFILE,
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
         UIEvents.TOGGLE_FILMSTRIP,
1254
         UIEvents.TOGGLE_FILMSTRIP,

+ 3
- 31
react/features/toolbox/actions.web.js 查看文件

100
  * closure.
100
  * closure.
101
  *
101
  *
102
  * @param {Function} dispatch - Redux action dispatcher.
102
  * @param {Function} dispatch - Redux action dispatcher.
103
- * @param {Function} getState - The function fetching the Redux state.
104
  * @returns {Object} Button on mount/unmount handlers.
103
  * @returns {Object} Button on mount/unmount handlers.
105
  * @private
104
  * @private
106
  */
105
  */
107
-function _getButtonHandlers(dispatch, getState) {
106
+function _getButtonHandlers(dispatch) {
108
     const localRaiseHandHandler
107
     const localRaiseHandHandler
109
         = (...args) => dispatch(changeLocalRaiseHand(...args));
108
         = (...args) => dispatch(changeLocalRaiseHand(...args));
110
     const toggleFullScreenHandler
109
     const toggleFullScreenHandler
136
                     toggleFullScreenHandler)
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
          * Mount/Unmount handlers for raisehand button.
139
          * Mount/Unmount handlers for raisehand button.
152
          *
140
          *
246
  * @returns {Function}
234
  * @returns {Function}
247
  */
235
  */
248
 export function setDefaultToolboxButtons(): Function {
236
 export function setDefaultToolboxButtons(): Function {
249
-    return (dispatch: Dispatch, getState: Function) => {
237
+    return (dispatch: Dispatch) => {
250
         // Save dispatch function in closure.
238
         // Save dispatch function in closure.
251
-        const buttonHandlers = _getButtonHandlers(dispatch, getState);
239
+        const buttonHandlers = _getButtonHandlers(dispatch);
252
         const toolboxButtons = getDefaultToolboxButtons(buttonHandlers);
240
         const toolboxButtons = getDefaultToolboxButtons(buttonHandlers);
253
 
241
 
254
         dispatch({
242
         dispatch({
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
  * Shows desktop sharing button.
250
  * Shows desktop sharing button.
279
  *
251
  *

+ 0
- 0
react/features/toolbox/components/ProfileButton.native.js 查看文件


+ 126
- 0
react/features/toolbox/components/ProfileButton.web.js 查看文件

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 查看文件

68
         /**
68
         /**
69
          * Object describing button.
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
         return (
97
         return (
103
             <a
98
             <a
104
                 { ...attributes }
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
             </a>
102
             </a>
110
         );
103
         );
111
     }
104
     }
131
             onClick(event);
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 查看文件

128
         const [ key, button ] = keyValuePair;
128
         const [ key, button ] = keyValuePair;
129
 
129
 
130
         if (button.component) {
130
         if (button.component) {
131
+
131
             return (
132
             return (
132
                 <button.component
133
                 <button.component
133
                     key = { key }
134
                     key = { key }
135
+                    toggled = { button.toggled }
134
                     tooltipPosition = { this.props.tooltipPosition } />
136
                     tooltipPosition = { this.props.tooltipPosition } />
135
             );
137
             );
136
         }
138
         }
137
 
139
 
138
         const { tooltipPosition } = this.props;
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
         const onClickWithDispatch = (...args) =>
147
         const onClickWithDispatch = (...args) =>
141
             onClick && onClick(this.props.dispatch, ...args);
148
             onClick && onClick(this.props.dispatch, ...args);
142
 
149
 
147
                 onClick = { onClickWithDispatch }
154
                 onClick = { onClickWithDispatch }
148
                 onMount = { onMount }
155
                 onMount = { onMount }
149
                 onUnmount = { onUnmount }
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 查看文件

32
  */
32
  */
33
 class ToolbarButton extends Component {
33
 class ToolbarButton extends Component {
34
     button: Object;
34
     button: Object;
35
-    _createRefToButton: Function;
36
 
35
 
37
     _onClick: Function;
36
     _onClick: Function;
38
 
37
 
99
         };
98
         };
100
 
99
 
101
         // Bind methods to save the context
100
         // Bind methods to save the context
102
-        this._createRefToButton = this._createRefToButton.bind(this);
103
         this._onClick = this._onClick.bind(this);
101
         this._onClick = this._onClick.bind(this);
104
         this._onMouseOut = this._onMouseOut.bind(this);
102
         this._onMouseOut = this._onMouseOut.bind(this);
105
         this._onMouseOver = this._onMouseOver.bind(this);
103
         this._onMouseOver = this._onMouseOver.bind(this);
142
         const { button, t, tooltipPosition } = this.props;
140
         const { button, t, tooltipPosition } = this.props;
143
         const props = {
141
         const props = {
144
             ...this.props,
142
             ...this.props,
145
-            onClick: this._onClick,
146
-            createRefToButton: this._createRefToButton
143
+            onClick: this._onClick
147
         };
144
         };
148
 
145
 
149
         const buttonComponent = ( // eslint-disable-line no-extra-parens
146
         const buttonComponent = ( // eslint-disable-line no-extra-parens
153
                 onMouseOver = { this._onMouseOver }
150
                 onMouseOver = { this._onMouseOver }
154
                 position = { tooltipPosition }
151
                 position = { tooltipPosition }
155
                 visible = { this.state.showTooltip }>
152
                 visible = { this.state.showTooltip }>
156
-                <StatelessToolbarButton { ...props } />
153
+                <StatelessToolbarButton { ...props }>
154
+                    { this.props.children }
155
+                </StatelessToolbarButton>
157
             </Tooltip>
156
             </Tooltip>
158
         );
157
         );
159
         let children = buttonComponent;
158
         let children = buttonComponent;
192
         this.setState({ showTooltip: false });
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
      * Parses the props and state to find any popup that should be displayed
195
      * Parses the props and state to find any popup that should be displayed
209
      * and returns an object describing how the popup should display.
196
      * and returns an object describing how the popup should display.
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
      * Hides any displayed tooltip.
221
      * Hides any displayed tooltip.
250
      *
222
      *

+ 5
- 16
react/features/toolbox/defaultToolbarButtons.web.js 查看文件

2
 
2
 
3
 import React from 'react';
3
 import React from 'react';
4
 
4
 
5
-import { DEFAULT_AVATAR_RELATIVE_PATH } from '../base/participants';
5
+import { ParticipantCounter } from '../contact-list';
6
 import { openDeviceSelectionDialog } from '../device-selection';
6
 import { openDeviceSelectionDialog } from '../device-selection';
7
 import { openDialOutDialog } from '../dial-out';
7
 import { openDialOutDialog } from '../dial-out';
8
 import { openAddPeopleDialog, openInviteDialog } from '../invite';
8
 import { openAddPeopleDialog, openInviteDialog } from '../invite';
9
-import { VideoQualityButton } from '../video-quality';
10
-
11
 import UIEvents from '../../../service/UI/UIEvents';
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
 declare var APP: Object;
14
 declare var APP: Object;
16
 declare var interfaceConfig: Object;
15
 declare var interfaceConfig: Object;
328
      * The descriptor of the profile toolbar button.
327
      * The descriptor of the profile toolbar button.
329
      */
328
      */
330
     profile: {
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
     /**

Loading…
取消
儲存