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

82 lines
2.4 KiB
React
Raw Normal View History

2016-07-21 22:24:50 +08:00
import React, { Component, PropTypes, cloneElement } from 'react';
2016-04-29 03:02:51 +08:00
import { createContainer } from 'meteor/react-meteor-data';
import { withRouter } from 'react-router';
import { defineMessages, injectIntl } from 'react-intl';
import {
getFontSize,
getCaptionsStatus,
} from './service';
2017-04-19 03:06:51 +08:00
import { withModalMounter } from '../modal/service';
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users';
import Breakouts from '/imports/api/breakouts';
import App from './component';
import NavBarContainer from '../nav-bar/container';
import ActionsBarContainer from '../actions-bar/container';
import MediaContainer from '../media/container';
2017-05-02 03:52:57 +08:00
import AudioModalContainer from '../audio/audio-modal/component';
2017-03-24 00:19:02 +08:00
import ClosedCaptionsContainer from '/imports/ui/components/closed-captions/container';
2016-04-29 03:02:51 +08:00
const defaultProps = {
2016-07-21 22:24:50 +08:00
navbar: <NavBarContainer />,
2016-07-23 02:47:54 +08:00
actionsbar: <ActionsBarContainer />,
2016-07-21 22:24:50 +08:00
media: <MediaContainer />,
2016-04-29 03:02:51 +08:00
};
const intlMessages = defineMessages({
kickedMessage: {
id: 'app.error.kicked',
description: 'Message when the user is kicked out of the meeting',
defaultMessage: 'You have been kicked out of the meeting',
},
});
2016-04-29 03:02:51 +08:00
class AppContainer extends Component {
render() {
2016-07-21 22:24:50 +08:00
// inject location on the navbar container
let navbarWithLocation = cloneElement(this.props.navbar, { location: this.props.location });
2016-04-29 03:02:51 +08:00
return (
2016-07-21 22:24:50 +08:00
<App {...this.props} navbar={navbarWithLocation}>
2016-04-29 03:02:51 +08:00
{this.props.children}
</App>
);
}
};
2017-04-19 03:06:51 +08:00
export default withRouter(injectIntl(withModalMounter(createContainer((
{ router, intl, mountModal, baseControls }) => {
// Check if user is kicked out of the session
Users.find({ userId: Auth.userID }).observeChanges({
2017-04-29 00:15:29 +08:00
changed(id, fields) {
if (fields.user && fields.user.kicked) {
Auth.clearCredentials()
.then(() => {
router.push('/error/403');
baseControls.updateErrorState(
intl.formatMessage(intlMessages.kickedMessage),
);
});
}
2017-04-19 03:06:51 +08:00
},
});
2017-04-19 03:06:51 +08:00
// Close the widow when the current breakout room ends
Breakouts.find({ breakoutMeetingId: Auth.meetingID }).observeChanges({
removed(old) {
Auth.clearCredentials().then(window.close);
},
});
2017-04-19 03:06:51 +08:00
return {
sidebar: getCaptionsStatus() ? <ClosedCaptionsContainer /> : null,
fontSize: getFontSize(),
};
}, AppContainer))));
AppContainer.defaultProps = defaultProps;