2020-03-25 20:52:23 +08:00
|
|
|
import React, { Component } from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2016-12-06 04:00:09 +08:00
|
|
|
import cx from 'classnames';
|
2017-05-03 23:06:28 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2018-11-01 02:51:56 +08:00
|
|
|
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';
|
2017-03-29 23:22:26 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2020-04-29 00:43:14 +08:00
|
|
|
import Icon from '../icon/component';
|
2018-02-23 01:30:12 +08:00
|
|
|
import { styles } from './styles.scss';
|
2020-06-05 07:01:17 +08:00
|
|
|
import Button from '/imports/ui/components/button/component';
|
2019-08-22 02:29:31 +08:00
|
|
|
import RecordingIndicator from './recording-indicator/container';
|
2019-11-02 03:29:33 +08:00
|
|
|
import TalkingIndicatorContainer from '/imports/ui/components/nav-bar/talking-indicator/container';
|
2021-03-26 05:22:50 +08:00
|
|
|
import ConnectionStatusButton from '/imports/ui/components/connection-status/button/container';
|
|
|
|
import ConnectionStatusService from '/imports/ui/components/connection-status/service';
|
2018-02-23 01:30:12 +08:00
|
|
|
import SettingsDropdownContainer from './settings-dropdown/container';
|
2021-09-30 20:43:28 +08:00
|
|
|
import browserInfo from '/imports/utils/browserInfo';
|
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2022-01-06 21:45:35 +08:00
|
|
|
import _ from "lodash";
|
2022-01-24 00:18:09 +08:00
|
|
|
import { politeSRAlert } from '/imports/utils/dom-utils';
|
2021-05-18 04:25:07 +08:00
|
|
|
import { PANELS, ACTIONS } from '../layout/enums';
|
2020-07-16 00:44:59 +08:00
|
|
|
|
2017-03-29 23:22:26 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
toggleUserListLabel: {
|
|
|
|
id: 'app.navBar.userListToggleBtnLabel',
|
2017-04-10 23:50:03 +08:00
|
|
|
description: 'Toggle button label',
|
2017-03-29 23:22:26 +08:00
|
|
|
},
|
2018-02-23 04:27:19 +08:00
|
|
|
toggleUserListAria: {
|
|
|
|
id: 'app.navBar.toggleUserList.ariaLabel',
|
|
|
|
description: 'description of the lists inside the userlist',
|
|
|
|
},
|
2017-04-18 01:00:15 +08:00
|
|
|
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',
|
2017-04-18 01:00:15 +08:00
|
|
|
},
|
2021-12-28 13:40:51 +08:00
|
|
|
newMsgAria: {
|
|
|
|
id: 'app.navBar.toggleUserList.newMsgAria',
|
|
|
|
description: 'label for new message screen reader alert',
|
|
|
|
},
|
2022-01-14 20:59:31 +08:00
|
|
|
defaultBreakoutName: {
|
|
|
|
id: 'app.createBreakoutRoom.room',
|
|
|
|
description: 'default breakout room name',
|
|
|
|
},
|
2017-03-29 23:22:26 +08:00
|
|
|
});
|
2016-04-29 03:02:51 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
2018-11-01 02:51:56 +08:00
|
|
|
presentationTitle: PropTypes.string,
|
|
|
|
hasUnreadMessages: PropTypes.bool,
|
|
|
|
shortcuts: PropTypes.string,
|
2022-01-27 01:16:10 +08:00
|
|
|
breakoutNum: PropTypes.number,
|
|
|
|
breakoutName: PropTypes.string,
|
|
|
|
meetingName: PropTypes.string,
|
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,
|
2018-11-01 02:51:56 +08:00
|
|
|
shortcuts: '',
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
2020-03-25 20:52:23 +08:00
|
|
|
class NavBar extends Component {
|
2021-05-18 04:25:07 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2020-06-20 13:46:10 +08:00
|
|
|
|
2021-12-28 13:40:51 +08:00
|
|
|
this.state = {
|
|
|
|
acs: props.activeChats,
|
|
|
|
}
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
this.handleToggleUserList = this.handleToggleUserList.bind(this);
|
2019-01-16 21:08:20 +08:00
|
|
|
}
|
|
|
|
|
2019-01-04 02:14:35 +08:00
|
|
|
componentDidMount() {
|
2019-01-09 06:17:11 +08:00
|
|
|
const {
|
|
|
|
processOutsideToggleRecording,
|
|
|
|
connectRecordingObserver,
|
2021-09-30 20:43:28 +08:00
|
|
|
shortcuts: TOGGLE_USERLIST_AK,
|
2022-01-14 20:59:31 +08:00
|
|
|
intl,
|
|
|
|
breakoutNum,
|
|
|
|
breakoutName,
|
|
|
|
meetingName,
|
2019-01-09 06:17:11 +08:00
|
|
|
} = this.props;
|
|
|
|
|
2022-01-14 20:59:31 +08:00
|
|
|
if (breakoutNum && breakoutNum > 0) {
|
2022-01-27 01:16:10 +08:00
|
|
|
if (breakoutName && meetingName) {
|
|
|
|
const defaultBreakoutName = intl.formatMessage(intlMessages.defaultBreakoutName, {
|
|
|
|
0: breakoutNum,
|
|
|
|
});
|
2022-01-14 20:59:31 +08:00
|
|
|
|
2022-01-27 01:16:10 +08:00
|
|
|
if (breakoutName === defaultBreakoutName) {
|
|
|
|
document.title = `${breakoutNum} - ${meetingName}`;
|
|
|
|
} else {
|
|
|
|
document.title = `${breakoutName} - ${meetingName}`;
|
|
|
|
}
|
2022-01-14 20:59:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-30 20:43:28 +08:00
|
|
|
const { isFirefox } = browserInfo;
|
|
|
|
const { isMacos } = deviceInfo;
|
|
|
|
|
2019-01-04 05:09:00 +08:00
|
|
|
if (Meteor.settings.public.allowOutsideCommands.toggleRecording
|
2019-07-22 22:28:13 +08:00
|
|
|
|| 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
|
|
|
}
|
2021-09-30 20:43:28 +08:00
|
|
|
|
|
|
|
// accessKey U does not work on firefox for macOS for some unknown reason
|
|
|
|
if (isMacos && isFirefox && TOGGLE_USERLIST_AK === 'U') {
|
|
|
|
document.addEventListener('keyup', (event) => {
|
|
|
|
const { key, code } = event;
|
2021-11-22 08:55:51 +08:00
|
|
|
const eventKey = key?.toUpperCase();
|
2021-09-30 20:43:28 +08:00
|
|
|
const eventCode = code;
|
2021-11-22 08:55:51 +08:00
|
|
|
if (event?.altKey && (eventKey === TOGGLE_USERLIST_AK || eventCode === `Key${TOGGLE_USERLIST_AK}`)) {
|
2021-09-30 20:43:28 +08:00
|
|
|
this.handleToggleUserList();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-01-04 02:14:35 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 13:40:51 +08:00
|
|
|
componentDidUpdate(prevProps, prevState) {
|
2022-01-06 21:45:35 +08:00
|
|
|
if (!_.isEqual(prevProps.activeChats, this.props.activeChats)) {
|
2021-12-28 13:40:51 +08:00
|
|
|
this.setState({ acs: this.props.activeChats})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
handleToggleUserList() {
|
|
|
|
const {
|
|
|
|
sidebarNavigation,
|
|
|
|
sidebarContent,
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2021-05-18 04:25:07 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (sidebarNavigation.isOpen) {
|
|
|
|
if (sidebarContent.isOpen) {
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
|
|
|
value: false,
|
|
|
|
});
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.NONE,
|
|
|
|
});
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_ID_CHAT_OPEN,
|
|
|
|
value: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_SIDEBAR_NAVIGATION_IS_OPEN,
|
|
|
|
value: false,
|
|
|
|
});
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_SIDEBAR_NAVIGATION_PANEL,
|
|
|
|
value: PANELS.NONE,
|
|
|
|
});
|
|
|
|
} else {
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_SIDEBAR_NAVIGATION_IS_OPEN,
|
|
|
|
value: true,
|
|
|
|
});
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch({
|
2021-05-18 04:25:07 +08:00
|
|
|
type: ACTIONS.SET_SIDEBAR_NAVIGATION_PANEL,
|
|
|
|
value: PANELS.USERLIST,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-11 06:08:51 +08:00
|
|
|
render() {
|
2018-05-02 08:02:45 +08:00
|
|
|
const {
|
2018-11-01 02:51:56 +08:00
|
|
|
hasUnreadMessages,
|
2021-04-01 22:58:58 +08:00
|
|
|
hasUnreadNotes,
|
2021-05-18 04:25:07 +08:00
|
|
|
// isExpanded,
|
2021-12-28 13:40:51 +08:00
|
|
|
activeChats,
|
2018-11-01 02:51:56 +08:00
|
|
|
intl,
|
|
|
|
shortcuts: TOGGLE_USERLIST_AK,
|
2019-01-04 02:14:35 +08:00
|
|
|
mountModal,
|
2019-06-07 21:49:50 +08:00
|
|
|
presentationTitle,
|
2019-08-15 04:49:16 +08:00
|
|
|
amIModerator,
|
2021-05-18 04:25:07 +08:00
|
|
|
style,
|
|
|
|
main,
|
|
|
|
sidebarNavigation,
|
2018-05-02 08:02:45 +08:00
|
|
|
} = this.props;
|
2017-10-11 06:08:51 +08:00
|
|
|
|
2021-04-01 22:58:58 +08:00
|
|
|
const hasNotification = hasUnreadMessages || hasUnreadNotes;
|
2017-10-11 06:08:51 +08:00
|
|
|
const toggleBtnClasses = {};
|
|
|
|
toggleBtnClasses[styles.btn] = true;
|
2021-04-01 22:58:58 +08:00
|
|
|
toggleBtnClasses[styles.btnWithNotificationDot] = hasNotification;
|
2017-10-11 06:08:51 +08:00
|
|
|
|
2018-10-16 01:49:17 +08:00
|
|
|
let ariaLabel = intl.formatMessage(intlMessages.toggleUserListAria);
|
2021-04-01 22:58:58 +08:00
|
|
|
ariaLabel += hasNotification ? (` ${intl.formatMessage(intlMessages.newMessages)}`) : '';
|
2018-10-16 01:49:17 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const isExpanded = sidebarNavigation.isOpen;
|
|
|
|
|
2021-12-28 13:40:51 +08:00
|
|
|
const { acs } = this.state;
|
|
|
|
|
|
|
|
activeChats.map((c, i) => {
|
|
|
|
if (c?.unreadCounter > 0 && c?.unreadCounter !== acs[i]?.unreadCounter) {
|
2022-01-24 00:18:09 +08:00
|
|
|
politeSRAlert(`${intl.formatMessage(intlMessages.newMsgAria, { 0: c.name })}`)
|
2021-12-28 13:40:51 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-11 06:08:51 +08:00
|
|
|
return (
|
2021-05-18 04:25:07 +08:00
|
|
|
<header
|
2020-03-25 20:52:23 +08:00
|
|
|
className={styles.navbar}
|
2021-05-18 04:25:07 +08:00
|
|
|
style={
|
|
|
|
main === 'new'
|
|
|
|
? {
|
|
|
|
position: 'absolute',
|
|
|
|
top: style.top,
|
|
|
|
left: style.left,
|
|
|
|
height: style.height,
|
|
|
|
width: style.width,
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
position: 'relative',
|
|
|
|
height: style.height,
|
|
|
|
width: '100%',
|
|
|
|
}
|
|
|
|
}
|
2020-03-25 20:52:23 +08:00
|
|
|
>
|
2019-11-15 02:47:27 +08:00
|
|
|
<div className={styles.top}>
|
|
|
|
<div className={styles.left}>
|
2021-11-05 01:30:47 +08:00
|
|
|
{isExpanded && document.dir === 'ltr'
|
|
|
|
&& <Icon iconName="left_arrow" className={styles.arrowLeft} />}
|
|
|
|
{!isExpanded && document.dir === 'rtl'
|
|
|
|
&& <Icon iconName="left_arrow" className={styles.arrowLeft} />}
|
2019-11-15 02:47:27 +08:00
|
|
|
<Button
|
2021-05-18 04:25:07 +08:00
|
|
|
onClick={this.handleToggleUserList}
|
2019-11-15 02:47:27 +08:00
|
|
|
ghost
|
|
|
|
circle
|
|
|
|
hideLabel
|
2022-01-20 21:03:18 +08:00
|
|
|
data-test={hasNotification ? 'hasUnreadMessages' : 'toggleUserList'}
|
2021-08-27 21:49:20 +08:00
|
|
|
label={intl.formatMessage(intlMessages.toggleUserListLabel)}
|
2021-08-27 20:21:39 +08:00
|
|
|
tooltipLabel={intl.formatMessage(intlMessages.toggleUserListLabel)}
|
2019-11-15 02:47:27 +08:00
|
|
|
aria-label={ariaLabel}
|
|
|
|
icon="user"
|
|
|
|
className={cx(toggleBtnClasses)}
|
|
|
|
aria-expanded={isExpanded}
|
|
|
|
accessKey={TOGGLE_USERLIST_AK}
|
|
|
|
/>
|
2021-11-05 01:30:47 +08:00
|
|
|
{!isExpanded && document.dir === 'ltr'
|
|
|
|
&& <Icon iconName="right_arrow" className={styles.arrowRight} />}
|
|
|
|
{isExpanded && document.dir === 'rtl'
|
|
|
|
&& <Icon iconName="right_arrow" className={styles.arrowRight} />}
|
2019-11-15 02:47:27 +08:00
|
|
|
</div>
|
|
|
|
<div className={styles.center}>
|
2022-01-20 21:03:18 +08:00
|
|
|
<h1 className={styles.presentationTitle} data-test="presentationTitle">
|
|
|
|
{presentationTitle}
|
|
|
|
</h1>
|
2019-08-22 02:29:31 +08:00
|
|
|
|
2019-11-15 02:47:27 +08:00
|
|
|
<RecordingIndicator
|
|
|
|
mountModal={mountModal}
|
|
|
|
amIModerator={amIModerator}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.right}>
|
2021-03-26 05:22:50 +08:00
|
|
|
{ConnectionStatusService.isEnabled() ? <ConnectionStatusButton /> : null}
|
2019-11-15 02:47:27 +08:00
|
|
|
<SettingsDropdownContainer amIModerator={amIModerator} />
|
|
|
|
</div>
|
2017-10-11 06:08:51 +08:00
|
|
|
</div>
|
2019-11-15 02:47:27 +08:00
|
|
|
<div className={styles.bottom}>
|
|
|
|
<TalkingIndicatorContainer amIModerator={amIModerator} />
|
2017-10-11 06:08:51 +08:00
|
|
|
</div>
|
2021-05-18 04:25:07 +08:00
|
|
|
</header>
|
2017-10-11 06:08:51 +08:00
|
|
|
);
|
|
|
|
}
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
NavBar.propTypes = propTypes;
|
|
|
|
NavBar.defaultProps = defaultProps;
|
2018-11-01 02:51:56 +08:00
|
|
|
export default withShortcutHelper(withModalMounter(injectIntl(NavBar)), 'toggleUserList');
|