bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/actions-bar/create-breakout-room/component.jsx

1376 lines
43 KiB
React
Raw Normal View History

2019-06-25 02:06:02 +08:00
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { range } from '/imports/utils/array-utils';
2021-04-01 01:13:36 +08:00
import deviceInfo from '/imports/utils/deviceInfo';
2022-02-15 04:20:50 +08:00
import Button from '/imports/ui/components/common/button/component';
import { Session } from 'meteor/session';
import ModalFullscreen from '/imports/ui/components/common/modal/fullscreen/component';
import SortList from './sort-user-list/component';
2021-10-26 03:21:27 +08:00
import Styled from './styles';
import Icon from '/imports/ui/components/common/icon/component';
import { isImportSharedNotesFromBreakoutRoomsEnabled, isImportPresentationWithAnnotationsFromBreakoutRoomsEnabled } from '/imports/ui/services/features';
import { addNewAlert } from '/imports/ui/components/screenreader-alert/service';
import PresentationUploaderService from '/imports/ui/components/presentation/presentation-uploader/service';
2023-02-23 22:23:51 +08:00
import { uniqueId } from '/imports/utils/string-utils';
2018-09-28 22:42:07 +08:00
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
2018-09-28 22:42:07 +08:00
const intlMessages = defineMessages({
2018-10-24 01:18:09 +08:00
breakoutRoomTitle: {
2018-09-28 22:42:07 +08:00
id: 'app.createBreakoutRoom.title',
description: 'modal title',
},
2018-10-24 01:18:09 +08:00
breakoutRoomDesc: {
2018-09-28 22:42:07 +08:00
id: 'app.createBreakoutRoom.modalDesc',
2018-10-30 03:29:45 +08:00
description: 'modal description',
2018-09-28 22:42:07 +08:00
},
breakoutRoomUpdateDesc: {
id: 'app.updateBreakoutRoom.modalDesc',
description: 'update modal description',
},
cancelLabel: {
id: 'app.updateBreakoutRoom.cancelLabel',
description: 'used in the button that close update modal',
},
updateTitle: {
id: 'app.updateBreakoutRoom.title',
description: 'update breakout title',
},
updateConfirm: {
id: 'app.updateBreakoutRoom.confirm',
description: 'Update to breakout confirm button label',
},
resetUserRoom: {
id: 'app.update.resetRoom',
description: 'Reset user room button label',
},
2018-10-24 01:18:09 +08:00
confirmButton: {
id: 'app.createBreakoutRoom.confirm',
2018-10-30 03:29:45 +08:00
description: 'confirm button label',
2018-10-24 01:18:09 +08:00
},
dismissLabel: {
id: 'app.presentationUploder.dismissLabel',
description: 'used in the button that close modal',
},
2018-10-24 01:18:09 +08:00
numberOfRooms: {
id: 'app.createBreakoutRoom.numberOfRooms',
2018-10-30 03:29:45 +08:00
description: 'number of rooms label',
2018-10-24 01:18:09 +08:00
},
duration: {
id: 'app.createBreakoutRoom.durationInMinutes',
2018-10-30 03:29:45 +08:00
description: 'duration time label',
2018-10-24 01:18:09 +08:00
},
resetAssignments: {
id: 'app.createBreakoutRoom.resetAssignments',
description: 'reset assignments label',
},
resetAssignmentsDesc: {
id: 'app.createBreakoutRoom.resetAssignmentsDesc',
description: 'reset assignments label description',
},
2018-10-24 01:18:09 +08:00
randomlyAssign: {
id: 'app.createBreakoutRoom.randomlyAssign',
2018-10-30 03:29:45 +08:00
description: 'randomly assign label',
},
randomlyAssignDesc: {
id: 'app.createBreakoutRoom.randomlyAssignDesc',
description: 'randomly assign label description',
},
breakoutRoom: {
id: 'app.createBreakoutRoom.room',
description: 'breakout room',
2018-10-24 01:18:09 +08:00
},
freeJoinLabel: {
id: 'app.createBreakoutRoom.freeJoin',
description: 'free join label',
},
captureNotesLabel: {
id: 'app.createBreakoutRoom.captureNotes',
description: 'capture shared notes label',
},
captureSlidesLabel: {
id: 'app.createBreakoutRoom.captureSlides',
description: 'capture slides label',
2022-09-06 01:27:38 +08:00
},
captureNotesType: {
id: 'app.notes.label',
description: 'indicates notes have been captured',
},
captureSlidesType: {
id: 'app.shortcut-help.whiteboard',
description: 'indicates the whiteboard has been captured',
},
roomLabel: {
id: 'app.createBreakoutRoom.room',
description: 'Room label',
},
leastOneWarnBreakout: {
id: 'app.createBreakoutRoom.leastOneWarnBreakout',
description: 'warn message label',
},
notAssigned: {
id: 'app.createBreakoutRoom.notAssigned',
description: 'Not assigned label',
},
breakoutRoomLabel: {
id: 'app.createBreakoutRoom.breakoutRoomLabel',
description: 'breakout room label',
},
addParticipantLabel: {
id: 'app.createBreakoutRoom.addParticipantLabel',
description: 'add Participant label',
},
nextLabel: {
id: 'app.createBreakoutRoom.nextLabel',
description: 'Next label',
},
backLabel: {
id: 'app.audio.backLabel',
description: 'Back label',
},
minusRoomTime: {
id: 'app.createBreakoutRoom.minusRoomTime',
description: 'aria label for btn to decrease room time',
},
addRoomTime: {
id: 'app.createBreakoutRoom.addRoomTime',
description: 'aria label for btn to increase room time',
},
record: {
id: 'app.createBreakoutRoom.record',
description: 'label for checkbox to allow record',
},
roomTime: {
id: 'app.createBreakoutRoom.roomTime',
description: 'used to provide current room time for aria label',
},
numberOfRoomsIsValid: {
id: 'app.createBreakoutRoom.numberOfRoomsError',
description: 'Label an error message',
},
roomNameEmptyIsValid: {
id: 'app.createBreakoutRoom.emptyRoomNameError',
description: 'Label an error message',
},
roomNameDuplicatedIsValid: {
id: 'app.createBreakoutRoom.duplicatedRoomNameError',
description: 'Label an error message',
},
you: {
id: 'app.userList.you',
description: 'Text for identifying your user',
},
2021-06-12 00:21:26 +08:00
minimumDurationWarnBreakout: {
id: 'app.createBreakoutRoom.minimumDurationWarnBreakout',
description: 'minimum duration warning message label',
},
roomNameInputDesc: {
id: 'app.createBreakoutRoom.roomNameInputDesc',
description: 'aria description for room name change',
},
movedUserLabel: {
id: 'app.createBreakoutRoom.movedUserLabel',
description: 'screen reader alert when users are moved to rooms',
}
2018-09-28 22:42:07 +08:00
});
const BREAKOUT_LIM = Meteor.settings.public.app.breakouts.breakoutRoomLimit;
const MIN_BREAKOUT_ROOMS = 2;
const MAX_BREAKOUT_ROOMS = BREAKOUT_LIM > MIN_BREAKOUT_ROOMS ? BREAKOUT_LIM : MIN_BREAKOUT_ROOMS;
2021-06-12 00:21:26 +08:00
const MIN_BREAKOUT_TIME = 5;
2018-09-28 22:42:07 +08:00
const propTypes = {
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
isMe: PropTypes.func.isRequired,
meetingName: PropTypes.string.isRequired,
users: PropTypes.arrayOf(PropTypes.object).isRequired,
createBreakoutRoom: PropTypes.func.isRequired,
getUsersNotJoined: PropTypes.func.isRequired,
getBreakouts: PropTypes.func.isRequired,
sendInvitation: PropTypes.func.isRequired,
isBreakoutRecordable: PropTypes.bool,
};
const setPresentationVisibility = (state) => {
const presentationInnerWrapper = document.getElementById('presentationInnerWrapper');
if (presentationInnerWrapper) {
presentationInnerWrapper.style.display = state;
}
}
2019-06-25 02:06:02 +08:00
class BreakoutRoom extends PureComponent {
2018-09-28 22:42:07 +08:00
constructor(props) {
super(props);
2018-10-24 01:18:09 +08:00
this.changeNumberOfRooms = this.changeNumberOfRooms.bind(this);
2018-09-28 22:42:07 +08:00
this.changeDurationTime = this.changeDurationTime.bind(this);
this.changeUserRoom = this.changeUserRoom.bind(this);
2018-09-28 22:42:07 +08:00
this.increaseDurationTime = this.increaseDurationTime.bind(this);
this.decreaseDurationTime = this.decreaseDurationTime.bind(this);
2018-10-24 01:18:09 +08:00
this.onCreateBreakouts = this.onCreateBreakouts.bind(this);
this.setRoomUsers = this.setRoomUsers.bind(this);
this.setFreeJoin = this.setFreeJoin.bind(this);
this.getUserByRoom = this.getUserByRoom.bind(this);
2018-12-17 21:48:42 +08:00
this.onAssignRandomly = this.onAssignRandomly.bind(this);
this.onAssignReset = this.onAssignReset.bind(this);
2018-12-28 00:20:03 +08:00
this.onInviteBreakout = this.onInviteBreakout.bind(this);
this.renderUserItemByRoom = this.renderUserItemByRoom.bind(this);
this.renderRoomsGrid = this.renderRoomsGrid.bind(this);
this.renderBreakoutForm = this.renderBreakoutForm.bind(this);
this.renderCheckboxes = this.renderCheckboxes.bind(this);
this.renderRoomSortList = this.renderRoomSortList.bind(this);
this.renderDesktop = this.renderDesktop.bind(this);
this.renderMobile = this.renderMobile.bind(this);
this.renderButtonSetLevel = this.renderButtonSetLevel.bind(this);
this.renderSelectUserScreen = this.renderSelectUserScreen.bind(this);
2018-12-28 00:20:03 +08:00
this.renderTitle = this.renderTitle.bind(this);
this.handleDismiss = this.handleDismiss.bind(this);
2018-12-28 00:20:03 +08:00
this.setInvitationConfig = this.setInvitationConfig.bind(this);
this.setRecord = this.setRecord.bind(this);
this.setCaptureNotes = this.setCaptureNotes.bind(this);
this.setCaptureSlides = this.setCaptureSlides.bind(this);
this.blurDurationTime = this.blurDurationTime.bind(this);
this.removeRoomUsers = this.removeRoomUsers.bind(this);
this.renderErrorMessages = this.renderErrorMessages.bind(this);
this.onUpdateBreakouts = this.onUpdateBreakouts.bind(this);
2018-11-28 02:00:15 +08:00
2018-09-28 22:42:07 +08:00
this.state = {
numberOfRooms: MIN_BREAKOUT_ROOMS,
selectedId: '',
users: [],
durationTime: 15,
freeJoin: false,
formFillLevel: 1,
roomNamesChanged: [],
roomSelected: 0,
preventClosing: true,
leastOneUserIsValid: true,
numberOfRoomsIsValid: true,
roomNameDuplicatedIsValid: true,
roomNameEmptyIsValid: true,
record: false,
captureNotes: false,
captureSlides: false,
2021-06-12 00:21:26 +08:00
durationIsValid: true,
breakoutJoinedUsers: null,
2018-09-28 22:42:07 +08:00
};
2023-02-23 22:23:51 +08:00
this.btnLevelId = uniqueId('btn-set-level-');
this.handleMoveEvent = this.handleMoveEvent.bind(this);
this.handleShiftUser = this.handleShiftUser.bind(this);
2018-09-28 22:42:07 +08:00
}
componentDidMount() {
const {
2022-04-15 01:38:14 +08:00
breakoutJoinedUsers, getLastBreakouts, groups, isUpdate,
allowUserChooseRoomByDefault, captureSharedNotesByDefault,
captureWhiteboardByDefault,
} = this.props;
setPresentationVisibility('none');
this.setRoomUsers();
if (isUpdate) {
const usersToMerge = []
breakoutJoinedUsers.forEach((breakout) => {
breakout.joinedUsers.forEach((user) => {
usersToMerge.push({
userId: user.userId,
userName: user.name,
from: breakout.sequence,
room: breakout.sequence,
isModerator: user.role === ROLE_MODERATOR,
joined: true,
});
});
});
this.setState((prevState) => {
return {
users: [
...prevState.users,
...usersToMerge,
],
};
});
}
this.setState({
freeJoin: allowUserChooseRoomByDefault,
captureSlides: captureWhiteboardByDefault,
captureNotes: captureSharedNotesByDefault,
});
const lastBreakouts = getLastBreakouts();
if (lastBreakouts.length > 0) {
2021-11-13 04:02:29 +08:00
this.populateWithLastBreakouts(lastBreakouts);
} else if (groups && groups.length > 0) {
2021-11-13 04:02:29 +08:00
this.populateWithGroups(groups);
}
}
2021-08-09 22:24:02 +08:00
componentDidUpdate(prevProps, prevstate) {
if (this.listOfUsers) {
for (let i = 0; i < this.listOfUsers.children.length; i += 1) {
const roomWrapperChildren = this.listOfUsers.children[i].getElementsByTagName('div');
const roomList = roomWrapperChildren[roomWrapperChildren.length > 1 ? 1 : 0];
2021-08-09 22:24:02 +08:00
roomList.addEventListener('keydown', this.handleMoveEvent, true);
}
}
const { numberOfRooms } = this.state;
const { users } = this.props;
const { users: prevUsers } = prevProps;
if (numberOfRooms < prevstate.numberOfRooms) {
this.resetUserWhenRoomsChange(numberOfRooms);
}
const usersCount = users.length;
const prevUsersCount = prevUsers.length;
if (usersCount > prevUsersCount) {
this.setRoomUsers();
}
if (usersCount < prevUsersCount) {
this.removeRoomUsers();
}
}
componentWillUnmount() {
if (this.listOfUsers) {
for (let i = 0; i < this.listOfUsers.children.length; i += 1) {
const roomList = this.listOfUsers.children[i].getElementsByTagName('div')[0];
roomList.removeEventListener('keydown', this.handleMoveEvent, true);
}
}
}
handleShiftUser(activeListSibling) {
const { users } = this.state;
if (activeListSibling) {
const text = activeListSibling.getElementsByTagName('input')[0].value;
const roomNumber = text.match(/\d/g).join('');
2021-08-09 22:24:02 +08:00
users.forEach((u, index) => {
2021-10-26 03:21:27 +08:00
if (`roomUserItem-${u.userId}` === document.activeElement.id) {
2021-08-09 22:24:02 +08:00
users[index].room = text.substr(text.length - 1).includes(')') ? 0 : parseInt(roomNumber, 10);
this.changeUserRoom(u.userId, users[index].room);
}
});
}
}
handleMoveEvent(event) {
if (this.listOfUsers) {
const { activeElement } = document;
if (event.key.includes('ArrowDown')) {
const {
2021-10-26 03:21:27 +08:00
nextElementSibling, id, childNodes, parentElement,
} = activeElement;
2021-10-26 03:21:27 +08:00
if (id.includes('breakoutBox')) return childNodes[0].focus();
2021-10-26 03:21:27 +08:00
if (id.includes('roomUserItem')) {
if (!nextElementSibling) {
return parentElement.firstElementChild.focus();
}
return nextElementSibling.focus();
}
}
if (event.key.includes('ArrowUp')) {
const {
2021-10-26 03:21:27 +08:00
previousElementSibling, id, childNodes, parentElement,
} = activeElement;
2021-10-26 03:21:27 +08:00
if (id.includes('breakoutBox')) return childNodes[childNodes.length - 1].focus();
2021-10-26 03:21:27 +08:00
if (id.includes('roomUserItem')) {
if (!previousElementSibling) {
return parentElement.lastElementChild.focus();
}
return previousElementSibling.focus();
}
}
if (event.key.includes('ArrowRight')) {
const { parentElement: listContainer } = activeElement;
2021-10-26 03:21:27 +08:00
if (listContainer.id.includes('breakoutBox')) {
this.handleShiftUser(listContainer.parentElement.nextSibling);
}
}
if (event.key.includes('ArrowLeft')) {
const { parentElement: listContainer } = activeElement;
2021-10-26 03:21:27 +08:00
if (listContainer.id.includes('breakoutBox')) {
this.handleShiftUser(listContainer.parentElement.previousSibling);
}
}
this.setRoomUsers();
}
2021-08-09 22:24:02 +08:00
return true;
}
2021-08-09 22:24:02 +08:00
handleDismiss() {
const { setIsOpen } = this.props;
setPresentationVisibility('block');
2021-08-09 22:24:02 +08:00
return new Promise((resolve) => {
setIsOpen(false);
2021-08-09 22:24:02 +08:00
this.setState({
preventClosing: false,
}, resolve);
});
}
2018-10-24 01:18:09 +08:00
onCreateBreakouts() {
setPresentationVisibility('block');
2018-10-24 01:18:09 +08:00
const {
createBreakoutRoom,
} = this.props;
2018-12-20 01:08:01 +08:00
const {
users,
freeJoin,
record,
captureNotes,
captureSlides,
numberOfRoomsIsValid,
numberOfRooms,
durationTime,
2021-06-12 00:21:26 +08:00
durationIsValid,
2018-12-20 01:08:01 +08:00
} = this.state;
2018-10-24 01:18:09 +08:00
2021-06-12 00:21:26 +08:00
if ((durationTime || 0) < MIN_BREAKOUT_TIME) {
this.setState({ durationIsValid: false });
return;
}
if (users.length === this.getUserByRoom(0).length && !freeJoin) {
this.setState({ leastOneUserIsValid: false });
return;
}
2021-06-12 00:21:26 +08:00
if (!numberOfRoomsIsValid || !durationIsValid) {
return;
}
const duplicatedNames = range(1, numberOfRooms + 1).filter((n) => this.hasNameDuplicated(n));
if (duplicatedNames.length > 0) {
this.setState({ roomNameDuplicatedIsValid: false });
return;
}
const emptyNames = range(1, numberOfRooms + 1)
2021-08-09 22:24:02 +08:00
.filter((n) => this.getRoomName(n).length === 0);
if (emptyNames.length > 0) {
this.setState({ roomNameEmptyIsValid: false });
return;
}
2021-09-06 21:07:14 +08:00
this.handleDismiss();
const rooms = range(1, numberOfRooms + 1).map((seq) => ({
users: this.getUserByRoom(seq).map((u) => u.userId),
name: this.getFullName(seq),
2023-01-17 07:10:13 +08:00
captureNotesFilename: this.getCaptureFilename(seq, false),
captureSlidesFilename: this.getCaptureFilename(seq),
shortName: this.getRoomName(seq),
isDefaultName: !this.hasNameChanged(seq),
2018-12-20 01:08:01 +08:00
freeJoin,
sequence: seq,
2018-10-30 03:29:45 +08:00
}));
2018-10-24 01:18:09 +08:00
createBreakoutRoom(rooms, durationTime, record, captureNotes, captureSlides);
Session.set('isUserListOpen', true);
2018-10-24 01:18:09 +08:00
}
2018-12-28 00:20:03 +08:00
onInviteBreakout() {
2018-12-28 19:51:41 +08:00
const { getBreakouts, sendInvitation } = this.props;
const { users, freeJoin } = this.state;
2018-12-28 00:20:03 +08:00
const breakouts = getBreakouts();
if (users.length === this.getUserByRoom(0).length && !freeJoin) {
this.setState({ leastOneUserIsValid: false });
2018-12-28 00:20:03 +08:00
return;
}
2019-01-17 01:41:21 +08:00
breakouts.forEach((breakout) => {
const { breakoutId } = breakout;
const breakoutUsers = this.getUserByRoom(breakout.sequence);
breakoutUsers.forEach((user) => sendInvitation(breakoutId, user.userId));
2019-01-17 01:41:21 +08:00
});
2018-12-28 00:20:03 +08:00
2021-09-06 21:07:14 +08:00
this.handleDismiss();
2018-12-28 00:20:03 +08:00
}
getBreakoutBySequence(sequence) {
const { getBreakouts } = this.props;
const breakouts = getBreakouts();
return breakouts.find((breakout) => breakout.sequence === sequence);
}
changeUserBreakout(fromBreakoutId, toBreakoutId, userId) {
const { moveUser } = this.props;
moveUser(fromBreakoutId, toBreakoutId, userId);
}
onUpdateBreakouts() {
setPresentationVisibility('block');
const { users } = this.state;
const leastOneUserIsValid = users.some((user) => user.from !== user.room);
if (!leastOneUserIsValid) {
this.setState({ leastOneUserIsValid });
}
users.forEach((user) => {
const { from, room } = user;
let { userId } = user;
2022-04-13 00:56:54 +08:00
if (from === room) return;
2022-04-13 00:56:54 +08:00
let toBreakoutId = '';
if (room !== 0) {
const toBreakout = this.getBreakoutBySequence(room);
toBreakoutId = toBreakout.breakoutId;
}
2022-04-13 00:56:54 +08:00
let fromBreakoutId = '';
if (from !== 0) {
[userId] = userId.split('-');
const fromBreakout = this.getBreakoutBySequence(from);
fromBreakoutId = fromBreakout.breakoutId;
}
this.changeUserBreakout(fromBreakoutId, toBreakoutId, userId);
});
this.handleDismiss();
}
2018-12-17 21:48:42 +08:00
onAssignRandomly() {
const { numberOfRooms } = this.state;
2019-06-13 06:58:56 +08:00
const { users } = this.state;
// We only want to assign viewers so filter out the moderators. We also want to get
// all users each run so that clicking the button again will reshuffle
const viewers = users.filter((user) => !user.isModerator);
// We want to keep assigning users until all viewers have been assigned a room
2019-06-13 06:58:56 +08:00
while (viewers.length > 0) {
// We cycle through the rooms picking one user for each room so that the rooms
// will have an equal number of people in each one
for (let i = 1; i <= numberOfRooms && viewers.length > 0; i += 1) {
// Select a random user for the room
2019-06-13 06:58:56 +08:00
const userIdx = Math.floor(Math.random() * (viewers.length));
this.changeUserRoom(viewers[userIdx].userId, i);
// Remove the picked user so they aren't selected again
2019-06-13 06:58:56 +08:00
viewers.splice(userIdx, 1);
}
}
2018-12-17 21:48:42 +08:00
}
onAssignReset() {
const { users } = this.state;
users.forEach((u) => {
if (u.room !== null && u.room > 0) {
this.changeUserRoom(u.userId, 0);
}
});
}
2018-12-28 00:20:03 +08:00
setInvitationConfig() {
const { getBreakouts } = this.props;
this.setState({
numberOfRooms: getBreakouts().length,
formFillLevel: 2,
});
}
setRoomUsers() {
const { users, getUsersNotJoined } = this.props;
const { users: stateUsers } = this.state;
const stateUsersId = stateUsers.map((user) => user.userId);
const roomUsers = getUsersNotJoined(users)
.filter((user) => !stateUsersId.includes(user.userId))
.map((user) => ({
userId: user.userId,
2022-04-07 01:35:44 +08:00
extId: user.extId,
userName: user.name,
isModerator: user.role === ROLE_MODERATOR,
from: 0,
room: 0,
}));
this.setState({
users: [
...stateUsers,
...roomUsers,
],
});
}
2018-11-22 00:29:20 +08:00
setFreeJoin(e) {
this.setState({ freeJoin: e.target.checked, leastOneUserIsValid: true });
2018-09-28 22:42:07 +08:00
}
setRecord(e) {
this.setState({ record: e.target.checked });
}
setCaptureNotes(e) {
this.setState({ captureNotes: e.target.checked });
}
setCaptureSlides(e) {
this.setState({ captureSlides: e.target.checked });
2022-09-06 01:27:38 +08:00
}
getUserByRoom(room) {
2018-12-20 01:08:01 +08:00
const { users } = this.state;
return users.filter((user) => user.room === room);
}
getUsersByRoomSequence(sequence) {
const { breakoutJoinedUsers } = this.state;
if (!breakoutJoinedUsers) return [];
return breakoutJoinedUsers.filter((room) => room.sequence === sequence)[0].joinedUsers || [];
}
getRoomName(position, padWithZeroes = false) {
2021-08-09 22:24:02 +08:00
const { intl } = this.props;
const { roomNamesChanged } = this.state;
2021-08-09 22:24:02 +08:00
if (this.hasNameChanged(position)) {
return roomNamesChanged[position];
}
return intl.formatMessage(intlMessages.breakoutRoom, {
0: padWithZeroes ? `${position}`.padStart(2, '0') : position
});
2021-08-09 22:24:02 +08:00
}
2021-08-09 22:24:02 +08:00
getFullName(position) {
const { meetingName } = this.props;
2021-08-09 22:24:02 +08:00
return `${meetingName} (${this.getRoomName(position)})`;
}
getCaptureFilename(position, slides = true) {
const { intl } = this.props;
const presentations = PresentationUploaderService.getPresentations();
const captureType = slides
? intl.formatMessage(intlMessages.captureSlidesType)
: intl.formatMessage(intlMessages.captureNotesType);
const fileName = `${this.getRoomName(position,true)}_${captureType}`.replace(/ /g, '_');
const fileNameDuplicatedCount = presentations.filter((pres) => pres.filename?.startsWith(fileName)
|| pres.name?.startsWith(fileName)).length;
return fileNameDuplicatedCount === 0 ? fileName : `${fileName}(${fileNameDuplicatedCount + 1})`;
}
resetUserWhenRoomsChange(rooms) {
const { users } = this.state;
const filtredUsers = users.filter((u) => u.room > rooms);
filtredUsers.forEach((u) => this.changeUserRoom(u.userId, 0));
}
changeUserRoom(userId, room) {
2022-10-24 21:48:38 +08:00
const { intl } = this.props;
const { users, freeJoin } = this.state;
2018-12-28 00:20:03 +08:00
2021-10-26 03:58:37 +08:00
const idxUser = users.findIndex((user) => user.userId === userId.replace('roomUserItem-', ''));
const usersCopy = [...users];
let userName = null;
if (idxUser >= 0) {
usersCopy[idxUser].room = room;
userName = usersCopy[idxUser].userName;
};
this.setState({
users: usersCopy,
leastOneUserIsValid: (this.getUserByRoom(0).length !== users.length || freeJoin),
}, () => {
addNewAlert(intl.formatMessage(intlMessages.movedUserLabel, { 0: userName, 1: room }))
});
}
2018-09-28 22:42:07 +08:00
increaseDurationTime() {
2018-12-20 01:08:01 +08:00
const { durationTime } = this.state;
2021-06-16 00:17:03 +08:00
const number = ((1 * durationTime) + 1);
const newDurationTime = number > MIN_BREAKOUT_TIME ? number : MIN_BREAKOUT_TIME;
2021-06-12 00:21:26 +08:00
2021-06-16 00:17:03 +08:00
this.setState({ durationTime: newDurationTime, durationIsValid: true });
2018-09-28 22:42:07 +08:00
}
decreaseDurationTime() {
2018-12-20 01:08:01 +08:00
const { durationTime } = this.state;
const number = ((1 * durationTime) - 1);
2021-06-16 00:17:03 +08:00
const newDurationTime = number > MIN_BREAKOUT_TIME ? number : MIN_BREAKOUT_TIME;
2021-06-12 00:21:26 +08:00
2021-06-16 00:17:03 +08:00
this.setState({ durationTime: newDurationTime, durationIsValid: true });
2018-09-28 22:42:07 +08:00
}
2018-11-22 00:29:20 +08:00
changeDurationTime(event) {
2021-06-12 00:21:26 +08:00
const durationTime = Number.parseInt(event.target.value, 10) || '';
const durationIsValid = durationTime >= MIN_BREAKOUT_TIME;
this.setState({ durationTime, durationIsValid });
2018-11-22 00:29:20 +08:00
}
blurDurationTime(event) {
const value = Number.parseInt(event.target.value, 10);
this.setState({ durationTime: !(value <= 0) ? value : 1 });
}
2018-11-22 00:29:20 +08:00
changeNumberOfRooms(event) {
const numberOfRooms = Number.parseInt(event.target.value, 10);
this.setState({
numberOfRooms,
numberOfRoomsIsValid: numberOfRooms <= MAX_BREAKOUT_ROOMS
2021-06-12 00:21:26 +08:00
&& numberOfRooms >= MIN_BREAKOUT_ROOMS,
});
}
2021-08-09 22:24:02 +08:00
removeRoomUsers() {
const { users } = this.props;
const { users: stateUsers } = this.state;
const userIds = users.map((user) => user.userId);
const removeUsers = stateUsers.filter((user) => userIds.includes(user.userId));
2021-08-09 22:24:02 +08:00
this.setState({
users: removeUsers,
});
}
hasNameChanged(position) {
const { intl } = this.props;
const { roomNamesChanged } = this.state;
if (typeof roomNamesChanged[position] !== 'undefined'
2021-08-09 22:24:02 +08:00
&& roomNamesChanged[position] !== intl
.formatMessage(intlMessages.breakoutRoom, { 0: position })) {
return true;
}
2021-08-09 22:24:02 +08:00
return false;
}
hasNameDuplicated(position) {
const { numberOfRooms } = this.state;
const currName = this.getRoomName(position).trim();
const equals = range(1, numberOfRooms + 1)
.filter((n) => this.getRoomName(n).trim() === currName);
if (equals.length > 1) return true;
return false;
}
2021-11-13 04:02:29 +08:00
populateWithLastBreakouts(lastBreakouts) {
const { getBreakoutUserWasIn, users, intl } = this.props;
2021-11-13 04:02:29 +08:00
const changedNames = [];
lastBreakouts.forEach((breakout) => {
if (breakout.isDefaultName === false) {
changedNames[breakout.sequence] = breakout.shortName;
}
});
this.setState({
roomNamesChanged: changedNames,
numberOfRooms: lastBreakouts.length,
roomNameDuplicatedIsValid: true,
roomNameEmptyIsValid: true,
}, () => {
const rooms = range(1, lastBreakouts.length + 1).map((seq) => this.getRoomName(seq));
2021-11-13 04:02:29 +08:00
users.forEach((u) => {
const lastUserBreakout = getBreakoutUserWasIn(u.userId, u.extId);
if (lastUserBreakout !== null) {
const lastUserBreakoutName = lastUserBreakout.isDefaultName === false
? lastUserBreakout.shortName
: intl.formatMessage(intlMessages.breakoutRoom, { 0: lastUserBreakout.sequence });
if (rooms.indexOf(lastUserBreakoutName) !== false) {
this.changeUserRoom(u.userId, rooms.indexOf(lastUserBreakoutName) + 1);
}
}
});
});
}
populateWithGroups(groups) {
const { users } = this.props;
const changedNames = [];
groups.forEach((group, idx) => {
if (group.name.length > 0) {
changedNames[idx + 1] = group.name;
}
});
this.setState({
roomNamesChanged: changedNames,
numberOfRooms: groups.length > 1 ? groups.length : 2,
roomNameDuplicatedIsValid: true,
roomNameEmptyIsValid: true,
}, () => {
groups.forEach((group, groupIdx) => {
const usersInGroup = group.usersExtId;
if (usersInGroup.length > 0) {
usersInGroup.forEach((groupUserExtId) => {
users.filter((u) => u.extId === groupUserExtId).forEach((foundUser) => {
this.changeUserRoom(foundUser.userId, groupIdx + 1);
});
});
}
});
});
}
renderRoomsGrid() {
const { intl, isUpdate } = this.props;
2018-12-20 01:08:01 +08:00
const {
leastOneUserIsValid,
2018-12-20 01:08:01 +08:00
numberOfRooms,
roomNamesChanged,
2018-12-20 01:08:01 +08:00
} = this.state;
2019-06-27 03:27:51 +08:00
const rooms = (numberOfRooms > MAX_BREAKOUT_ROOMS
|| numberOfRooms < MIN_BREAKOUT_ROOMS)
? 0 : numberOfRooms;
const allowDrop = (ev) => {
ev.preventDefault();
};
const drop = (room) => (ev) => {
ev.preventDefault();
const data = ev.dataTransfer.getData('text');
this.changeUserRoom(data, room);
this.setState({ selectedId: '' });
};
const changeRoomName = (position) => (ev) => {
2021-08-09 22:24:02 +08:00
const newRoomsNames = [...roomNamesChanged];
newRoomsNames[position] = ev.target.value;
this.setState({
roomNamesChanged: newRoomsNames,
roomNameDuplicatedIsValid: true,
roomNameEmptyIsValid: true,
});
};
return (
<Styled.BoxContainer key="rooms-grid-" ref={(r) => { this.listOfUsers = r; }} data-test="roomGrid">
2021-10-26 03:21:27 +08:00
<Styled.Alert valid={leastOneUserIsValid} role="alert">
<Styled.FreeJoinLabel>
<Styled.BreakoutNameInput
2021-08-09 22:24:02 +08:00
type="text"
readOnly
value={
intl.formatMessage(intlMessages.notAssigned, { 0: this.getUserByRoom(0).length })
}
/>
2021-10-26 03:21:27 +08:00
</Styled.FreeJoinLabel>
<Styled.BreakoutBox id="breakoutBox-0" onDrop={drop(0)} onDragOver={allowDrop} tabIndex={0}>
{this.renderUserItemByRoom(0)}
2021-10-26 03:21:27 +08:00
</Styled.BreakoutBox>
2022-09-30 19:17:15 +08:00
<Styled.SpanWarn data-test="warningNoUserAssigned" valid={leastOneUserIsValid}>
{intl.formatMessage(intlMessages.leastOneWarnBreakout)}
2021-10-26 03:21:27 +08:00
</Styled.SpanWarn>
</Styled.Alert>
{
range(1, rooms + 1).map((value) => (
<div key={`room-${value}`}>
2021-10-26 03:21:27 +08:00
<Styled.FreeJoinLabel>
<Styled.RoomName
type="text"
maxLength="255"
2021-10-26 03:21:27 +08:00
duplicated={this.hasNameDuplicated(value)}
value={this.getRoomName(value)}
onChange={changeRoomName(value)}
onBlur={changeRoomName(value)}
aria-label={`${this.getRoomName(value)}`}
aria-describedby={this.getRoomName(value).length === 0 ? `room-error-${value}` : `room-input-${value}`}
data-test={this.getRoomName(value).length === 0 ? `room-error-${value}` : `roomName-${value}`}
readOnly={isUpdate}
/>
<div aria-hidden id={`room-input-${value}`} className="sr-only">
{intl.formatMessage(intlMessages.roomNameInputDesc)}
</div>
2021-10-26 03:21:27 +08:00
</Styled.FreeJoinLabel>
<Styled.BreakoutBox id={`breakoutBox-${value}`} onDrop={drop(value)} onDragOver={allowDrop} tabIndex={0}>
2018-12-20 01:08:01 +08:00
{this.renderUserItemByRoom(value)}
2021-10-26 03:21:27 +08:00
</Styled.BreakoutBox>
2021-08-09 22:24:02 +08:00
{this.hasNameDuplicated(value) ? (
2021-10-26 03:21:27 +08:00
<Styled.SpanWarn valid={false}>
{intl.formatMessage(intlMessages.roomNameDuplicatedIsValid)}
2021-10-26 03:21:27 +08:00
</Styled.SpanWarn>
2021-08-09 22:24:02 +08:00
) : null}
{this.getRoomName(value).length === 0 ? (
2021-10-26 03:21:27 +08:00
<Styled.SpanWarn valid={false} aria-hidden id={`room-error-${value}`}>
{intl.formatMessage(intlMessages.roomNameEmptyIsValid)}
2021-10-26 03:21:27 +08:00
</Styled.SpanWarn>
2021-08-09 22:24:02 +08:00
) : null}
</div>
2018-12-20 01:08:01 +08:00
))
}
2021-10-26 03:21:27 +08:00
</Styled.BoxContainer>
);
}
renderBreakoutForm() {
2018-12-28 00:20:03 +08:00
const {
intl,
isUpdate,
2018-12-28 00:20:03 +08:00
} = this.props;
2018-12-20 01:08:01 +08:00
const {
numberOfRooms,
durationTime,
numberOfRoomsIsValid,
2021-06-12 00:21:26 +08:00
durationIsValid,
2018-12-20 01:08:01 +08:00
} = this.state;
2022-04-15 01:38:14 +08:00
if (isUpdate) return null;
2018-12-28 00:20:03 +08:00
return (
<React.Fragment key="breakout-form">
2021-10-26 03:21:27 +08:00
<Styled.BreakoutSettings>
<div>
2021-10-26 03:21:27 +08:00
<Styled.FormLabel valid={numberOfRoomsIsValid} aria-hidden>
{intl.formatMessage(intlMessages.numberOfRooms)}
2021-10-26 03:21:27 +08:00
</Styled.FormLabel>
<Styled.InputRooms
id="numberOfRooms"
name="numberOfRooms"
2021-10-26 03:21:27 +08:00
valid={numberOfRoomsIsValid}
value={numberOfRooms}
onChange={this.changeNumberOfRooms}
aria-label={intl.formatMessage(intlMessages.numberOfRooms)}
>
{
2023-02-23 22:23:51 +08:00
range(MIN_BREAKOUT_ROOMS, MAX_BREAKOUT_ROOMS + 1).map((item) => (<option key={uniqueId('value-')}>{item}</option>))
}
2021-10-26 03:21:27 +08:00
</Styled.InputRooms>
</div>
2021-10-26 03:21:27 +08:00
<Styled.DurationLabel valid={durationIsValid} htmlFor="breakoutRoomTime">
<Styled.LabelText aria-hidden>
{intl.formatMessage(intlMessages.duration)}
2021-10-26 03:21:27 +08:00
</Styled.LabelText>
<Styled.DurationArea>
<Styled.DurationInput
type="number"
min="1"
value={durationTime}
onChange={this.changeDurationTime}
onBlur={this.blurDurationTime}
aria-label={intl.formatMessage(intlMessages.duration)}
2022-09-10 00:54:50 +08:00
data-test="durationTime"
/>
2021-10-26 03:21:27 +08:00
<Styled.HoldButtonWrapper
key="decrease-breakout-time"
exec={this.decreaseDurationTime}
minBound={MIN_BREAKOUT_ROOMS}
value={durationTime}
>
<Button
label={intl.formatMessage(intlMessages.minusRoomTime)}
aria-label={
`${intl.formatMessage(intlMessages.minusRoomTime)} ${intl.formatMessage(intlMessages.roomTime, { 0: durationTime - 1 })}`
}
icon="substract"
2021-06-12 00:21:26 +08:00
onClick={() => { }}
hideLabel
circle
size="sm"
2022-09-10 00:54:50 +08:00
data-test="decreaseBreakoutTime"
/>
2021-10-26 03:21:27 +08:00
</Styled.HoldButtonWrapper>
<Styled.HoldButtonWrapper
key="increase-breakout-time"
exec={this.increaseDurationTime}
>
<Button
label={intl.formatMessage(intlMessages.addRoomTime)}
aria-label={
`${intl.formatMessage(intlMessages.addRoomTime)} ${intl.formatMessage(intlMessages.roomTime, { 0: durationTime + 1 })}`
}
icon="add"
2021-06-12 00:21:26 +08:00
onClick={() => { }}
hideLabel
circle
size="sm"
2022-09-10 00:54:50 +08:00
data-test="increaseBreakoutTime"
/>
2021-10-26 03:21:27 +08:00
</Styled.HoldButtonWrapper>
</Styled.DurationArea>
<Styled.SpanWarn valid={durationIsValid}>
2021-08-09 22:24:02 +08:00
{
intl.formatMessage(
intlMessages.minimumDurationWarnBreakout,
{ 0: MIN_BREAKOUT_TIME },
)
}
2021-10-26 03:21:27 +08:00
</Styled.SpanWarn>
</Styled.DurationLabel>
2021-11-12 01:02:03 +08:00
<Styled.AssignBtnsContainer>
<Styled.AssignBtns
data-test="randomlyAssign"
label={intl.formatMessage(intlMessages.randomlyAssign)}
aria-describedby="randomlyAssignDesc"
onClick={this.onAssignRandomly}
size="sm"
color="default"
disabled={!numberOfRoomsIsValid}
/>
2021-11-12 01:02:03 +08:00
<Styled.AssignBtns
data-test="resetAssignments"
label={intl.formatMessage(intlMessages.resetAssignments)}
aria-describedby="resetAssignmentsDesc"
onClick={this.onAssignReset}
size="sm"
color="default"
disabled={!numberOfRoomsIsValid}
/>
2021-11-12 01:02:03 +08:00
</Styled.AssignBtnsContainer>
2021-10-26 03:21:27 +08:00
</Styled.BreakoutSettings>
<Styled.SpanWarn valid={numberOfRoomsIsValid}>
{intl.formatMessage(intlMessages.numberOfRoomsIsValid)}
2021-10-26 03:21:27 +08:00
</Styled.SpanWarn>
<span aria-hidden id="randomlyAssignDesc" className="sr-only">
{intl.formatMessage(intlMessages.randomlyAssignDesc)}
</span>
</React.Fragment>
);
}
renderSelectUserScreen() {
2018-12-20 01:08:01 +08:00
const {
users,
roomSelected,
} = this.state;
return (
<SortList
confirm={() => this.setState({ formFillLevel: 2 })}
2018-12-20 01:08:01 +08:00
users={users}
room={roomSelected}
onCheck={this.changeUserRoom}
onUncheck={(userId) => this.changeUserRoom(userId, 0)}
/>
);
}
renderCheckboxes() {
2022-09-06 01:27:38 +08:00
const {
intl, isUpdate, isBreakoutRecordable,
} = this.props;
2022-04-15 01:38:14 +08:00
if (isUpdate) return null;
const {
freeJoin,
record,
captureNotes,
captureSlides,
} = this.state;
return (
2021-10-26 03:21:27 +08:00
<Styled.CheckBoxesContainer key="breakout-checkboxes">
<Styled.FreeJoinLabel htmlFor="freeJoinCheckbox" key="free-join-breakouts">
<Styled.FreeJoinCheckbox
type="checkbox"
id="freeJoinCheckbox"
onChange={this.setFreeJoin}
checked={freeJoin}
aria-label={intl.formatMessage(intlMessages.freeJoinLabel)}
/>
<span aria-hidden>{intl.formatMessage(intlMessages.freeJoinLabel)}</span>
2021-10-26 03:21:27 +08:00
</Styled.FreeJoinLabel>
{
isBreakoutRecordable ? (
2021-10-26 03:21:27 +08:00
<Styled.FreeJoinLabel htmlFor="recordBreakoutCheckbox" key="record-breakouts">
<Styled.FreeJoinCheckbox
id="recordBreakoutCheckbox"
type="checkbox"
onChange={this.setRecord}
checked={record}
aria-label={intl.formatMessage(intlMessages.record)}
/>
<span aria-hidden>
{intl.formatMessage(intlMessages.record)}
</span>
2021-10-26 03:21:27 +08:00
</Styled.FreeJoinLabel>
) : null
}
2022-09-18 23:53:52 +08:00
{
isImportPresentationWithAnnotationsFromBreakoutRoomsEnabled() ? (
<Styled.FreeJoinLabel htmlFor="captureSlidesBreakoutCheckbox" key="capture-slides-breakouts">
<Styled.FreeJoinCheckbox
id="captureSlidesBreakoutCheckbox"
type="checkbox"
onChange={this.setCaptureSlides}
checked={captureSlides}
aria-label={intl.formatMessage(intlMessages.captureSlidesLabel)}
/>
<span aria-hidden>
{intl.formatMessage(intlMessages.captureSlidesLabel)}
</span>
</Styled.FreeJoinLabel>
) : null
}
{
isImportSharedNotesFromBreakoutRoomsEnabled() ? (
<Styled.FreeJoinLabel htmlFor="captureNotesBreakoutCheckbox" key="capture-notes-breakouts">
2022-09-18 23:53:52 +08:00
<Styled.FreeJoinCheckbox
id="captureNotesBreakoutCheckbox"
2022-09-18 23:53:52 +08:00
type="checkbox"
onChange={this.setCaptureNotes}
checked={captureNotes}
aria-label={intl.formatMessage(intlMessages.captureNotesLabel)}
2022-09-18 23:53:52 +08:00
/>
<span aria-hidden>
{intl.formatMessage(intlMessages.captureNotesLabel)}
2022-09-18 23:53:52 +08:00
</span>
</Styled.FreeJoinLabel>
) : null
}
2021-10-26 03:21:27 +08:00
</Styled.CheckBoxesContainer>
);
}
renderUserItemByRoom(room) {
2018-12-20 01:08:01 +08:00
const {
leastOneUserIsValid,
selectedId,
2018-12-20 01:08:01 +08:00
} = this.state;
const { intl, isMe } = this.props;
2018-11-28 02:00:15 +08:00
const dragStart = (ev) => {
ev.dataTransfer.setData('text', ev.target.id);
this.setState({ selectedId: ev.target.id });
if (!leastOneUserIsValid) {
this.setState({ leastOneUserIsValid: true });
}
2018-11-28 02:00:15 +08:00
};
const dragEnd = () => {
this.setState({ selectedId: '' });
};
return this.getUserByRoom(room)
.map((user) => (
2021-10-26 03:21:27 +08:00
<Styled.RoomUserItem
tabIndex={-1}
2021-10-26 03:21:27 +08:00
id={`roomUserItem-${user.userId}`}
key={user.userId}
selected={selectedId.replace('roomUserItem-', '') === user.userId.replace('roomUserItem-', '')}
2021-10-26 03:21:27 +08:00
disabled={false}
highlight={room !== user.from}
draggable
2018-11-28 02:00:15 +08:00
onDragStart={dragStart}
onDragEnd={dragEnd}
>
<span>
<span>{user.userName}</span>
<i>{(isMe(user.userId)) ? ` (${intl.formatMessage(intlMessages.you)})` : ''}</i>
</span>
{ room !== user.from ? (
<span
className="close"
role="button"
aria-label={intl.formatMessage(intlMessages.resetUserRoom)}
onClick={() => this.changeUserRoom(user.userId, user.from)}
>
<Icon iconName="close" />
</span>
) : null }
2021-10-26 03:21:27 +08:00
</Styled.RoomUserItem>
));
}
renderRoomSortList() {
2022-04-15 01:38:14 +08:00
const { intl } = this.props;
const { numberOfRooms } = this.state;
const onClick = (roomNumber) => this.setState({ formFillLevel: 3, roomSelected: roomNumber });
return (
2021-10-26 03:21:27 +08:00
<Styled.ListContainer>
<span>
{
new Array(numberOfRooms).fill(1).map((room, idx) => (
2021-10-26 03:21:27 +08:00
<Styled.RoomItem>
<Styled.ItemTitle>
{intl.formatMessage(intlMessages.breakoutRoomLabel, { 0: idx + 1 })}
2021-10-26 03:21:27 +08:00
</Styled.ItemTitle>
<Styled.ItemButton
label={intl.formatMessage(intlMessages.addParticipantLabel)}
size="lg"
ghost
color="primary"
onClick={() => onClick(idx + 1)}
/>
2021-10-26 03:21:27 +08:00
</Styled.RoomItem>
))
}
</span>
2022-04-15 01:38:14 +08:00
{this.renderButtonSetLevel(1, intl.formatMessage(intlMessages.backLabel))}
2021-10-26 03:21:27 +08:00
</Styled.ListContainer>
);
}
renderErrorMessages() {
const {
intl,
} = this.props;
const {
leastOneUserIsValid,
numberOfRoomsIsValid,
roomNameDuplicatedIsValid,
roomNameEmptyIsValid,
} = this.state;
return (
<>
{!leastOneUserIsValid
&& (
2021-10-26 03:21:27 +08:00
<Styled.WithError>
2021-06-12 00:21:26 +08:00
{intl.formatMessage(intlMessages.leastOneWarnBreakout)}
2021-10-26 03:21:27 +08:00
</Styled.WithError>
)}
{!numberOfRoomsIsValid
&& (
2021-10-26 03:21:27 +08:00
<Styled.WithError>
2021-06-12 00:21:26 +08:00
{intl.formatMessage(intlMessages.numberOfRoomsIsValid)}
2021-10-26 03:21:27 +08:00
</Styled.WithError>
)}
{!roomNameDuplicatedIsValid
&& (
2021-10-26 03:21:27 +08:00
<Styled.WithError>
2021-08-09 22:24:02 +08:00
{intl.formatMessage(intlMessages.roomNameDuplicatedIsValid)}
2021-10-26 03:21:27 +08:00
</Styled.WithError>
)}
{!roomNameEmptyIsValid
&& (
2021-10-26 03:21:27 +08:00
<Styled.WithError>
2021-08-09 22:24:02 +08:00
{intl.formatMessage(intlMessages.roomNameEmptyIsValid)}
2021-10-26 03:21:27 +08:00
</Styled.WithError>
)}
</>
);
}
renderDesktop() {
return [
this.renderBreakoutForm(),
this.renderCheckboxes(),
this.renderRoomsGrid(),
];
}
renderMobile() {
const { intl } = this.props;
const { formFillLevel } = this.state;
if (formFillLevel === 2) {
return [
this.renderErrorMessages(),
this.renderRoomSortList(),
];
}
if (formFillLevel === 3) {
return [
this.renderErrorMessages(),
this.renderSelectUserScreen(),
];
}
return [
this.renderErrorMessages(),
this.renderBreakoutForm(),
this.renderCheckboxes(),
this.renderButtonSetLevel(2, intl.formatMessage(intlMessages.nextLabel)),
];
}
renderButtonSetLevel(level, label) {
return (
<Button
color="primary"
size="lg"
label={label}
onClick={() => this.setState({ formFillLevel: level })}
key={this.btnLevelId}
/>
);
}
2018-12-28 00:20:03 +08:00
renderTitle() {
const { intl, isUpdate } = this.props;
2018-12-28 00:20:03 +08:00
return (
2021-10-26 03:21:27 +08:00
<Styled.SubTitle>
{ isUpdate
? intl.formatMessage(intlMessages.breakoutRoomUpdateDesc)
: intl.formatMessage(intlMessages.breakoutRoomDesc) }
2021-10-26 03:21:27 +08:00
</Styled.SubTitle>
2018-12-28 00:20:03 +08:00
);
}
render() {
const { intl, isUpdate, isOpen, priority, setIsOpen, } = this.props;
const {
preventClosing,
leastOneUserIsValid,
numberOfRoomsIsValid,
roomNameDuplicatedIsValid,
roomNameEmptyIsValid,
2021-06-12 00:21:26 +08:00
durationIsValid,
} = this.state;
2021-04-01 01:13:36 +08:00
const { isMobile } = deviceInfo;
2018-09-28 22:42:07 +08:00
return (
<ModalFullscreen
2018-12-28 00:20:03 +08:00
title={
2022-04-15 01:38:14 +08:00
isUpdate
? intl.formatMessage(intlMessages.updateTitle)
2018-12-28 00:20:03 +08:00
: intl.formatMessage(intlMessages.breakoutRoomTitle)
}
2018-10-24 01:18:09 +08:00
confirm={
{
2022-04-15 01:38:14 +08:00
label: isUpdate
? intl.formatMessage(intlMessages.updateConfirm)
2018-12-28 00:20:03 +08:00
: intl.formatMessage(intlMessages.confirmButton),
2022-04-15 01:38:14 +08:00
callback: isUpdate ? this.onUpdateBreakouts : this.onCreateBreakouts,
disabled: !leastOneUserIsValid
2021-08-09 22:24:02 +08:00
|| !numberOfRoomsIsValid
|| !roomNameDuplicatedIsValid
|| !roomNameEmptyIsValid
|| !durationIsValid
,
2018-10-24 01:18:09 +08:00
}
}
dismiss={{
callback: this.handleDismiss,
label: isUpdate
? intl.formatMessage(intlMessages.cancelLabel)
: intl.formatMessage(intlMessages.dismissLabel),
}}
2018-12-20 01:08:01 +08:00
preventClosing={preventClosing}
{...{
isOpen,
priority,
setIsOpen,
}}
2018-09-28 22:42:07 +08:00
>
2021-10-26 03:21:27 +08:00
<Styled.Content>
2022-04-15 01:38:14 +08:00
{this.renderTitle()}
2021-04-01 01:13:36 +08:00
{isMobile ? this.renderMobile() : this.renderDesktop()}
2021-10-26 03:21:27 +08:00
</Styled.Content>
</ModalFullscreen>
2018-09-28 22:42:07 +08:00
);
}
}
BreakoutRoom.propTypes = propTypes;
export default injectIntl(BreakoutRoom);