|
@@ -0,0 +1,101 @@
|
|
1
|
+// @flow
|
|
2
|
+
|
|
3
|
+import React, { PureComponent } from 'react';
|
|
4
|
+import type { Dispatch } from 'redux';
|
|
5
|
+
|
|
6
|
+import { openDialog } from '../../../base/dialog';
|
|
7
|
+import { getParticipantCount } from '../../../base/participants';
|
|
8
|
+import { connect } from '../../../base/redux';
|
|
9
|
+import { SpeakerStats } from '../../../speaker-stats';
|
|
10
|
+
|
|
11
|
+/**
|
|
12
|
+ * The type of the React {@code Component} props of {@link ParticipantsCount}.
|
|
13
|
+ */
|
|
14
|
+type Props = {
|
|
15
|
+
|
|
16
|
+ /**
|
|
17
|
+ * Number of the conference participants.
|
|
18
|
+ */
|
|
19
|
+ count: string,
|
|
20
|
+
|
|
21
|
+ /**
|
|
22
|
+ * Conference data.
|
|
23
|
+ */
|
|
24
|
+ conference: Object,
|
|
25
|
+
|
|
26
|
+ /**
|
|
27
|
+ * Invoked to open Speaker stats.
|
|
28
|
+ */
|
|
29
|
+ dispatch: Dispatch<any>,
|
|
30
|
+};
|
|
31
|
+
|
|
32
|
+/**
|
|
33
|
+ * ParticipantsCount react component.
|
|
34
|
+ * Displays the number of participants and opens Speaker stats on click.
|
|
35
|
+ *
|
|
36
|
+ * @class ParticipantsCount
|
|
37
|
+ */
|
|
38
|
+class ParticipantsCount extends PureComponent<Props> {
|
|
39
|
+ /**
|
|
40
|
+ * Initializes a new ParticipantsCount instance.
|
|
41
|
+ *
|
|
42
|
+ * @param {Object} props - The read-only properties with which the new
|
|
43
|
+ * instance is to be initialized.
|
|
44
|
+ */
|
|
45
|
+ constructor(props: Props) {
|
|
46
|
+ super(props);
|
|
47
|
+
|
|
48
|
+ this._onClick = this._onClick.bind(this);
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ _onClick: () => void;
|
|
52
|
+
|
|
53
|
+ /**
|
|
54
|
+ * Callback invoked to display {@code SpeakerStats}.
|
|
55
|
+ *
|
|
56
|
+ * @private
|
|
57
|
+ * @returns {void}
|
|
58
|
+ */
|
|
59
|
+ _onClick() {
|
|
60
|
+ const { dispatch, conference } = this.props;
|
|
61
|
+
|
|
62
|
+ dispatch(openDialog(SpeakerStats, { conference }));
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ /**
|
|
66
|
+ * Implements React's {@link PureComponent#render()}.
|
|
67
|
+ *
|
|
68
|
+ * @inheritdoc
|
|
69
|
+ * @returns {ReactElement}
|
|
70
|
+ */
|
|
71
|
+ render() {
|
|
72
|
+ return (
|
|
73
|
+ <div
|
|
74
|
+ className = 'participants-count'
|
|
75
|
+ onClick = { this._onClick }>
|
|
76
|
+ <span className = 'participants-count-number'>
|
|
77
|
+ {this.props.count}
|
|
78
|
+ </span>
|
|
79
|
+ <span className = 'participants-count-icon' />
|
|
80
|
+ </div>
|
|
81
|
+ );
|
|
82
|
+ }
|
|
83
|
+}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+/**
|
|
87
|
+ * Maps (parts of) the Redux state to the associated props for the
|
|
88
|
+ * {@code ParticipantsCount} component.
|
|
89
|
+ *
|
|
90
|
+ * @param {Object} state - The Redux state.
|
|
91
|
+ * @private
|
|
92
|
+ * @returns {Props}
|
|
93
|
+ */
|
|
94
|
+function mapStateToProps(state) {
|
|
95
|
+ return {
|
|
96
|
+ conference: state['features/base/conference'].conference,
|
|
97
|
+ count: getParticipantCount(state)
|
|
98
|
+ };
|
|
99
|
+}
|
|
100
|
+
|
|
101
|
+export default connect(mapStateToProps)(ParticipantsCount);
|