bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/nav-bar/component.jsx

125 lines
3.6 KiB
React
Raw Normal View History

2019-08-22 02:57:34 +08:00
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
2018-12-18 23:15:51 +08:00
import { Session } from 'meteor/session';
import cx from 'classnames';
2017-05-03 23:06:28 +08:00
import { withModalMounter } from '/imports/ui/components/modal/service';
import withShortcutHelper from '/imports/ui/components/shortcut-help/service';
2019-01-04 02:14:35 +08:00
import getFromUserSettings from '/imports/ui/services/users-settings';
import { defineMessages, injectIntl } from 'react-intl';
2018-02-23 01:30:12 +08:00
import { styles } from './styles.scss';
import Button from '../button/component';
import RecordingIndicator from './recording-indicator/container';
2018-02-23 01:30:12 +08:00
import SettingsDropdownContainer from './settings-dropdown/container';
2019-08-15 04:49:16 +08:00
const intlMessages = defineMessages({
toggleUserListLabel: {
id: 'app.navBar.userListToggleBtnLabel',
2017-04-10 23:50:03 +08:00
description: 'Toggle button label',
},
toggleUserListAria: {
id: 'app.navBar.toggleUserList.ariaLabel',
description: 'description of the lists inside the userlist',
},
newMessages: {
2017-08-11 00:05:51 +08:00
id: 'app.navBar.toggleUserList.newMessages',
2017-04-26 22:08:47 +08:00
description: 'label for toggleUserList btn when showing red notification',
},
});
2016-04-29 03:02:51 +08:00
const propTypes = {
presentationTitle: PropTypes.string,
hasUnreadMessages: PropTypes.bool,
shortcuts: PropTypes.string,
2016-04-29 03:02:51 +08:00
};
const defaultProps = {
presentationTitle: 'Default Room Title',
2016-04-29 03:02:51 +08:00
hasUnreadMessages: false,
shortcuts: '',
2016-04-29 03:02:51 +08:00
};
2019-08-22 02:57:34 +08:00
class NavBar extends PureComponent {
2019-01-16 21:08:20 +08:00
static handleToggleUserList() {
Session.set(
'openPanel',
Session.get('openPanel') !== ''
? ''
: 'userlist',
);
Session.set('idChatOpen', '');
}
2019-01-04 02:14:35 +08:00
componentDidMount() {
2019-01-09 06:17:11 +08:00
const {
processOutsideToggleRecording,
connectRecordingObserver,
} = this.props;
2019-01-04 05:09:00 +08:00
if (Meteor.settings.public.allowOutsideCommands.toggleRecording
|| getFromUserSettings('bbb_outside_toggle_recording', false)) {
2019-01-09 06:17:11 +08:00
connectRecordingObserver();
window.addEventListener('message', processOutsideToggleRecording);
2019-01-04 02:14:35 +08:00
}
}
componentWillUnmount() {
2019-01-04 05:09:00 +08:00
clearInterval(this.interval);
2019-01-04 02:14:35 +08:00
}
2017-10-11 06:08:51 +08:00
render() {
2018-05-02 08:02:45 +08:00
const {
hasUnreadMessages,
isExpanded,
intl,
shortcuts: TOGGLE_USERLIST_AK,
2019-01-04 02:14:35 +08:00
mountModal,
presentationTitle,
2019-08-15 04:49:16 +08:00
amIModerator,
2018-05-02 08:02:45 +08:00
} = this.props;
2017-10-11 06:08:51 +08:00
2019-01-04 02:14:35 +08:00
2017-10-11 06:08:51 +08:00
const toggleBtnClasses = {};
toggleBtnClasses[styles.btn] = true;
toggleBtnClasses[styles.btnWithNotificationDot] = hasUnreadMessages;
let ariaLabel = intl.formatMessage(intlMessages.toggleUserListAria);
ariaLabel += hasUnreadMessages ? (` ${intl.formatMessage(intlMessages.newMessages)}`) : '';
2017-10-11 06:08:51 +08:00
return (
<div className={styles.navbar}>
<div className={styles.left}>
<Button
2018-01-09 10:43:34 +08:00
data-test="userListToggleButton"
2019-01-16 21:08:20 +08:00
onClick={NavBar.handleToggleUserList}
2017-10-11 06:08:51 +08:00
ghost
circle
hideLabel
label={intl.formatMessage(intlMessages.toggleUserListLabel)}
aria-label={ariaLabel}
2018-02-23 01:30:12 +08:00
icon="user"
2017-10-11 06:08:51 +08:00
className={cx(toggleBtnClasses)}
aria-expanded={isExpanded}
2018-05-02 08:02:45 +08:00
accessKey={TOGGLE_USERLIST_AK}
2017-10-11 06:08:51 +08:00
/>
</div>
2018-02-23 01:30:12 +08:00
<div className={styles.center}>
<h1 className={styles.presentationTitle}>{presentationTitle}</h1>
<RecordingIndicator
2019-01-04 02:14:35 +08:00
mountModal={mountModal}
2019-04-04 04:51:18 +08:00
amIModerator={amIModerator}
/>
2017-10-11 06:08:51 +08:00
</div>
<div className={styles.right}>
2019-08-30 00:32:29 +08:00
<SettingsDropdownContainer amIModerator={amIModerator} />
2017-10-11 06:08:51 +08:00
</div>
</div>
);
}
2016-04-29 03:02:51 +08:00
}
NavBar.propTypes = propTypes;
NavBar.defaultProps = defaultProps;
export default withShortcutHelper(withModalMounter(injectIntl(NavBar)), 'toggleUserList');