import React, { Component } from 'react'; import PropTypes from 'prop-types'; import _ from 'lodash'; import cx from 'classnames'; import Icon from '/imports/ui/components/icon/component'; import BreakoutJoinConfirmation from '/imports/ui/components/breakout-join-confirmation/container'; 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 { withModalMounter } from '/imports/ui/components/modal/service'; import { defineMessages, injectIntl } from 'react-intl'; import { styles } from './styles.scss'; import Button from '../button/component'; import RecordingIndicator from './recording-indicator/component'; import SettingsDropdownContainer from './settings-dropdown/container'; const intlMessages = defineMessages({ toggleUserListLabel: { id: 'app.navBar.userListToggleBtnLabel', description: 'Toggle button label', }, toggleUserListAria: { id: 'app.navBar.toggleUserList.ariaLabel', description: 'description of the lists inside the userlist', }, newMessages: { id: 'app.navBar.toggleUserList.newMessages', description: 'label for toggleUserList btn when showing red notification', }, recordingSession: { id: 'app.navBar.recording', description: 'label for when the session is being recorded', }, recordingIndicatorOn: { id: 'app.navBar.recording.on', description: 'label for indicator when the session is being recorded', }, recordingIndicatorOff: { id: 'app.navBar.recording.off', description: 'label for indicator when the session is not being recorded', }, }); const propTypes = { presentationTitle: PropTypes.string.isRequired, hasUnreadMessages: PropTypes.bool.isRequired, beingRecorded: PropTypes.object.isRequired, }; const defaultProps = { presentationTitle: 'Default Room Title', hasUnreadMessages: false, beingRecorded: false, }; const SHORTCUTS_CONFIG = Meteor.settings.public.app.shortcuts; const TOGGLE_USERLIST_AK = SHORTCUTS_CONFIG.toggleUserList.accesskey; const openBreakoutJoinConfirmation = (breakout, breakoutName, mountModal) => mountModal(); const closeBreakoutJoinConfirmation = mountModal => mountModal(null); class NavBar extends Component { constructor(props) { super(props); this.state = { isActionsOpen: false, didSendBreakoutInvite: false, }; this.handleToggleUserList = this.handleToggleUserList.bind(this); } handleToggleUserList() { this.props.toggleUserList(); } componentDidUpdate(oldProps) { const { breakouts, getBreakoutJoinURL, isBreakoutRoom, } = this.props; const hadBreakouts = oldProps.breakouts.length; const hasBreakouts = breakouts.length; if (!hasBreakouts && hadBreakouts) { closeBreakoutJoinConfirmation(this.props.mountModal); } breakouts.forEach((breakout) => { if (!breakout.users) { return; } if (!this.state.didSendBreakoutInvite && !isBreakoutRoom) { this.inviteUserToBreakout(breakout); } }); if (!breakouts.length && this.state.didSendBreakoutInvite) { this.setState({ didSendBreakoutInvite: false }); } } inviteUserToBreakout(breakout) { const { mountModal, } = this.props; this.setState({ didSendBreakoutInvite: true }, () => { openBreakoutJoinConfirmation.call(this, breakout, breakout.name, mountModal); }); } renderPresentationTitle() { const { breakouts, isBreakoutRoom, presentationTitle, } = this.props; if (isBreakoutRoom || !breakouts.length) { return (

{presentationTitle}

); } const breakoutItems = breakouts.map(breakout => this.renderBreakoutItem(breakout)); return (

{presentationTitle}

{breakoutItems}
); } renderBreakoutItem(breakout) { const { mountModal, } = this.props; const breakoutName = breakout.name; return ( ); } render() { const { hasUnreadMessages, beingRecorded, isExpanded, intl, } = this.props; const recordingMessage = beingRecorded.recording ? 'recordingIndicatorOn' : 'recordingIndicatorOff'; const toggleBtnClasses = {}; toggleBtnClasses[styles.btn] = true; toggleBtnClasses[styles.btnWithNotificationDot] = hasUnreadMessages; return (
); } } NavBar.propTypes = propTypes; NavBar.defaultProps = defaultProps; export default withModalMounter(injectIntl(NavBar));