2021-09-10 11:05:16 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2021-09-10 11:05:16 +00:00
|
|
|
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-09-10 11:05:16 +00:00
|
|
|
import { Avatar } from '../../../base/avatar';
|
2022-08-25 11:35:19 +00:00
|
|
|
import Icon from '../../../base/icons/components/Icon';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconCheck, IconCloseLarge } from '../../../base/icons/svg';
|
2021-09-10 11:05:16 +00:00
|
|
|
import { withPixelLineHeight } from '../../../base/styles/functions.web';
|
|
|
|
import { admitMultiple } from '../../../lobby/actions.web';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { getKnockingParticipants, getLobbyEnabled } from '../../../lobby/functions';
|
2023-02-02 11:12:31 +00:00
|
|
|
import Drawer from '../../../toolbox/components/web/Drawer';
|
|
|
|
import JitsiPortal from '../../../toolbox/components/web/JitsiPortal';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { showOverflowDrawer } from '../../../toolbox/functions.web';
|
2021-09-10 11:05:16 +00:00
|
|
|
import { useLobbyActions, useParticipantDrawer } from '../../hooks';
|
|
|
|
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-09-10 11:05:16 +00:00
|
|
|
import LobbyParticipantItems from './LobbyParticipantItems';
|
|
|
|
|
2022-11-15 07:50:22 +00:00
|
|
|
const useStyles = makeStyles()(theme => {
|
2021-09-10 11:05:16 +00:00
|
|
|
return {
|
|
|
|
drawerActions: {
|
|
|
|
listStyleType: 'none',
|
|
|
|
margin: 0,
|
|
|
|
padding: 0
|
|
|
|
},
|
|
|
|
drawerItem: {
|
|
|
|
alignItems: 'center',
|
|
|
|
color: theme.palette.text01,
|
|
|
|
display: 'flex',
|
|
|
|
padding: '12px 16px',
|
|
|
|
...withPixelLineHeight(theme.typography.bodyShortRegularLarge),
|
|
|
|
|
|
|
|
'&:first-child': {
|
|
|
|
marginTop: '15px'
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
cursor: 'pointer',
|
|
|
|
background: theme.palette.action02
|
|
|
|
}
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
marginRight: 16
|
|
|
|
},
|
|
|
|
headingContainer: {
|
|
|
|
alignItems: 'center',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between'
|
|
|
|
},
|
|
|
|
heading: {
|
2022-09-13 07:36:00 +00:00
|
|
|
// @ts-ignore
|
2021-09-10 11:05:16 +00:00
|
|
|
...withPixelLineHeight(theme.typography.heading7),
|
|
|
|
color: theme.palette.text02
|
|
|
|
},
|
|
|
|
link: {
|
|
|
|
...withPixelLineHeight(theme.typography.labelBold),
|
|
|
|
color: theme.palette.link01,
|
|
|
|
cursor: 'pointer'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component used to display a list of participants waiting in the lobby.
|
|
|
|
*
|
|
|
|
* @returns {ReactNode}
|
|
|
|
*/
|
|
|
|
export default function LobbyParticipants() {
|
|
|
|
const lobbyEnabled = useSelector(getLobbyEnabled);
|
2022-11-23 09:12:26 +00:00
|
|
|
const participants = useSelector(getKnockingParticipants);
|
2021-09-10 11:05:16 +00:00
|
|
|
const { t } = useTranslation();
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes } = useStyles();
|
2021-09-10 11:05:16 +00:00
|
|
|
const dispatch = useDispatch();
|
|
|
|
const admitAll = useCallback(() => {
|
|
|
|
dispatch(admitMultiple(participants));
|
|
|
|
}, [ dispatch, participants ]);
|
|
|
|
const overflowDrawer = useSelector(showOverflowDrawer);
|
|
|
|
const [ drawerParticipant, closeDrawer, openDrawerForParticipant ] = useParticipantDrawer();
|
|
|
|
const [ admit, reject ] = useLobbyActions(drawerParticipant, closeDrawer);
|
|
|
|
|
|
|
|
if (!lobbyEnabled || !participants.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-11-04 21:10:43 +00:00
|
|
|
<>
|
|
|
|
<div className = { classes.headingContainer }>
|
|
|
|
<div className = { classes.heading }>
|
|
|
|
{t('participantsPane.headings.lobby', { count: participants.length })}
|
|
|
|
</div>
|
2022-01-07 11:43:25 +00:00
|
|
|
{
|
|
|
|
participants.length > 1
|
|
|
|
&& <div
|
|
|
|
className = { classes.link }
|
|
|
|
onClick = { admitAll }>{t('lobby.admitAll')}</div>
|
|
|
|
}
|
2021-09-10 11:05:16 +00:00
|
|
|
</div>
|
2021-11-04 21:10:43 +00:00
|
|
|
<LobbyParticipantItems
|
|
|
|
openDrawerForParticipant = { openDrawerForParticipant }
|
|
|
|
overflowDrawer = { overflowDrawer }
|
|
|
|
participants = { participants } />
|
|
|
|
<JitsiPortal>
|
|
|
|
<Drawer
|
|
|
|
isOpen = { Boolean(drawerParticipant && overflowDrawer) }
|
|
|
|
onClose = { closeDrawer }>
|
|
|
|
<ul className = { classes.drawerActions }>
|
|
|
|
<li className = { classes.drawerItem }>
|
|
|
|
<Avatar
|
|
|
|
className = { classes.icon }
|
2022-09-08 09:52:36 +00:00
|
|
|
participantId = { drawerParticipant?.participantID }
|
2021-11-04 21:10:43 +00:00
|
|
|
size = { 20 } />
|
2022-09-08 09:52:36 +00:00
|
|
|
<span>{ drawerParticipant?.displayName }</span>
|
2021-11-04 21:10:43 +00:00
|
|
|
</li>
|
|
|
|
<li
|
|
|
|
className = { classes.drawerItem }
|
|
|
|
onClick = { admit }>
|
|
|
|
<Icon
|
|
|
|
className = { classes.icon }
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconCheck } />
|
|
|
|
<span>{ t('lobby.admit') }</span>
|
|
|
|
</li>
|
|
|
|
<li
|
|
|
|
className = { classes.drawerItem }
|
|
|
|
onClick = { reject }>
|
|
|
|
<Icon
|
|
|
|
className = { classes.icon }
|
|
|
|
size = { 20 }
|
2022-11-08 10:24:32 +00:00
|
|
|
src = { IconCloseLarge } />
|
2021-11-04 21:10:43 +00:00
|
|
|
<span>{ t('lobby.reject')}</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</Drawer>
|
|
|
|
</JitsiPortal>
|
|
|
|
</>
|
2021-09-10 11:05:16 +00:00
|
|
|
);
|
|
|
|
}
|