2019-10-31 06:14:15 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
|
|
|
import { openDialog } from '../../../base/dialog';
|
2021-04-08 08:35:26 +00:00
|
|
|
import { IconUserGroups } from '../../../base/icons';
|
|
|
|
import { Label } from '../../../base/label';
|
2022-10-24 07:44:41 +00:00
|
|
|
import { COLORS } from '../../../base/label/constants';
|
2019-10-31 06:14:15 +00:00
|
|
|
import { getParticipantCount } from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { SpeakerStats } from '../../../speaker-stats';
|
2022-10-17 20:40:13 +00:00
|
|
|
import { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';
|
2019-10-31 06:14:15 +00:00
|
|
|
|
2021-04-08 08:35:26 +00:00
|
|
|
|
2019-10-31 06:14:15 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link ParticipantsCount}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of the conference participants.
|
|
|
|
*/
|
2021-09-20 18:12:56 +00:00
|
|
|
count: number,
|
2019-10-31 06:14:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Conference data.
|
|
|
|
*/
|
|
|
|
conference: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to open Speaker stats.
|
|
|
|
*/
|
|
|
|
dispatch: Dispatch<any>,
|
2022-10-17 20:40:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Weather or not the speaker stats is disabled.
|
|
|
|
*/
|
2022-10-24 07:44:41 +00:00
|
|
|
_isSpeakerStatsDisabled: Boolean,
|
2019-10-31 06:14:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ParticipantsCount react component.
|
|
|
|
* Displays the number of participants and opens Speaker stats on click.
|
|
|
|
*
|
|
|
|
* @class ParticipantsCount
|
|
|
|
*/
|
|
|
|
class ParticipantsCount extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Initializes a new ParticipantsCount instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback invoked to display {@code SpeakerStats}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { dispatch, conference } = this.props;
|
|
|
|
|
|
|
|
dispatch(openDialog(SpeakerStats, { conference }));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link PureComponent#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2021-09-20 18:12:56 +00:00
|
|
|
const { count } = this.props;
|
|
|
|
|
|
|
|
if (count <= 2) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-10-31 06:14:15 +00:00
|
|
|
return (
|
2021-09-29 12:06:03 +00:00
|
|
|
<Label
|
2022-10-24 07:44:41 +00:00
|
|
|
color = { COLORS.white }
|
2021-09-29 12:06:03 +00:00
|
|
|
icon = { IconUserGroups }
|
2022-10-24 07:44:41 +00:00
|
|
|
iconColor = '#fff'
|
2022-10-17 20:40:13 +00:00
|
|
|
onClick = { !this.props._isSpeakerStatsDisabled && this._onClick }
|
2021-09-29 12:06:03 +00:00
|
|
|
text = { count } />
|
2019-10-31 06:14:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated props for the
|
|
|
|
* {@code ParticipantsCount} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
conference: state['features/base/conference'].conference,
|
2022-10-17 20:40:13 +00:00
|
|
|
count: getParticipantCount(state),
|
|
|
|
_isSpeakerStatsDisabled: isSpeakerStatsDisabled(state)
|
2019-10-31 06:14:15 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(ParticipantsCount);
|