2016-04-29 03:02:51 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2016-05-04 04:40:46 +08:00
|
|
|
import styles from './styles.scss';
|
2016-05-20 21:44:27 +08:00
|
|
|
import Button from '../button/component';
|
2016-06-18 06:15:11 +08:00
|
|
|
import RecordButton from './recordbutton/component';
|
2016-09-02 04:19:37 +08:00
|
|
|
import SettingsDropdown from './settings-dropdown/component';
|
2016-11-07 23:52:39 +08:00
|
|
|
import Icon from '/imports/ui/components/icon/component';
|
|
|
|
import Breakouts from '/imports/api/breakouts';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import { showModal } from '/imports/ui/components/app/service';
|
|
|
|
import BreakoutJoinConfirmation from '/imports/ui/components/breakout-join-confirmation/component';
|
|
|
|
|
|
|
|
import Dropdown from '/imports/ui/components/dropdown/component';
|
|
|
|
import DropdownTrigger from '/imports/ui/components/dropdown/trigger/component';
|
|
|
|
import DropdownContent from '/imports/ui/components/dropdown/content/component';
|
|
|
|
import DropdownList from '/imports/ui/components/dropdown/list/component';
|
|
|
|
import DropdownListItem from '/imports/ui/components/dropdown/list/item/component';
|
|
|
|
import DropdownListSeparator from '/imports/ui/components/dropdown/list/separator/component';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
presentationTitle: PropTypes.string.isRequired,
|
|
|
|
hasUnreadMessages: PropTypes.bool.isRequired,
|
2016-06-29 02:50:44 +08:00
|
|
|
beingRecorded: PropTypes.bool.isRequired,
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
2016-05-04 04:40:46 +08:00
|
|
|
presentationTitle: 'Default Room Title',
|
2016-04-29 03:02:51 +08:00
|
|
|
hasUnreadMessages: false,
|
2016-06-29 02:50:44 +08:00
|
|
|
beingRecorded: false,
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
const openBreakoutJoinConfirmation = (breakoutURL, breakoutName) =>
|
|
|
|
showModal(<BreakoutJoinConfirmation
|
|
|
|
breakoutURL={breakoutURL}
|
|
|
|
breakoutName={breakoutName}/>);
|
2016-11-07 23:52:39 +08:00
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
class NavBar extends Component {
|
2016-04-29 03:02:51 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2016-11-07 23:52:39 +08:00
|
|
|
this.state = {
|
|
|
|
isActionsOpen: false,
|
2016-11-14 19:57:10 +08:00
|
|
|
didSendBreakoutInvite: false,
|
|
|
|
timeRemaining: null,
|
2016-11-07 23:52:39 +08:00
|
|
|
};
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
this.handleToggleUserList = this.handleToggleUserList.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleToggleUserList() {
|
2016-07-21 22:24:50 +08:00
|
|
|
this.props.toggleUserList();
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
inviteUserToBreakout(breakout, breakoutURL) {
|
|
|
|
this.setState({ didSendBreakoutInvite: true }, () => {
|
|
|
|
openBreakoutJoinConfirmation.call(this, breakoutURL, breakout.name);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
render() {
|
2016-11-07 23:52:39 +08:00
|
|
|
const { hasUnreadMessages, beingRecorded } = this.props;
|
2016-06-18 06:15:11 +08:00
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2016-05-21 00:29:55 +08:00
|
|
|
<div className={styles.navbar}>
|
|
|
|
<div className={styles.left}>
|
|
|
|
<Button
|
|
|
|
onClick={this.handleToggleUserList}
|
|
|
|
ghost={true}
|
|
|
|
circle={true}
|
2016-06-18 00:42:17 +08:00
|
|
|
hideLabel={true}
|
|
|
|
label={'Toggle User-List'}
|
2016-05-21 00:39:58 +08:00
|
|
|
icon={'user'}
|
2016-06-07 22:33:22 +08:00
|
|
|
className={styles.btn}
|
2016-05-21 00:29:55 +08:00
|
|
|
/>
|
|
|
|
</div>
|
2016-10-12 01:36:28 +08:00
|
|
|
{hasUnreadMessages ? <span className={styles.withdot}></span> : null}
|
2016-05-21 00:29:55 +08:00
|
|
|
<div className={styles.center}>
|
2016-11-07 23:52:39 +08:00
|
|
|
{this.renderPresentationTitle()}
|
2016-06-18 06:15:11 +08:00
|
|
|
<span className={styles.divideBar}> | </span>
|
2016-06-24 22:48:09 +08:00
|
|
|
<div className={styles.record}>
|
2016-06-29 02:50:44 +08:00
|
|
|
<RecordButton beingRecorded={beingRecorded}/>
|
2016-06-24 22:48:09 +08:00
|
|
|
</div>
|
2016-05-21 00:29:55 +08:00
|
|
|
</div>
|
|
|
|
<div className={styles.right}>
|
2016-08-12 04:05:26 +08:00
|
|
|
<SettingsDropdown />
|
2016-05-21 00:29:55 +08:00
|
|
|
</div>
|
2016-04-29 03:02:51 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-11-07 23:52:39 +08:00
|
|
|
|
|
|
|
renderPresentationTitle() {
|
2016-11-14 19:57:10 +08:00
|
|
|
const remainingTime = this.props.timeRemaining;
|
|
|
|
const presentationTitle = this.props.presentationTitle;
|
|
|
|
let breakouts = this.props.breakouts;
|
|
|
|
const meetingId = Auth.getCredentials().meetingId;
|
|
|
|
const currentUserId = Auth.getCredentials().requesterUserId;
|
2016-11-07 23:52:39 +08:00
|
|
|
document.title = presentationTitle;
|
|
|
|
|
|
|
|
breakouts = breakouts.filter(breakout => {
|
|
|
|
if (!breakout.users) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return breakout.users.some(user => user.userId === currentUserId);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!breakouts.length) {
|
|
|
|
return (
|
|
|
|
<h1 className={styles.presentationTitle}>{presentationTitle}</h1>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dropdown
|
|
|
|
isOpen={this.state.isActionsOpen}
|
|
|
|
ref="dropdown">
|
|
|
|
<DropdownTrigger className={styles.DropdownTrigger}>
|
|
|
|
<h1 className={styles.presentationTitle}>
|
|
|
|
{presentationTitle} <Icon iconName='down-arrow'/>
|
|
|
|
</h1>
|
|
|
|
</DropdownTrigger>
|
|
|
|
<DropdownContent
|
|
|
|
placement="bottom">
|
|
|
|
<DropdownList>
|
|
|
|
{breakouts.map(breakout => this.renderBreakoutItem(breakout))}
|
|
|
|
</DropdownList>
|
|
|
|
</DropdownContent>
|
|
|
|
</Dropdown>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
componentDidUpdate() {
|
|
|
|
const { breakouts } = this.props;
|
|
|
|
const currentUserId = Auth.getCredentials().requesterUserId;
|
|
|
|
|
|
|
|
breakouts.map(breakout => {
|
|
|
|
if (!breakout.users) {
|
|
|
|
return;
|
|
|
|
} else if (!breakout.users.find(user => user.userId === currentUserId)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const breakoutURL = this.getBreakoutJoinUrl(breakout);
|
|
|
|
if (!this.state.didSendBreakoutInvite) {
|
|
|
|
this.inviteUserToBreakout(breakout, breakoutURL);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!breakouts.length && this.state.didSendBreakoutInvite) {
|
|
|
|
this.setState({ didSendBreakoutInvite: false });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-07 23:52:39 +08:00
|
|
|
renderBreakoutItem(breakout) {
|
|
|
|
const breakoutName = breakout.name;
|
2016-11-14 19:57:10 +08:00
|
|
|
const breakoutURL = this.getBreakoutJoinUrl(breakout);
|
2016-11-07 23:52:39 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<DropdownListItem
|
|
|
|
className={styles.actionsHeader}
|
|
|
|
key={_.uniqueId('action-header')}
|
|
|
|
label={breakoutName}
|
2016-11-14 19:57:10 +08:00
|
|
|
onClick={openBreakoutJoinConfirmation.bind(this, breakoutURL, breakout.name)}
|
2016-11-07 23:52:39 +08:00
|
|
|
defaultMessage={'batata'}/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
getBreakoutJoinUrl(breakout) {
|
|
|
|
const currentUserId = Auth.getCredentials().requesterUserId;
|
2016-11-14 19:57:10 +08:00
|
|
|
|
|
|
|
if (breakout.users) {
|
|
|
|
const users = breakout.users.find(user => user.userId === currentUserId);
|
|
|
|
if (users) {
|
|
|
|
const urlParams = users.urlParams;
|
|
|
|
return [
|
|
|
|
window.origin,
|
|
|
|
'html5client/join',
|
|
|
|
urlParams.meetingId,
|
|
|
|
urlParams.userId,
|
|
|
|
urlParams.authToken,
|
|
|
|
].join('/');
|
|
|
|
}
|
2016-11-07 23:52:39 +08:00
|
|
|
}
|
|
|
|
}
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
NavBar.propTypes = propTypes;
|
|
|
|
NavBar.defaultProps = defaultProps;
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2016-07-21 22:24:50 +08:00
|
|
|
export default NavBar;
|