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

204 lines
4.1 KiB
React
Raw Normal View History

2016-04-29 03:02:51 +08:00
import React, { Component, PropTypes } from 'react';
2016-07-29 03:48:26 +08:00
import { FormattedMessage } from 'react-intl';
2016-07-29 03:48:26 +08:00
import LoadingScreen from '../loading-screen/component';
import KickedScreen from '../kicked-screen/component';
import NotificationsBarContainer from '../notifications-bar/container';
2016-07-29 03:48:26 +08:00
import Button from '../button/component';
2016-05-03 06:42:54 +08:00
import styles from './styles';
import cx from 'classnames';
2016-04-29 03:02:51 +08:00
const propTypes = {
navbar: PropTypes.element,
sidebar: PropTypes.element,
sidebarRight: PropTypes.element,
media: PropTypes.element,
actionsbar: PropTypes.element,
captions: PropTypes.element,
modal: PropTypes.element,
2016-04-29 03:02:51 +08:00
};
export default class App extends Component {
2016-09-15 01:48:50 +08:00
constructor(props) {
super(props);
this.state = {
compactUserList: false, //TODO: Change this on userlist resize (?)
};
this.setDefaultSettings = props.setDefaultSettings;
}
setHtmlFontSize(size) {
document.getElementsByTagName('html')[0].style.fontSize = size;
};
componentDidMount() {
this.setDefaultSettings();
this.setHtmlFontSize(this.props.fontSize);
2016-09-15 01:48:50 +08:00
}
renderNavBar() {
2016-04-29 03:02:51 +08:00
const { navbar } = this.props;
2016-05-03 06:42:54 +08:00
if (navbar) {
2016-04-29 03:02:51 +08:00
return (
2016-05-03 06:42:54 +08:00
<header className={styles.navbar}>
2016-04-29 03:02:51 +08:00
{navbar}
</header>
);
}
return false;
}
renderSidebar() {
const { sidebar } = this.props;
2016-04-29 03:02:51 +08:00
2016-05-03 06:42:54 +08:00
if (sidebar) {
2016-04-29 03:02:51 +08:00
return (
<aside className={styles.sidebar}>
2016-04-29 03:02:51 +08:00
{sidebar}
</aside>
);
}
return false;
}
renderUserList() {
2016-09-15 01:48:50 +08:00
let { userList } = this.props;
const { compactUserList } = this.state;
2016-09-15 01:48:50 +08:00
let userListStyle = {};
userListStyle[styles.compact] = compactUserList;
if (userList) {
2016-09-15 01:48:50 +08:00
userList = React.cloneElement(userList, {
compact: compactUserList,
});
return (
<nav className={cx(styles.userList, userListStyle)}>
{userList}
</nav>
);
}
return false;
}
renderChat() {
const { chat } = this.props;
if (chat) {
return (
<section className={styles.chat} role="log">
{chat}
</section>
);
}
return false;
}
2016-04-29 03:02:51 +08:00
renderMedia() {
const { media } = this.props;
2016-05-03 06:42:54 +08:00
if (media) {
2016-04-29 03:02:51 +08:00
return (
2016-05-03 06:42:54 +08:00
<section className={styles.media}>
2016-04-29 03:02:51 +08:00
{media}
</section>
);
}
return false;
}
renderClosedCaptions() {
const { captions } = this.props;
if (captions && this.props.getCaptionsStatus()) {
return (
<section className={styles.closedCaptions}>
{captions}
</section>
);
}
}
renderActionsBar() {
2016-04-29 03:02:51 +08:00
const { actionsbar } = this.props;
2016-05-03 06:42:54 +08:00
if (actionsbar) {
2016-04-29 03:02:51 +08:00
return (
2016-05-03 06:42:54 +08:00
<section className={styles.actionsbar}>
2016-04-29 03:02:51 +08:00
{actionsbar}
</section>
);
}
return false;
}
2016-05-12 04:43:07 +08:00
renderAudioElement() {
return (
<audio id="remote-media" autoPlay="autoplay"></audio>
2016-05-12 04:43:07 +08:00
);
}
renderModal() {
const { modal } = this.props;
if (modal) {
return (<div>{modal}</div>);
}
return false;
}
2016-04-29 03:02:51 +08:00
render() {
2016-07-29 03:48:26 +08:00
if (this.props.wasKicked) {
return (
<KickedScreen>
<FormattedMessage
id="app.kickMessage"
description="Message when the user is kicked out of the meeting"
defaultMessage="You have been kicked out of the meeting"
/>
<br/><br/>
<Button
label={'OK'}
onClick={this.props.redirectToLogoutUrl}/>
</KickedScreen>
);
}
2016-07-09 07:13:26 +08:00
if (this.props.isLoading) {
2016-07-29 03:48:26 +08:00
return <LoadingScreen/>;
}
2016-04-29 03:02:51 +08:00
return (
2016-05-03 06:42:54 +08:00
<main className={styles.main}>
<NotificationsBarContainer />
2016-05-03 06:42:54 +08:00
<section className={styles.wrapper}>
{this.renderUserList()}
{this.renderChat()}
2016-05-03 06:42:54 +08:00
<div className={styles.content}>
{this.renderNavBar()}
2016-04-29 03:02:51 +08:00
{this.renderMedia()}
{this.renderActionsBar()}
2016-04-29 03:02:51 +08:00
</div>
{this.renderSidebar()}
2016-12-21 07:54:39 +08:00
{this.renderClosedCaptions()}
2016-04-29 03:02:51 +08:00
</section>
2016-05-12 04:43:07 +08:00
{this.renderAudioElement()}
{this.renderModal()}
2016-04-29 03:02:51 +08:00
</main>
);
}
}
App.propTypes = propTypes;