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

541 lines
16 KiB
React
Raw Normal View History

2021-05-28 02:12:49 +08:00
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { throttle } from 'lodash';
import { defineMessages, injectIntl } from 'react-intl';
import Modal from 'react-modal';
import browserInfo from '/imports/utils/browserInfo';
2021-04-01 01:13:36 +08:00
import deviceInfo from '/imports/utils/deviceInfo';
import PanelManager from '/imports/ui/components/panel-manager/component';
2018-10-12 23:05:53 +08:00
import PollingContainer from '/imports/ui/components/polling/container';
import logger from '/imports/startup/client/logger';
2019-02-27 01:40:01 +08:00
import ActivityCheckContainer from '/imports/ui/components/activity-check/container';
import UserInfoContainer from '/imports/ui/components/user-info/container';
import BreakoutRoomInvitation from '/imports/ui/components/breakout-room/invitation/container';
2021-05-18 04:25:07 +08:00
import { Meteor } from 'meteor/meteor';
2017-10-13 02:53:33 +08:00
import ToastContainer from '../toast/container';
2017-04-19 03:06:51 +08:00
import ModalContainer from '../modal/container';
import NotificationsBarContainer from '../notifications-bar/container';
2017-03-28 04:40:44 +08:00
import AudioContainer from '../audio/container';
import ChatAlertContainer from '../chat/alert/container';
2019-03-16 04:07:14 +08:00
import BannerBarContainer from '/imports/ui/components/banner-bar/container';
import WaitingNotifierContainer from '/imports/ui/components/waiting-users/alert/container';
import LockNotifier from '/imports/ui/components/lock-viewers/notify/container';
2020-06-30 10:43:20 +08:00
import StatusNotifier from '/imports/ui/components/status-notifier/container';
import MediaService from '/imports/ui/components/media/service';
2019-06-13 02:03:23 +08:00
import ManyWebcamsNotifier from '/imports/ui/components/video-provider/many-users-notify/container';
2020-02-26 03:29:14 +08:00
import UploaderContainer from '/imports/ui/components/presentation/presentation-uploader/container';
import RandomUserSelectContainer from '/imports/ui/components/modal/random-user/container';
import { withDraggableContext } from '../media/webcam-draggable-overlay/context';
import NewWebcamContainer from '../webcam/container';
2021-06-09 21:49:59 +08:00
import PresentationAreaContainer from '../presentation/presentation-area/container';
import ScreenshareContainer from '../screenshare/container';
2018-01-08 14:17:18 +08:00
import { styles } from './styles';
2021-05-18 04:25:07 +08:00
import {
2021-05-28 02:12:49 +08:00
LAYOUT_TYPE, DEVICE_TYPE, ACTIONS,
2021-05-18 04:25:07 +08:00
} from '../layout/enums';
import {
isMobile, isTablet, isTabletPortrait, isTabletLandscape, isDesktop,
} from '../layout/utils';
import CustomLayout from '../layout/layout-manager/customLayout';
import SmartLayout from '../layout/layout-manager/smartLayout';
import PresentationFocusLayout from '../layout/layout-manager/presentationFocusLayout';
import VideoFocusLayout from '../layout/layout-manager/videoFocusLayout';
import NavBarContainer from '../nav-bar/container';
import SidebarNavigationContainer from '../sidebar-navigation/container';
import SidebarContentContainer from '../sidebar-content/container';
2019-11-20 01:49:18 +08:00
import { makeCall } from '/imports/ui/services/api';
import ConnectionStatusService from '/imports/ui/components/connection-status/service';
import { NAVBAR_HEIGHT, LARGE_NAVBAR_HEIGHT } from '/imports/ui/components/layout/layout-manager/component';
2016-04-29 03:02:51 +08:00
const MOBILE_MEDIA = 'only screen and (max-width: 40em)';
const APP_CONFIG = Meteor.settings.public.app;
2019-01-04 01:55:10 +08:00
const DESKTOP_FONT_SIZE = APP_CONFIG.desktopFontSize;
const MOBILE_FONT_SIZE = APP_CONFIG.mobileFontSize;
const OVERRIDE_LOCALE = APP_CONFIG.defaultSettings.application.overrideLocale;
const intlMessages = defineMessages({
userListLabel: {
2017-09-23 01:51:47 +08:00
id: 'app.userList.label',
2017-04-10 23:50:03 +08:00
description: 'Aria-label for Userlist Nav',
},
chatLabel: {
2017-09-23 01:23:25 +08:00
id: 'app.chat.label',
2017-04-19 03:42:55 +08:00
description: 'Aria-label for Chat Section',
},
mediaLabel: {
2017-08-11 00:05:51 +08:00
id: 'app.media.label',
2017-04-19 03:42:55 +08:00
description: 'Aria-label for Media Section',
},
2017-08-11 00:05:51 +08:00
actionsBarLabel: {
id: 'app.actionsBar.label',
2017-04-19 03:42:55 +08:00
description: 'Aria-label for ActionsBar Section',
},
iOSWarning: {
id: 'app.iOSWarning.label',
description: 'message indicating to upgrade ios version',
},
clearedEmoji: {
id: 'app.toast.clearedEmoji.label',
2019-06-01 02:48:41 +08:00
description: 'message for cleared emoji status',
},
setEmoji: {
id: 'app.toast.setEmoji.label',
2019-06-01 02:48:41 +08:00
description: 'message when a user emoji has been set',
},
raisedHand: {
id: 'app.toast.setEmoji.raiseHand',
description: 'toast message for raised hand notification',
},
loweredHand: {
id: 'app.toast.setEmoji.lowerHand',
description: 'toast message for lowered hand notification',
},
meetingMuteOn: {
id: 'app.toast.meetingMuteOn.label',
2019-06-01 02:48:41 +08:00
description: 'message used when meeting has been muted',
},
meetingMuteOff: {
id: 'app.toast.meetingMuteOff.label',
2019-06-01 02:48:41 +08:00
description: 'message used when meeting has been unmuted',
},
pollPublishedLabel: {
id: 'app.whiteboard.annotations.poll',
description: 'message displayed when a poll is published',
},
});
2016-04-29 03:02:51 +08:00
const propTypes = {
navbar: PropTypes.element,
sidebar: PropTypes.element,
media: PropTypes.element,
actionsbar: PropTypes.element,
captions: PropTypes.element,
locale: PropTypes.string,
};
const defaultProps = {
navbar: null,
sidebar: null,
media: null,
actionsbar: null,
captions: null,
locale: OVERRIDE_LOCALE || navigator.language,
2016-04-29 03:02:51 +08:00
};
const LAYERED_BREAKPOINT = 640;
const isLayeredView = window.matchMedia(`(max-width: ${LAYERED_BREAKPOINT}px)`);
class App extends Component {
2021-05-18 04:25:07 +08:00
constructor(props) {
super(props);
2016-09-15 01:48:50 +08:00
this.state = {
enableResize: !window.matchMedia(MOBILE_MEDIA).matches,
2016-09-15 01:48:50 +08:00
};
this.handleWindowResize = throttle(this.handleWindowResize).bind(this);
this.shouldAriaHide = this.shouldAriaHide.bind(this);
this.renderMedia = withDraggableContext(this.renderMedia.bind(this));
2021-05-18 04:25:07 +08:00
this.throttledDeviceType = throttle(() => this.setDeviceType(),
50, { trailing: true, leading: true }).bind(this);
}
componentDidMount() {
const {
2021-05-18 04:25:07 +08:00
locale,
notify,
intl,
validIOSVersion,
} = this.props;
const { browserName } = browserInfo;
2021-05-18 04:25:07 +08:00
const { osName } = deviceInfo;
2017-07-04 22:32:22 +08:00
MediaService.setSwapLayout();
Modal.setAppElement('#app');
2017-07-04 22:32:22 +08:00
document.getElementsByTagName('html')[0].lang = locale;
2021-05-20 07:05:26 +08:00
document.getElementsByTagName('html')[0].style.fontSize = isMobile() ? MOBILE_FONT_SIZE : DESKTOP_FONT_SIZE;
const body = document.getElementsByTagName('body')[0];
if (browserName) {
body.classList.add(`browser-${browserName.split(' ').pop()
.toLowerCase()}`);
}
2021-04-01 01:13:36 +08:00
body.classList.add(`os-${osName.split(' ').shift().toLowerCase()}`);
if (!validIOSVersion()) {
notify(
intl.formatMessage(intlMessages.iOSWarning), 'error', 'warning',
);
}
this.handleWindowResize();
window.addEventListener('resize', this.handleWindowResize, false);
2021-05-18 04:25:07 +08:00
window.ondragover = (e) => { e.preventDefault(); };
window.ondrop = (e) => { e.preventDefault(); };
2021-05-20 07:05:26 +08:00
if (isMobile()) makeCall('setMobileUser');
2019-11-20 01:49:18 +08:00
ConnectionStatusService.startRoundTripTime();
logger.info({ logCode: 'app_component_componentdidmount' }, 'Client loaded successfully');
}
componentDidUpdate(prevProps) {
const {
meetingMuted,
notify,
currentUserEmoji,
intl,
hasPublishedPoll,
randomlySelectedUser,
mountModal,
2021-05-18 04:25:07 +08:00
deviceType,
Fancy random viewer selection (#11297) * Revert "Delete bbb-icons-ori.woff" This reverts commit 84937a0d076f79076d8df201e3edb278374df0d0. * Revert "Add files via upload" This reverts commit 391434445ab286a160fde63533fa843175e9e8a0. * Revert "Delete bbb-icons.woff" This reverts commit 7c245c666d9adc7a8a1b1dc88b01bce749109b2f. * Revert "Add files via upload" This reverts commit 6f8c764c4bc35d646d9691cec8298d0ad3b98b11. * Revert "Delete tmp.woff" This reverts commit 5141e653599b4d83ddff6123ed59c1e4eb4d18e0. * Revert "Add files via upload" This reverts commit c8f7b17b0483910b6fa2750b2138cc3895e57145. * Revert "Create tmp.woff" This reverts commit 73c45065944d96f7779971b3535943c96feb2897. * Revert "Delete bbb-icons.woff" This reverts commit 9d01d58527bac04ebbf9be61140a13e7e14d7cc8. * Revert "Revert "Delete bbb-icons.woff"" This reverts commit d221d290cd5ad33b3c455b09f9da36d5788ee152. * Revert "Revert "Revert "Delete bbb-icons.woff""" This reverts commit c415ff02d1bd710e6f8804667c69d3c7d2e4caf1. * Revert "Revert "Delete bbb-icons.woff"" This reverts commit d221d290cd5ad33b3c455b09f9da36d5788ee152. * Revert "Revert "Create tmp.woff"" This reverts commit 267dc412d561c3d2eac49959e4b0ada77b8364bd. * Revert "Delete bbb-icons-ori.woff" This reverts commit 84937a0d076f79076d8df201e3edb278374df0d0. * Revert "Delete bbb-icons.woff" This reverts commit 7c245c666d9adc7a8a1b1dc88b01bce749109b2f. * Revert "Add files via upload" This reverts commit 6f8c764c4bc35d646d9691cec8298d0ad3b98b11. * Revert "Add files via upload" This reverts commit c8f7b17b0483910b6fa2750b2138cc3895e57145. * Revert "Create tmp.woff" This reverts commit 73c45065944d96f7779971b3535943c96feb2897. * Revert "Delete bbb-icons.woff" This reverts commit 9d01d58527bac04ebbf9be61140a13e7e14d7cc8. * Revert "Revert "Delete bbb-icons.woff"" This reverts commit 64a48f2bd6d76ca7fe31bc606682700ec1078592. * Revert "Revert "Revert "Delete bbb-icons.woff""" This reverts commit 9d1b4a068ae4de2ca3ad2e842884c910e16af0b9. * Revert "Revert "Revert "Revert "Delete bbb-icons.woff"""" This reverts commit b60491d933c2c984a5a64fa162026430d5f51485. * Revert "Revert "Revert "Revert "Revert "Delete bbb-icons.woff""""" This reverts commit 16e357091d558afe07bf17c7fedaa13ac8905f27. * Revert "Revert "Revert "Revert "Revert "Revert "Delete bbb-icons.woff"""""" This reverts commit e0b70f20554884f7c9e64104a3f942d3d09bfe24. * Revert "Revert "Revert "Revert "Revert "Revert "Revert "Delete bbb-icons.woff""""""" This reverts commit 7b1bde97edbed7985beb63646d39c3ddc82138e6. * Update UsersMgs.scala * Update selectRandomViewer.js * Update clearRandomlySelectedUser.js * Update addMeeting.js * Update updateRandomViewer.js * Update component.jsx * Update container.jsx * Update component.jsx * Update container.jsx * Update styles.scss * Update en.json * Update SelectRandomViewerReqMsgHdlr.scala * code simplification * in case only one person to be selected * Update en.json * Create en.json * Update en.json * Update component.jsx * Update styles.scss * Update en.json * Update updateRandomViewer.js Fix a typo * Update component.jsx When the presenter is moved to a viewer, in the modal of ex-presenter "somebody is selected" should be displayed. Before this modification, "somebody is the only viewer" was displayed. * add a comment explaining why a condition is needed. * Update en.json * Update en.json * revert (due to the rename UserMgs -> UserMsgs) * Update UsersMsgs.scala
2021-04-15 23:12:10 +08:00
isPresenter,
} = this.props;
2021-04-17 03:55:27 +08:00
if (!isPresenter && randomlySelectedUser.length > 0) mountModal(<RandomUserSelectContainer />);
2019-06-01 02:36:52 +08:00
if (prevProps.currentUserEmoji.status !== currentUserEmoji.status) {
const formattedEmojiStatus = intl.formatMessage({ id: `app.actionsBar.emojiMenu.${currentUserEmoji.status}Label` })
2021-05-18 04:25:07 +08:00
|| currentUserEmoji.status;
const raisedHand = currentUserEmoji.status === 'raiseHand';
let statusLabel = '';
if (currentUserEmoji.status === 'none') {
statusLabel = prevProps.currentUserEmoji.status === 'raiseHand'
? intl.formatMessage(intlMessages.loweredHand)
: intl.formatMessage(intlMessages.clearedEmoji);
} else {
statusLabel = raisedHand
? intl.formatMessage(intlMessages.raisedHand)
: intl.formatMessage(intlMessages.setEmoji, ({ 0: formattedEmojiStatus }));
}
2019-06-01 02:36:52 +08:00
notify(
statusLabel,
2019-06-01 02:36:52 +08:00
'info',
currentUserEmoji.status === 'none'
? 'clear_status'
: 'user',
);
}
if (!prevProps.meetingMuted && meetingMuted) {
notify(
intl.formatMessage(intlMessages.meetingMuteOn), 'info', 'mute',
);
}
if (prevProps.meetingMuted && !meetingMuted) {
notify(
intl.formatMessage(intlMessages.meetingMuteOff), 'info', 'unmute',
);
}
if (!prevProps.hasPublishedPoll && hasPublishedPoll) {
notify(
intl.formatMessage(intlMessages.pollPublishedLabel), 'info', 'polling',
);
}
2021-05-18 04:25:07 +08:00
if (deviceType === null || prevProps.deviceType !== deviceType) this.throttledDeviceType();
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleWindowResize, false);
ConnectionStatusService.stopRoundTripTime();
}
handleWindowResize() {
const { enableResize } = this.state;
const shouldEnableResize = !window.matchMedia(MOBILE_MEDIA).matches;
if (enableResize === shouldEnableResize) return;
this.setState({ enableResize: shouldEnableResize });
2021-05-18 04:25:07 +08:00
this.throttledDeviceType();
}
setDeviceType() {
const { deviceType, newLayoutContextDispatch } = this.props;
let newDeviceType = null;
if (isMobile()) newDeviceType = DEVICE_TYPE.MOBILE;
if (isTablet()) newDeviceType = DEVICE_TYPE.TABLET;
if (isTabletPortrait()) newDeviceType = DEVICE_TYPE.TABLET_PORTRAIT;
if (isTabletLandscape()) newDeviceType = DEVICE_TYPE.TABLET_LANDSCAPE;
if (isDesktop()) newDeviceType = DEVICE_TYPE.DESKTOP;
if (newDeviceType !== deviceType) {
newLayoutContextDispatch({
type: ACTIONS.SET_DEVICE_TYPE,
value: newDeviceType,
});
}
2016-09-15 01:48:50 +08:00
}
shouldAriaHide() {
2021-05-18 04:25:07 +08:00
const { sidebarNavigationIsOpen, sidebarContentIsOpen, isPhone } = this.props;
return sidebarNavigationIsOpen
&& sidebarContentIsOpen
&& (isPhone || isLayeredView.matches);
2019-03-12 08:34:34 +08:00
}
2018-11-20 07:29:48 +08:00
renderPanel() {
const { enableResize } = this.state;
2021-05-18 04:25:07 +08:00
const {
sidebarNavPanel,
sidebarNavigationIsOpen,
sidebarContentPanel,
sidebarContentIsOpen,
isRTL,
} = this.props;
2018-09-15 01:50:18 +08:00
return (
<PanelManager
{...{
2021-05-18 04:25:07 +08:00
sidebarNavPanel,
sidebarNavigationIsOpen,
sidebarContentPanel,
sidebarContentIsOpen,
2018-12-18 23:15:51 +08:00
enableResize,
2019-07-16 03:15:58 +08:00
isRTL,
}}
shouldAriaHide={this.shouldAriaHide}
/>
2018-09-15 01:50:18 +08:00
);
}
renderNavBar() {
const { navbar, isLargeFont } = this.props;
2016-04-29 03:02:51 +08:00
if (!navbar) return null;
const realNavbarHeight = isLargeFont ? LARGE_NAVBAR_HEIGHT : NAVBAR_HEIGHT;
2017-03-17 00:52:43 +08:00
return (
<header
className={styles.navbar}
style={{
height: realNavbarHeight,
}}
>
2017-03-17 00:52:43 +08:00
{navbar}
</header>
);
2016-04-29 03:02:51 +08:00
}
renderSidebar() {
const { sidebar } = this.props;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
if (!sidebar) return null;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
return (
<aside className={styles.sidebar}>
2017-03-17 00:52:43 +08:00
{sidebar}
</aside>
);
}
renderCaptions() {
const { captions } = this.props;
if (!captions) return null;
return (
<div className={styles.captionsWrapper}>
{captions}
2017-05-13 03:17:08 +08:00
</div>
2017-03-17 00:52:43 +08:00
);
2016-04-29 03:02:51 +08:00
}
renderMedia() {
const {
media,
intl,
} = this.props;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
if (!media) return null;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
return (
<section
className={styles.media}
2017-06-03 03:25:02 +08:00
aria-label={intl.formatMessage(intlMessages.mediaLabel)}
aria-hidden={this.shouldAriaHide()}
2017-06-03 03:25:02 +08:00
>
{media}
{this.renderCaptions()}
2017-03-17 00:52:43 +08:00
</section>
);
}
renderActionsBar() {
const {
actionsbar,
intl,
2021-06-01 04:28:57 +08:00
layoutManagerLoaded,
actionsBarStyle,
} = this.props;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
if (!actionsbar) return null;
2016-04-29 03:02:51 +08:00
2016-05-12 04:43:07 +08:00
return (
<section
className={styles.actionsbar}
2017-08-11 00:05:51 +08:00
aria-label={intl.formatMessage(intlMessages.actionsBarLabel)}
aria-hidden={this.shouldAriaHide()}
2021-06-01 04:28:57 +08:00
style={
layoutManagerLoaded === 'new'
? {
position: 'absolute',
top: actionsBarStyle.top,
left: actionsBarStyle.left,
height: actionsBarStyle.height,
width: actionsBarStyle.width,
}
: {
position: 'relative',
}
}
2017-06-03 03:25:02 +08:00
>
{actionsbar}
2017-03-17 00:52:43 +08:00
</section>
2016-05-12 04:43:07 +08:00
);
}
2019-02-27 01:40:01 +08:00
renderActivityCheck() {
const { User } = this.props;
const { inactivityCheck, responseDelay } = User;
return (inactivityCheck ? (
<ActivityCheckContainer
inactivityCheck={inactivityCheck}
responseDelay={responseDelay}
2021-05-03 02:20:49 +08:00
/>
) : null);
2019-02-27 01:40:01 +08:00
}
renderUserInformation() {
const { UserInfo, User } = this.props;
return (UserInfo.length > 0 ? (
<UserInfoContainer
UserInfo={UserInfo}
requesterUserId={User.userId}
meetingId={User.meetingId}
2021-05-03 02:20:49 +08:00
/>
) : null);
}
2021-05-18 04:25:07 +08:00
renderLayoutManager() {
const { layoutType } = this.props;
switch (layoutType) {
case LAYOUT_TYPE.CUSTOM_LAYOUT:
return <CustomLayout />;
case LAYOUT_TYPE.SMART_LAYOUT:
return <SmartLayout />;
case LAYOUT_TYPE.PRESENTATION_FOCUS:
return <PresentationFocusLayout />;
case LAYOUT_TYPE.VIDEO_FOCUS:
return <VideoFocusLayout />;
default:
return <CustomLayout />;
}
}
render() {
const {
2021-05-18 04:25:07 +08:00
customStyle,
customStyleUrl,
layoutManagerLoaded,
sidebarNavigationIsOpen,
sidebarContentIsOpen,
2021-05-28 01:46:27 +08:00
audioAlertEnabled,
2021-05-28 02:12:49 +08:00
pushAlertEnabled,
shouldShowPresentation,
shouldShowScreenshare,
} = this.props;
2016-04-29 03:02:51 +08:00
return (
2021-05-18 04:25:07 +08:00
<>
{this.renderLayoutManager()}
{(layoutManagerLoaded === 'legacy' || layoutManagerLoaded === 'both')
&& (
<main
className={styles.main}
style={{
width: layoutManagerLoaded !== 'both' ? '100%' : '50%',
height: layoutManagerLoaded !== 'both' ? '100%' : '50%',
}}
>
{this.renderActivityCheck()}
{this.renderUserInformation()}
<BannerBarContainer />
<NotificationsBarContainer />
<section className={styles.wrapper}>
<div className={
sidebarNavigationIsOpen
&& sidebarContentIsOpen
? styles.content
: styles.noPanelContent
}
>
<NavBarContainer main="legacy" />
{this.renderMedia()}
{this.renderActionsBar()}
</div>
{this.renderPanel()}
</section>
<UploaderContainer />
<BreakoutRoomInvitation />
<PollingContainer />
<ModalContainer />
<AudioContainer />
<ToastContainer rtl />
2021-05-28 02:12:49 +08:00
{(audioAlertEnabled || pushAlertEnabled)
&& (
<ChatAlertContainer
audioAlertEnabled={audioAlertEnabled}
pushAlertEnabled={pushAlertEnabled}
/>
)}
2021-05-18 04:25:07 +08:00
<WaitingNotifierContainer />
<LockNotifier />
<StatusNotifier status="raiseHand" />
<ManyWebcamsNotifier />
{customStyleUrl ? <link rel="stylesheet" type="text/css" href={customStyleUrl} /> : null}
{customStyle ? <link rel="stylesheet" type="text/css" href={`data:text/css;charset=UTF-8,${encodeURIComponent(customStyle)}`} /> : null}
</main>
)}
{(layoutManagerLoaded === 'new' || layoutManagerLoaded === 'both')
&& (
<>
<div
id="newLayout"
className={styles.newLayout}
style={{
width: layoutManagerLoaded !== 'both' ? '100%' : '50%',
height: layoutManagerLoaded !== 'both' ? '100%' : '50%',
}}
>
<NavBarContainer main="new" />
<SidebarNavigationContainer />
<SidebarContentContainer />
<NewWebcamContainer />
{shouldShowPresentation ? <PresentationAreaContainer /> : null}
{shouldShowScreenshare ? <ScreenshareContainer /> : null}
2021-05-28 21:30:35 +08:00
<ModalContainer />
2021-06-01 04:28:57 +08:00
{this.renderActionsBar()}
2021-05-18 04:25:07 +08:00
</div>
</>
)}
</>
2016-04-29 03:02:51 +08:00
);
}
}
App.propTypes = propTypes;
App.defaultProps = defaultProps;
export default injectIntl(App);