jiti-meet/react/features/toolbox/components/PrimaryToolbar.web.js

121 lines
2.9 KiB
JavaScript
Raw Normal View History

2017-02-16 23:02:40 +00:00
/* @flow */
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { getToolbarClassNames } from '../functions';
2017-04-06 22:40:10 +00:00
import Toolbar from './Toolbar';
2017-02-16 23:02:40 +00:00
declare var interfaceConfig: Object;
/**
* Implementation of PrimaryToolbar React Component.
*
* @class PrimaryToolbar
* @extends Component
*/
class PrimaryToolbar extends Component {
static propTypes = {
/**
* Contains toolbar buttons for primary toolbar.
*/
_primaryToolbarButtons: React.PropTypes.instanceOf(Map),
/**
2017-04-01 05:52:40 +00:00
* Shows whether toolbox is visible.
2017-02-16 23:02:40 +00:00
*/
_visible: React.PropTypes.bool
};
2017-04-06 22:40:10 +00:00
state: Object;
2017-02-16 23:02:40 +00:00
/**
* Constructs instance of primary toolbar React component.
*
* @param {Object} props - React component's properties.
*/
constructor(props) {
super(props);
const splitterIndex = interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX;
this.state = {
/**
* If deployment supports toolbar splitter this value contains its
* index.
*
* @type {number}
*/
splitterIndex
};
}
/**
* Renders primary toolbar component.
*
* @returns {ReactElement}
*/
render(): ReactElement<*> | null {
2017-02-16 23:02:40 +00:00
const { _primaryToolbarButtons } = this.props;
// The number of buttons to show in the toolbar isn't fixed, it depends
2017-04-06 22:40:10 +00:00
// on the availability of features and configuration parameters. So
// there may be nothing to render.
if (_primaryToolbarButtons.size === 0) {
return null;
}
2017-05-26 21:28:16 +00:00
const { splitterIndex } = this.state;
2017-02-16 23:02:40 +00:00
const { primaryToolbarClassName } = getToolbarClassNames(this.props);
2017-04-06 22:40:10 +00:00
const tooltipPosition
= interfaceConfig.filmStripOnly ? 'left' : 'bottom';
2017-02-16 23:02:40 +00:00
return (
2017-04-01 05:52:40 +00:00
<Toolbar
2017-02-16 23:02:40 +00:00
className = { primaryToolbarClassName }
splitterIndex = { splitterIndex }
2017-04-06 22:40:10 +00:00
toolbarButtons = { _primaryToolbarButtons }
tooltipPosition = { tooltipPosition } />
2017-02-16 23:02:40 +00:00
);
}
}
/**
* Maps part of Redux store to React component props.
*
* @param {Object} state - Snapshot of Redux store.
* @returns {{
2017-04-06 22:40:10 +00:00
* _primaryToolbarButtons: Map,
* _visible: boolean
2017-02-16 23:02:40 +00:00
* }}
* @private
*/
function _mapStateToProps(state: Object): Object {
const {
primaryToolbarButtons,
visible
2017-04-01 05:52:40 +00:00
} = state['features/toolbox'];
2017-02-16 23:02:40 +00:00
return {
/**
* Default toolbar buttons for primary toolbar.
*
2017-04-06 22:40:10 +00:00
* @private
2017-02-16 23:02:40 +00:00
* @type {Map}
*/
_primaryToolbarButtons: primaryToolbarButtons,
/**
2017-04-01 05:52:40 +00:00
* Shows whether toolbox is visible.
2017-02-16 23:02:40 +00:00
*
2017-04-06 22:40:10 +00:00
* @private
2017-02-16 23:02:40 +00:00
* @type {boolean}
*/
_visible: visible
};
}
2017-05-26 21:28:16 +00:00
export default connect(_mapStateToProps)(PrimaryToolbar);