2024-02-06 21:12:25 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2023-11-21 00:30:07 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2024-02-06 21:12:25 +08:00
|
|
|
import EndMeetingConfirmationContainer from '/imports/ui/components/end-meeting-confirmation/container';
|
|
|
|
import BBBMenu from '/imports/ui/components/common/menu/component';
|
|
|
|
import { colorDanger, colorWhite } from '/imports/ui/stylesheets/styled-components/palette';
|
|
|
|
import Styled from './styles';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2023-11-21 00:30:07 +08:00
|
|
|
|
2024-02-06 21:12:25 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
leaveMeetingBtnLabel: {
|
|
|
|
id: 'app.navBar.leaveMeetingBtnLabel',
|
|
|
|
description: 'Leave meeting button label',
|
|
|
|
},
|
|
|
|
leaveMeetingBtnDesc: {
|
|
|
|
id: 'app.navBar.leaveMeetingBtnDesc',
|
|
|
|
description: 'Describes the leave meeting button',
|
|
|
|
},
|
|
|
|
leaveSessionLabel: {
|
|
|
|
id: 'app.navBar.optionsDropdown.leaveSessionLabel',
|
|
|
|
description: 'Leave session button label',
|
|
|
|
},
|
|
|
|
leaveSessionDesc: {
|
2024-02-28 01:45:59 +08:00
|
|
|
id: 'app.navBar.optionsDropdown.leaveSessionDesc',
|
2024-02-06 21:12:25 +08:00
|
|
|
description: 'Describes leave session option',
|
|
|
|
},
|
|
|
|
endMeetingLabel: {
|
|
|
|
id: 'app.navBar.optionsDropdown.endMeetingForAllLabel',
|
|
|
|
description: 'End meeting button label',
|
|
|
|
},
|
|
|
|
endMeetingDesc: {
|
2024-02-28 01:45:59 +08:00
|
|
|
id: 'app.navBar.optionsDropdown.endMeetingDesc',
|
2024-02-06 21:12:25 +08:00
|
|
|
description: 'Describes settings option closing the current meeting',
|
|
|
|
},
|
|
|
|
});
|
2023-11-21 00:30:07 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
2024-02-06 21:12:25 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
amIModerator: PropTypes.bool,
|
|
|
|
isBreakoutRoom: PropTypes.bool,
|
|
|
|
isMeteorConnected: PropTypes.bool.isRequired,
|
|
|
|
isDropdownOpen: PropTypes.bool,
|
|
|
|
isMobile: PropTypes.bool.isRequired,
|
2024-04-05 20:42:32 +08:00
|
|
|
userLeaveMeeting: PropTypes.func.isRequired,
|
2024-02-06 21:12:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
amIModerator: false,
|
|
|
|
isBreakoutRoom: false,
|
|
|
|
isDropdownOpen: false,
|
2023-11-21 00:30:07 +08:00
|
|
|
};
|
|
|
|
|
2024-02-06 21:12:25 +08:00
|
|
|
class LeaveMeetingButton extends PureComponent {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
isEndMeetingConfirmationModalOpen: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set the logout code to 680 because it's not a real code and can be matched on the other side
|
|
|
|
this.LOGOUT_CODE = '680';
|
|
|
|
|
|
|
|
this.setEndMeetingConfirmationModalIsOpen = this
|
|
|
|
.setEndMeetingConfirmationModalIsOpen.bind(this);
|
|
|
|
this.leaveSession = this.leaveSession.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
setEndMeetingConfirmationModalIsOpen(value) {
|
|
|
|
this.setState({ isEndMeetingConfirmationModalOpen: value });
|
|
|
|
}
|
|
|
|
|
|
|
|
leaveSession() {
|
2024-04-05 20:42:32 +08:00
|
|
|
const { userLeaveMeeting } = this.props;
|
|
|
|
|
|
|
|
userLeaveMeeting();
|
2023-11-21 00:30:07 +08:00
|
|
|
// we don't check askForFeedbackOnLogout here,
|
|
|
|
// it is checked in meeting-ended component
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('codeError', this.LOGOUT_CODE);
|
2024-02-06 21:12:25 +08:00
|
|
|
}
|
2023-11-21 00:30:07 +08:00
|
|
|
|
2024-02-06 21:12:25 +08:00
|
|
|
renderMenuItems() {
|
|
|
|
const {
|
|
|
|
intl, amIModerator, isBreakoutRoom, isMeteorConnected,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const allowedToEndMeeting = amIModerator && !isBreakoutRoom;
|
2023-11-21 00:30:07 +08:00
|
|
|
|
2024-03-22 03:41:32 +08:00
|
|
|
const { allowLogout: allowLogoutSetting } = window.meetingClientSettings.public.app;
|
2024-02-06 21:12:25 +08:00
|
|
|
|
|
|
|
this.menuItems = [];
|
|
|
|
|
|
|
|
if (allowLogoutSetting && isMeteorConnected) {
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
|
|
|
key: 'list-item-logout',
|
2024-03-02 00:44:46 +08:00
|
|
|
dataTest: 'directLogoutButton',
|
2024-02-06 21:12:25 +08:00
|
|
|
icon: 'logout',
|
|
|
|
label: intl.formatMessage(intlMessages.leaveSessionLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.leaveSessionDesc),
|
|
|
|
onClick: () => this.leaveSession(),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (allowedToEndMeeting && isMeteorConnected) {
|
|
|
|
const customStyles = { background: colorDanger, color: colorWhite };
|
|
|
|
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
|
|
|
key: 'list-item-end-meeting',
|
2024-02-23 21:09:31 +08:00
|
|
|
dataTest: 'endMeetingButton',
|
2024-02-06 21:12:25 +08:00
|
|
|
icon: 'close',
|
|
|
|
label: intl.formatMessage(intlMessages.endMeetingLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.endMeetingDesc),
|
|
|
|
customStyles,
|
|
|
|
onClick: () => this.setEndMeetingConfirmationModalIsOpen(true),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.menuItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
renderModal(
|
|
|
|
isOpen,
|
|
|
|
setIsOpen,
|
|
|
|
priority,
|
|
|
|
Component,
|
|
|
|
otherOptions,
|
|
|
|
) {
|
|
|
|
return isOpen ? (
|
|
|
|
<Component
|
|
|
|
{...{
|
|
|
|
...otherOptions,
|
|
|
|
onRequestClose: () => setIsOpen(false),
|
|
|
|
priority,
|
|
|
|
setIsOpen,
|
|
|
|
isOpen,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
isDropdownOpen,
|
|
|
|
isMobile,
|
|
|
|
isRTL,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const { isEndMeetingConfirmationModalOpen } = this.state;
|
|
|
|
|
|
|
|
const customStyles = { top: '1rem' };
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<BBBMenu
|
|
|
|
customStyles={!isMobile ? customStyles : null}
|
|
|
|
trigger={(
|
|
|
|
<Styled.LeaveButton
|
|
|
|
state={isDropdownOpen ? 'open' : 'closed'}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.leaveMeetingBtnLabel)}
|
2024-05-04 00:02:53 +08:00
|
|
|
label={intl.formatMessage(intlMessages.leaveMeetingBtnLabel)}
|
2024-02-06 21:12:25 +08:00
|
|
|
tooltipLabel={intl.formatMessage(intlMessages.leaveMeetingBtnLabel)}
|
|
|
|
description={intl.formatMessage(intlMessages.leaveMeetingBtnDesc)}
|
2024-02-23 21:09:31 +08:00
|
|
|
data-test="leaveMeetingDropdown"
|
2024-02-06 21:12:25 +08:00
|
|
|
icon="logout"
|
|
|
|
color="danger"
|
|
|
|
size="lg"
|
2024-05-04 00:02:53 +08:00
|
|
|
hideLabel
|
2024-02-06 21:12:25 +08:00
|
|
|
// FIXME: Without onClick react proptypes keep warning
|
|
|
|
// even after the DropdownTrigger inject an onClick handler
|
|
|
|
onClick={() => null}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
actions={this.renderMenuItems()}
|
|
|
|
opts={{
|
|
|
|
id: 'app-leave-meeting-menu',
|
|
|
|
keepMounted: true,
|
|
|
|
transitionDuration: 0,
|
|
|
|
elevation: 3,
|
|
|
|
getcontentanchorel: null,
|
|
|
|
fullwidth: 'true',
|
|
|
|
anchorOrigin: { vertical: 'bottom', horizontal: isRTL ? 'left' : 'right' },
|
|
|
|
transformorigin: { vertical: 'top', horizontal: isRTL ? 'left' : 'right' },
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{this.renderModal(isEndMeetingConfirmationModalOpen,
|
|
|
|
this.setEndMeetingConfirmationModalIsOpen,
|
|
|
|
'low', EndMeetingConfirmationContainer)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveMeetingButton.propTypes = propTypes;
|
|
|
|
LeaveMeetingButton.defaultProps = defaultProps;
|
|
|
|
export default injectIntl(LeaveMeetingButton);
|