jiti-meet/react/features/base/premeeting/components/web/PreMeetingScreen.tsx

241 lines
7.0 KiB
TypeScript
Raw Normal View History

/* eslint-disable lines-around-comment */
2023-01-30 11:34:56 +00:00
import clsx from 'clsx';
import React, { ReactNode } from 'react';
2023-01-30 11:34:56 +00:00
import { connect } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
2020-05-20 08:25:31 +00:00
import { IReduxState } from '../../../../app/types';
import DeviceStatus from '../../../../prejoin/components/web/preview/DeviceStatus';
// @ts-ignore
import { Toolbox } from '../../../../toolbox/components/web';
import { getConferenceName } from '../../../conference/functions';
import { PREMEETING_BUTTONS, THIRD_PARTY_PREJOIN_BUTTONS } from '../../../config/constants';
import { getToolbarButtons, isToolbarButtonEnabled } from '../../../config/functions.web';
import { withPixelLineHeight } from '../../../styles/functions.web';
2020-05-20 08:25:31 +00:00
import ConnectionStatus from './ConnectionStatus';
// @ts-ignore
2020-05-20 08:25:31 +00:00
import Preview from './Preview';
2023-01-30 11:34:56 +00:00
/* eslint-enable lines-around-comment */
2020-05-20 08:25:31 +00:00
interface IProps {
2020-05-20 08:25:31 +00:00
/**
* The list of toolbar buttons to render.
*/
_buttons: Array<string>;
/**
* The branding background of the premeeting screen(lobby/prejoin).
*/
_premeetingBackground: string;
/**
* The name of the meeting that is about to be joined.
*/
_roomName: string;
2020-05-20 08:25:31 +00:00
/**
* Children component(s) to be rendered on the screen.
*/
children?: ReactNode;
2020-05-20 08:25:31 +00:00
/**
* Additional CSS class names to set on the icon container.
2020-05-20 08:25:31 +00:00
*/
className?: string;
2020-05-20 08:25:31 +00:00
/**
* The name of the participant.
*/
name?: string;
/**
2021-11-04 21:10:43 +00:00
* Indicates whether the copy url button should be shown.
*/
2023-01-30 11:34:56 +00:00
showCopyUrlButton?: boolean;
2020-06-29 07:45:58 +00:00
/**
2021-11-04 21:10:43 +00:00
* Indicates whether the device status should be shown.
2020-06-29 07:45:58 +00:00
*/
showDeviceStatus: boolean;
2020-06-29 07:45:58 +00:00
/**
* The 'Skip prejoin' button to be rendered (if any).
2020-06-29 07:45:58 +00:00
*/
skipPrejoinButton?: ReactNode;
2020-06-29 07:45:58 +00:00
2020-05-20 08:25:31 +00:00
/**
* Whether it's used in the 3rdParty prejoin screen or not.
2020-05-20 08:25:31 +00:00
*/
thirdParty?: boolean;
2020-05-20 08:25:31 +00:00
/**
* Title of the screen.
*/
title?: string;
2020-05-20 08:25:31 +00:00
/**
* True if the preview overlay should be muted, false otherwise.
*/
videoMuted?: boolean;
2020-05-20 08:25:31 +00:00
/**
* The video track to render as preview (if omitted, the default local track will be rendered).
*/
videoTrack?: Object;
2020-05-20 08:25:31 +00:00
}
const useStyles = makeStyles()(theme => {
return {
2023-01-30 11:34:56 +00:00
container: {
height: '100%',
position: 'absolute',
inset: '0 0 0 0',
display: 'flex',
backgroundColor: theme.palette.ui01,
zIndex: 252,
'@media (max-width: 720px)': {
flexDirection: 'column-reverse'
}
},
content: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
flexShrink: 0,
boxSizing: 'border-box',
margin: '0 48px',
padding: '24px 0 16px',
position: 'relative',
width: '300px',
height: '100%',
zIndex: 252,
'@media (max-width: 720px)': {
height: 'auto',
margin: '0 auto'
},
// mobile phone landscape
'@media (max-width: 420px)': {
padding: '16px 16px 0 16px',
width: '100%'
},
'@media (max-width: 400px)': {
padding: '16px'
}
},
contentControls: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
margin: 'auto',
width: '100%'
},
title: {
...withPixelLineHeight(theme.typography.heading4),
color: `${theme.palette.text01}!important`,
marginBottom: theme.spacing(3),
textAlign: 'center',
'@media (max-width: 400px)': {
display: 'none'
}
},
roomName: {
...withPixelLineHeight(theme.typography.heading5),
color: theme.palette.text01,
marginBottom: theme.spacing(4),
overflow: 'hidden',
textAlign: 'center',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
width: '100%'
}
};
});
const PreMeetingScreen = ({
_buttons,
_premeetingBackground,
_roomName,
children,
className,
showDeviceStatus,
skipPrejoinButton,
title,
videoMuted,
videoTrack
}: IProps) => {
const { classes } = useStyles();
const style = _premeetingBackground ? {
background: _premeetingBackground,
backgroundPosition: 'center',
backgroundSize: 'cover'
} : {};
return (
2023-01-30 11:34:56 +00:00
<div className = { clsx('premeeting-screen', classes.container, className) }>
<div style = { style }>
2023-01-30 11:34:56 +00:00
<div className = { classes.content }>
<ConnectionStatus />
2023-01-30 11:34:56 +00:00
<div className = { classes.contentControls }>
<h1 className = { classes.title }>
{title}
</h1>
{_roomName && (
2023-01-30 11:34:56 +00:00
<span className = { classes.roomName }>
{_roomName}
</span>
)}
{children}
{_buttons.length && <Toolbox toolbarButtons = { _buttons } />}
{skipPrejoinButton}
{showDeviceStatus && <DeviceStatus />}
2020-05-20 08:25:31 +00:00
</div>
</div>
</div>
<Preview
videoMuted = { videoMuted }
videoTrack = { videoTrack } />
</div>
);
};
/**
* Maps (parts of) the redux state to the React {@code Component} props.
*
* @param {Object} state - The redux state.
* @param {Object} ownProps - The props passed to the component.
* @returns {Object}
*/
function mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
const { hiddenPremeetingButtons, hideConferenceSubject } = state['features/base/config'];
const toolbarButtons = getToolbarButtons(state);
const premeetingButtons = (ownProps.thirdParty
? THIRD_PARTY_PREJOIN_BUTTONS
: PREMEETING_BUTTONS).filter((b: any) => !(hiddenPremeetingButtons || []).includes(b));
const { premeetingBackground } = state['features/dynamic-branding'];
return {
// For keeping backwards compat.: if we pass an empty hiddenPremeetingButtons
// array through external api, we have all prejoin buttons present on premeeting
// screen regardless of passed values into toolbarButtons config overwrite.
// If hiddenPremeetingButtons is missing, we hide the buttons according to
// toolbarButtons config overwrite.
_buttons: hiddenPremeetingButtons
? premeetingButtons
: premeetingButtons.filter(b => isToolbarButtonEnabled(b, toolbarButtons)),
_premeetingBackground: premeetingBackground,
2023-01-30 11:34:56 +00:00
_roomName: (hideConferenceSubject ? undefined : getConferenceName(state)) ?? ''
};
}
export default connect(mapStateToProps)(PreMeetingScreen);