bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/user-list/component.jsx
Gabriel Carvalho de Campes 0cc29d13b1 Polish code
2016-09-14 14:48:50 -03:00

162 lines
4.1 KiB
JavaScript

import React, { Component, PropTypes } from 'react';
import { withRouter } from 'react-router';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import styles from './styles.scss';
import { FormattedMessage } from 'react-intl';
import cx from 'classnames';
import UserListItem from './user-list-item/component.jsx';
import ChatListItem from './chat-list-item/component.jsx';
const propTypes = {
openChats: PropTypes.array.isRequired,
users: PropTypes.array.isRequired,
};
const defaultProps = {
};
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 = {
compact: this.props.compact,
};
}
render() {
return (
<div className={styles.userList}>
{this.renderHeader()}
{this.renderContent()}
</div>
);
}
renderHeader() {
return (
<div className={styles.header}>
{
!this.state.compact ?
<h2 className={styles.headerTitle}>
<FormattedMessage
id="app.userlist.participantsTitle"
description="Title for the Header"
defaultMessage="Participants"
/>
</h2> : null
}
</div>
);
}
renderContent() {
return (
<div className={styles.content}>
{this.renderMessages()}
{this.renderParticipants()}
</div>
);
}
renderMessages() {
const {
openChats,
openChat,
} = this.props;
return (
<div className={styles.messages}>
{
!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>
}
<div className={styles.scrollableList}>
<ReactCSSTransitionGroup
transitionName={listTransition}
transitionAppear={true}
transitionEnter={true}
transitionLeave={false}
transitionAppearTimeout={0}
transitionEnterTimeout={0}
transitionLeaveTimeout={0}
component="ul"
className={cx(styles.chatsList, styles.scrollableList)}>
{openChats.map(chat => (
<ChatListItem
compact={this.state.compact}
key={chat.id}
openChat={openChat}
chat={chat} />
))}
</ReactCSSTransitionGroup>
</div>
</div>
);
}
renderParticipants() {
const {
users,
currentUser,
userActions,
compact,
} = this.props;
return (
<div className={styles.participants}>
{
!this.state.compact ?
<h3 className={styles.smallTitle}>
<FormattedMessage
id="app.userlist.participantsTitle"
description="Title for the Participants list"
defaultMessage="Participants"
/>
&nbsp;({users.length})
</h3> : <hr className={styles.separator}></hr>
}
<ReactCSSTransitionGroup
transitionName={listTransition}
transitionAppear={true}
transitionEnter={true}
transitionLeave={true}
transitionAppearTimeout={0}
transitionEnterTimeout={0}
transitionLeaveTimeout={0}
component="ul"
className={cx(styles.participantsList, styles.scrollableList)}>
{
users.map(user => (
<UserListItem
compact={this.state.compact}
key={user.id}
user={user}
currentUser={currentUser}
userActions={userActions}
/>
))}
</ReactCSSTransitionGroup>
</div>
);
}
}
UserList.propTypes = propTypes;
export default withRouter(UserList);