bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/breakout-room/breakout-dropdown/component.jsx

142 lines
3.7 KiB
React
Raw Normal View History

import React, { PureComponent } from 'react';
import { defineMessages, injectIntl } from 'react-intl';
2023-10-30 21:06:17 +08:00
import BBBMenu from '/imports/ui/components/common/menu/component';
2024-05-01 03:14:22 +08:00
import CreateBreakoutRoomContainerGraphql from '../create-breakout-room/component';
2023-10-30 21:06:17 +08:00
import Trigger from '/imports/ui/components/common/control-header/right/component';
const intlMessages = defineMessages({
options: {
id: 'app.breakout.dropdown.options',
description: 'Breakout options label',
},
manageDuration: {
id: 'app.breakout.dropdown.manageDuration',
description: 'Manage duration label',
},
manageUsers: {
id: 'app.breakout.dropdown.manageUsers',
description: 'Manage users label',
},
destroy: {
id: 'app.breakout.dropdown.destroyAll',
description: 'Destroy breakouts label',
},
});
class BreakoutDropdown extends PureComponent {
constructor(props) {
super(props);
this.state = {
isCreateBreakoutRoomModalOpen: false,
};
this.setCreateBreakoutRoomModalIsOpen = this.setCreateBreakoutRoomModalIsOpen.bind(this);
}
getAvailableActions() {
const {
intl,
openBreakoutTimeManager,
endAllBreakouts,
isMeteorConnected,
amIModerator,
} = this.props;
this.menuItems = [];
this.menuItems.push(
{
key: 'breakoutTimeManager',
dataTest: 'openBreakoutTimeManager',
label: intl.formatMessage(intlMessages.manageDuration),
onClick: () => {
openBreakoutTimeManager();
2023-10-30 21:06:17 +08:00
},
},
);
this.menuItems.push(
{
key: 'updateBreakoutUsers',
dataTest: 'openUpdateBreakoutUsersModal',
label: intl.formatMessage(intlMessages.manageUsers),
onClick: () => {
this.setCreateBreakoutRoomModalIsOpen(true);
2023-10-30 21:06:17 +08:00
},
},
);
if (amIModerator) {
this.menuItems.push(
{
key: 'endAllBreakouts',
dataTest: 'endAllBreakouts',
label: intl.formatMessage(intlMessages.destroy),
disabled: !isMeteorConnected,
onClick: () => {
endAllBreakouts();
2023-10-30 21:06:17 +08:00
},
},
);
}
return this.menuItems;
}
setCreateBreakoutRoomModalIsOpen(value) {
this.setState({
isCreateBreakoutRoomModalOpen: value,
});
}
render() {
const {
intl,
2022-05-13 21:42:19 +08:00
isRTL,
} = this.props;
const { isCreateBreakoutRoomModalOpen } = this.state;
return (
<>
<BBBMenu
trigger={
2023-10-30 21:06:17 +08:00
(
<Trigger
data-test="breakoutOptionsMenu"
icon="more"
label={intl.formatMessage(intlMessages.options)}
aria-label={intl.formatMessage(intlMessages.options)}
onClick={() => null}
/>
)
}
opts={{
2023-10-30 21:06:17 +08:00
id: 'breakoutroom-dropdown-menu',
keepMounted: true,
transitionDuration: 0,
elevation: 3,
2023-05-10 09:31:48 +08:00
getcontentanchorel: null,
2023-10-30 21:06:17 +08:00
fullwidth: 'true',
2022-05-13 21:42:19 +08:00
anchorOrigin: { vertical: 'bottom', horizontal: isRTL ? 'right' : 'left' },
transformOrigin: { vertical: 'top', horizontal: isRTL ? 'right' : 'left' },
}}
actions={this.getAvailableActions()}
/>
2023-10-30 21:06:17 +08:00
{isCreateBreakoutRoomModalOpen ? (
<CreateBreakoutRoomContainerGraphql
{...{
isUpdate: true,
onRequestClose: () => this.setCreateBreakoutRoomModalIsOpen(false),
priority: 'low',
setIsOpen: this.setCreateBreakoutRoomModalIsOpen,
isOpen: isCreateBreakoutRoomModalOpen,
}}
/>
) : null}
</>
);
}
}
export default injectIntl(BreakoutDropdown);