bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/user-list/component.jsx

164 lines
4.2 KiB
React
Raw Normal View History

2016-06-29 03:52:03 +08:00
import React, { Component, PropTypes } from 'react';
import { withRouter } from 'react-router';
2016-06-28 21:10:20 +08:00
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import styles from './styles.scss';
import { FormattedMessage } from 'react-intl';
2016-06-29 22:24:27 +08:00
import cx from 'classnames';
2016-05-20 02:22:56 +08:00
import UserListItem from './user-list-item/component.jsx';
import ChatListItem from './chat-list-item/component.jsx';
2016-06-29 03:52:03 +08:00
const propTypes = {
openChats: PropTypes.array.isRequired,
users: PropTypes.array.isRequired,
};
const defaultProps = {
};
2016-06-28 21:10:20 +08:00
const listTransition = {
enter: styles.enter,
enterActive: styles.enterActive,
appear: styles.appear,
appearActive: styles.appearActive,
leave: styles.leave,
leaveActive: styles.leaveActive,
};
class UserList extends Component {
constructor(props) {
super(props);
this.state = {
2016-09-15 01:48:50 +08:00
compact: this.props.compact,
};
}
2016-05-20 02:22:56 +08:00
render() {
return (
<div className={styles.userList}>
2016-05-26 03:29:22 +08:00
{this.renderHeader()}
{this.renderContent()}
</div>
);
}
renderHeader() {
return (
<div className={styles.header}>
2016-09-15 01:48:50 +08:00
{
!this.state.compact ?
<h2 className={styles.headerTitle}>
<FormattedMessage
id="app.userlist.participantsTitle"
description="Title for the Header"
defaultMessage="Participants"
/>
</h2> : null
}
2016-05-26 03:29:22 +08:00
</div>
);
2016-05-26 03:29:22 +08:00
}
2016-05-20 02:22:56 +08:00
2016-05-26 03:29:22 +08:00
renderContent() {
return (
<div className={styles.content}>
{this.renderMessages()}
{this.renderParticipants()}
2016-05-20 02:22:56 +08:00
</div>
);
}
2016-05-26 03:29:22 +08:00
renderMessages() {
2016-06-29 03:52:03 +08:00
const {
openChats,
2016-06-30 22:45:19 +08:00
openChat,
2016-06-29 03:52:03 +08:00
} = this.props;
2016-05-26 03:29:22 +08:00
return (
<div className={styles.messages}>
2016-09-15 01:48:50 +08:00
{
!this.state.compact ?
<h3 className={styles.smallTitle}>
<FormattedMessage
id="app.userlist.messagesTitle"
description="Title for the messages list"
defaultMessage="Messages"
/>
</h3> : <hr className={styles.separator}></hr>
}
2016-06-28 21:10:20 +08:00
<div className={styles.scrollableList}>
<ReactCSSTransitionGroup
transitionName={listTransition}
transitionAppear={true}
transitionEnter={true}
transitionLeave={false}
transitionAppearTimeout={0}
transitionEnterTimeout={0}
transitionLeaveTimeout={0}
component="ul"
2016-06-29 03:52:03 +08:00
className={cx(styles.chatsList, styles.scrollableList)}>
{openChats.map(chat => (
2016-06-28 21:10:20 +08:00
<ChatListItem
compact={this.state.compact}
2016-06-28 21:10:20 +08:00
key={chat.id}
2016-06-30 22:45:19 +08:00
openChat={openChat}
2016-06-28 21:10:20 +08:00
chat={chat} />
))}
</ReactCSSTransitionGroup>
</div>
2016-05-26 03:29:22 +08:00
</div>
);
2016-05-26 03:29:22 +08:00
}
renderParticipants() {
2016-06-29 03:52:03 +08:00
const {
users,
currentUser,
userActions,
2016-09-15 01:48:50 +08:00
compact,
isBreakoutRoom,
2016-06-29 03:52:03 +08:00
} = this.props;
2016-06-28 21:10:20 +08:00
2016-05-26 03:29:22 +08:00
return (
<div className={styles.participants}>
2016-09-15 01:48:50 +08:00
{
!this.state.compact ?
<h3 className={styles.smallTitle}>
<FormattedMessage
2016-12-16 04:03:54 +08:00
id="app.userlist.usersTitle"
description="Title for the Users list"
defaultMessage="Users"
/>
2016-09-15 01:48:50 +08:00
&nbsp;({users.length})
</h3> : <hr className={styles.separator}></hr>
}
2016-06-28 21:10:20 +08:00
<ReactCSSTransitionGroup
transitionName={listTransition}
transitionAppear={true}
transitionEnter={true}
transitionLeave={true}
transitionAppearTimeout={0}
transitionEnterTimeout={0}
transitionLeaveTimeout={0}
component="ul"
2016-06-29 03:52:03 +08:00
className={cx(styles.participantsList, styles.scrollableList)}>
2016-09-15 01:48:50 +08:00
{
users.map(user => (
2016-06-28 21:10:20 +08:00
<UserListItem
compact={this.state.compact}
2016-06-28 21:10:20 +08:00
key={user.id}
isBreakoutRoom={isBreakoutRoom}
2016-06-28 21:10:20 +08:00
user={user}
currentUser={currentUser}
2016-06-29 03:52:03 +08:00
userActions={userActions}
2016-06-28 21:10:20 +08:00
/>
))}
</ReactCSSTransitionGroup>
2016-05-26 03:29:22 +08:00
</div>
);
2016-05-26 03:29:22 +08:00
}
2016-05-20 02:22:56 +08:00
}
2016-06-29 03:52:03 +08:00
UserList.propTypes = propTypes;
export default withRouter(UserList);