ref(ToolbarButton): Remove dispatch
This commit is contained in:
parent
da9e3fb63e
commit
025f7204d5
|
@ -23,17 +23,6 @@ class Toolbar extends Component {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler for mouse out event.
|
|
||||||
*/
|
|
||||||
_onMouseOut: React.PropTypes.func,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler for mouse over event.
|
|
||||||
*/
|
|
||||||
_onMouseOver: React.PropTypes.func,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Children of current React component.
|
* Children of current React component.
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +33,12 @@ class Toolbar extends Component {
|
||||||
*/
|
*/
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to dispatch an action when a button is clicked or on mouse
|
||||||
|
* out/in event.
|
||||||
|
*/
|
||||||
|
dispatch: React.PropTypes.func,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map with toolbar buttons.
|
* Map with toolbar buttons.
|
||||||
*/
|
*/
|
||||||
|
@ -80,11 +75,11 @@ class Toolbar extends Component {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className = { `toolbar ${className}` }
|
className = { `toolbar ${className}` }
|
||||||
onMouseOut = { this.props._onMouseOut }
|
onMouseOut = { this._onMouseOut }
|
||||||
onMouseOver = { this.props._onMouseOver }>
|
onMouseOver = { this._onMouseOver }>
|
||||||
{
|
{
|
||||||
[ ...this.props.toolbarButtons.entries() ]
|
[ ...this.props.toolbarButtons.entries() ]
|
||||||
.reduce(this._renderToolbarButton, [])
|
.reduce(this._renderToolbarButton, [])
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.props.children
|
this.props.children
|
||||||
|
@ -93,6 +88,26 @@ class Toolbar extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches an action signalling that toolbar is no being hovered.
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @returns {Object} Dispatched action.
|
||||||
|
*/
|
||||||
|
_onMouseOut() {
|
||||||
|
this.props.dispatch(setToolbarHovered(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches an action signalling that toolbar is now being hovered.
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @returns {Object} Dispatched action.
|
||||||
|
*/
|
||||||
|
_onMouseOver() {
|
||||||
|
this.props.dispatch(setToolbarHovered(true));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders toolbar button. Method is passed to reduce function.
|
* Renders toolbar button. Method is passed to reduce function.
|
||||||
*
|
*
|
||||||
|
@ -120,11 +135,15 @@ class Toolbar extends Component {
|
||||||
|
|
||||||
const { onClick, onMount, onUnmount } = button;
|
const { onClick, onMount, onUnmount } = button;
|
||||||
|
|
||||||
|
const onClickHandler
|
||||||
|
= (...args) =>
|
||||||
|
onClick(this.props.dispatch, ...args);
|
||||||
|
|
||||||
acc.push(
|
acc.push(
|
||||||
<ToolbarButton
|
<ToolbarButton
|
||||||
button = { button }
|
button = { button }
|
||||||
key = { key }
|
key = { key }
|
||||||
onClick = { onClick }
|
onClick = { onClickHandler }
|
||||||
onMount = { onMount }
|
onMount = { onMount }
|
||||||
onUnmount = { onUnmount }
|
onUnmount = { onUnmount }
|
||||||
tooltipPosition = { tooltipPosition } />
|
tooltipPosition = { tooltipPosition } />
|
||||||
|
@ -134,35 +153,4 @@ class Toolbar extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default connect()(Toolbar);
|
||||||
* Maps part of Redux actions to component's props.
|
|
||||||
*
|
|
||||||
* @param {Function} dispatch - Redux action dispatcher.
|
|
||||||
* @private
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
function _mapDispatchToProps(dispatch: Function): Object {
|
|
||||||
return {
|
|
||||||
/**
|
|
||||||
* Dispatches an action signalling that toolbar is no being hovered.
|
|
||||||
*
|
|
||||||
* @protected
|
|
||||||
* @returns {Object} Dispatched action.
|
|
||||||
*/
|
|
||||||
_onMouseOut() {
|
|
||||||
dispatch(setToolbarHovered(false));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatches an action signalling that toolbar is now being hovered.
|
|
||||||
*
|
|
||||||
* @protected
|
|
||||||
* @returns {Object} Dispatched action.
|
|
||||||
*/
|
|
||||||
_onMouseOver() {
|
|
||||||
dispatch(setToolbarHovered(true));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(undefined, _mapDispatchToProps)(Toolbar);
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
import { translate } from '../../base/i18n';
|
import { translate } from '../../base/i18n';
|
||||||
|
|
||||||
|
@ -37,11 +36,6 @@ class ToolbarButton extends AbstractToolbarButton {
|
||||||
*/
|
*/
|
||||||
button: React.PropTypes.object.isRequired,
|
button: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to dispatch an action when the button is clicked.
|
|
||||||
*/
|
|
||||||
dispatch: React.PropTypes.func,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for component mount.
|
* Handler for component mount.
|
||||||
*/
|
*/
|
||||||
|
@ -157,11 +151,7 @@ class ToolbarButton extends AbstractToolbarButton {
|
||||||
} = button;
|
} = button;
|
||||||
|
|
||||||
if (enabled && !unclickable && onClick) {
|
if (enabled && !unclickable && onClick) {
|
||||||
const action = onClick(event);
|
onClick(event);
|
||||||
|
|
||||||
if (action) {
|
|
||||||
this.props.dispatch(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,4 +234,4 @@ class ToolbarButton extends AbstractToolbarButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translate(connect()(ToolbarButton));
|
export default translate(ToolbarButton);
|
||||||
|
|
|
@ -22,10 +22,10 @@ const buttons: Object = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
id: 'toolbar_button_add',
|
id: 'toolbar_button_add',
|
||||||
isDisplayed: () => !APP.store.getState()['features/jwt'].isGuest,
|
isDisplayed: () => !APP.store.getState()['features/jwt'].isGuest,
|
||||||
onClick() {
|
onClick(dispatch) {
|
||||||
JitsiMeetJS.analytics.sendEvent('toolbar.add.clicked');
|
JitsiMeetJS.analytics.sendEvent('toolbar.add.clicked');
|
||||||
|
|
||||||
return openAddPeopleDialog();
|
dispatch(openAddPeopleDialog());
|
||||||
},
|
},
|
||||||
tooltipKey: 'toolbar.addPeople'
|
tooltipKey: 'toolbar.addPeople'
|
||||||
},
|
},
|
||||||
|
@ -167,10 +167,10 @@ const buttons: Object = {
|
||||||
// Will be displayed once the SIP calls functionality is detected.
|
// Will be displayed once the SIP calls functionality is detected.
|
||||||
hidden: true,
|
hidden: true,
|
||||||
id: 'toolbar_button_dial_out',
|
id: 'toolbar_button_dial_out',
|
||||||
onClick() {
|
onClick(dispatch) {
|
||||||
JitsiMeetJS.analytics.sendEvent('toolbar.sip.clicked');
|
JitsiMeetJS.analytics.sendEvent('toolbar.sip.clicked');
|
||||||
|
|
||||||
return openDialOutDialog();
|
dispatch(openDialOutDialog());
|
||||||
},
|
},
|
||||||
tooltipKey: 'dialOut.dialOut'
|
tooltipKey: 'dialOut.dialOut'
|
||||||
},
|
},
|
||||||
|
@ -185,11 +185,11 @@ const buttons: Object = {
|
||||||
return interfaceConfig.filmStripOnly;
|
return interfaceConfig.filmStripOnly;
|
||||||
},
|
},
|
||||||
id: 'toolbar_button_fodeviceselection',
|
id: 'toolbar_button_fodeviceselection',
|
||||||
onClick() {
|
onClick(dispatch) {
|
||||||
JitsiMeetJS.analytics.sendEvent(
|
JitsiMeetJS.analytics.sendEvent(
|
||||||
'toolbar.fodeviceselection.toggled');
|
'toolbar.fodeviceselection.toggled');
|
||||||
|
|
||||||
return openDeviceSelectionDialog();
|
dispatch(openDeviceSelectionDialog());
|
||||||
},
|
},
|
||||||
sideContainerId: 'settings_container',
|
sideContainerId: 'settings_container',
|
||||||
tooltipKey: 'toolbar.Settings'
|
tooltipKey: 'toolbar.Settings'
|
||||||
|
@ -270,10 +270,10 @@ const buttons: Object = {
|
||||||
classNames: [ 'button', 'icon-link' ],
|
classNames: [ 'button', 'icon-link' ],
|
||||||
enabled: true,
|
enabled: true,
|
||||||
id: 'toolbar_button_link',
|
id: 'toolbar_button_link',
|
||||||
onClick() {
|
onClick(dispatch) {
|
||||||
JitsiMeetJS.analytics.sendEvent('toolbar.invite.clicked');
|
JitsiMeetJS.analytics.sendEvent('toolbar.invite.clicked');
|
||||||
|
|
||||||
return openInviteDialog();
|
dispatch(openInviteDialog());
|
||||||
},
|
},
|
||||||
tooltipKey: 'toolbar.invite'
|
tooltipKey: 'toolbar.invite'
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue