bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/chat/component.jsx

83 lines
2.1 KiB
React
Raw Normal View History

2016-04-29 03:02:51 +08:00
import React, { Component } from 'react';
import { Link } from 'react-router';
2016-06-02 00:33:19 +08:00
import styles from './styles';
import { defineMessages, injectIntl } from 'react-intl';
2016-06-02 00:33:19 +08:00
import MessageForm from './message-form/component';
import MessageList from './message-list/component';
import Icon from '../icon/component';
const ELEMENT_ID = 'chat-messages';
2016-04-29 03:02:51 +08:00
const intlMessages = defineMessages({
closeChatLabel: {
id: 'app.chat.closeChatLabel',
2017-04-10 23:50:03 +08:00
description: 'aria-label for closing chat button',
},
});
class Chat extends Component {
2016-06-02 00:33:19 +08:00
constructor(props) {
super(props);
}
2016-04-29 03:02:51 +08:00
render() {
2016-06-02 00:33:19 +08:00
const {
2016-07-01 01:10:36 +08:00
chatID,
chatName,
2016-06-02 00:33:19 +08:00
title,
messages,
2016-07-01 01:10:36 +08:00
scrollPosition,
2016-07-05 21:34:13 +08:00
hasUnreadMessages,
2016-07-12 03:42:54 +08:00
lastReadMessageTime,
2016-06-07 22:19:19 +08:00
isChatLocked,
2016-06-03 02:40:27 +08:00
actions,
intl,
2016-06-02 00:33:19 +08:00
} = this.props;
2016-04-29 03:02:51 +08:00
return (
2016-06-02 00:33:19 +08:00
<section className={styles.chat}>
2017-03-01 06:40:16 +08:00
2016-06-02 00:33:19 +08:00
<header className={styles.header}>
2017-03-17 06:39:34 +08:00
<div className={styles.title}>
<Link
to="/users"
role="button"
aria-label={intl.formatMessage(intlMessages.closeChatLabel, { title: title })}>
<Icon iconName="left_arrow"/> {title}
2017-03-17 06:39:34 +08:00
</Link>
</div>
<div className={styles.closeIcon}>
{
((this.props.chatID == 'public') ?
null :
<Link to="/users">
<Icon iconName="close" onClick={() => actions.handleClosePrivateChat(chatID)}/>
2017-03-17 06:39:34 +08:00
</Link>)
}
</div>
2016-06-02 00:33:19 +08:00
</header>
2017-03-01 06:40:16 +08:00
2016-06-02 00:33:19 +08:00
<MessageList
2016-07-01 01:10:36 +08:00
chatId={chatID}
2016-06-02 00:33:19 +08:00
messages={messages}
id={ELEMENT_ID}
2016-07-01 01:10:36 +08:00
scrollPosition={scrollPosition}
2016-07-05 21:34:13 +08:00
hasUnreadMessages={hasUnreadMessages}
2016-07-01 01:10:36 +08:00
handleScrollUpdate={actions.handleScrollUpdate}
2016-07-05 02:53:47 +08:00
handleReadMessage={actions.handleReadMessage}
2016-07-12 03:42:54 +08:00
lastReadMessageTime={lastReadMessageTime}
2016-06-02 00:33:19 +08:00
/>
2016-06-03 02:40:27 +08:00
<MessageForm
2016-06-07 22:19:19 +08:00
disabled={isChatLocked}
2016-06-03 02:40:27 +08:00
chatAreaId={ELEMENT_ID}
chatTitle={title}
chatName={chatName}
2016-06-03 02:40:27 +08:00
handleSendMessage={actions.handleSendMessage}
/>
2016-06-02 00:33:19 +08:00
</section>
2016-04-29 03:02:51 +08:00
);
}
}
export default injectIntl(Chat);