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

186 lines
5.8 KiB
React
Raw Normal View History

2018-09-28 22:42:07 +08:00
import React, { Component } from 'react';
import Modal from '/imports/ui/components/modal/fullscreen/component';
import { defineMessages, injectIntl } from 'react-intl';
2018-09-29 02:09:15 +08:00
import _ from 'lodash';
import HoldButton from '/imports/ui/components/presentation/presentation-toolbar/zoom-tool/holdButton/component';
2018-09-28 22:42:07 +08:00
import { styles } from './styles';
import Icon from '../../icon/component';
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
},
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
},
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
},
randomlyAssign: {
id: 'app.createBreakoutRoom.randomlyAssign',
2018-10-30 03:29:45 +08:00
description: 'randomly assign label',
},
roomName: {
id: 'app.createBreakoutRoom.roomName',
description: 'room intl to name the breakout meetings',
2018-10-24 01:18:09 +08:00
},
2018-09-28 22:42:07 +08:00
});
const MIN_BREAKOUT_ROOMS = 2;
const MAX_BREAKOUT_ROOMS = 8;
2018-09-28 22:42:07 +08:00
class BreakoutRoom extends Component {
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.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.setFreeJoin = this.setFreeJoin.bind(this);
2018-09-28 22:42:07 +08:00
this.state = {
numberOfRooms: MIN_BREAKOUT_ROOMS,
2018-09-28 22:42:07 +08:00
durationTime: 1,
freeJoin: false,
2018-09-28 22:42:07 +08:00
};
}
2018-10-24 01:18:09 +08:00
onCreateBreakouts() {
const {
createBreakoutRoom,
2018-10-30 03:29:45 +08:00
meetingName,
intl,
2018-10-24 01:18:09 +08:00
} = this.props;
const { numberOfRooms, durationTime } = this.state;
2018-10-30 03:29:45 +08:00
const rooms = _.range(1, numberOfRooms + 1).map(value => ({
users: [],
name: intl.formatMessage(intlMessages.roomName, {
0: meetingName,
1: value,
}),
freeJoin: this.state.freeJoin,
sequence: value,
}));
2018-10-24 01:18:09 +08:00
createBreakoutRoom(rooms, durationTime, this.state.freeJoin);
2018-10-24 01:18:09 +08:00
}
2018-11-22 00:29:20 +08:00
setFreeJoin(e) {
this.setState({ freeJoin: e.target.checked });
2018-09-28 22:42:07 +08:00
}
increaseDurationTime() {
this.setState({ durationTime: (1 * this.state.durationTime) + 1 });
}
decreaseDurationTime() {
2018-10-02 21:48:12 +08:00
const number = ((1 * this.state.durationTime) - 1);
this.setState({ durationTime: number < 1 ? 1 : number });
2018-09-28 22:42:07 +08:00
}
2018-11-22 00:29:20 +08:00
changeDurationTime(event) {
this.setState({ durationTime: Number.parseInt(event.target.value, 10) || '' });
}
changeNumberOfRooms(event) {
this.setState({ numberOfRooms: Number.parseInt(event.target.value, 10) });
}
2018-09-28 22:42:07 +08:00
render() {
const { intl } = this.props;
return (
<Modal
2018-10-24 01:18:09 +08:00
title={intl.formatMessage(intlMessages.breakoutRoomTitle)}
confirm={
{
label: intl.formatMessage(intlMessages.confirmButton),
callback: this.onCreateBreakouts,
}
}
2018-09-28 22:42:07 +08:00
>
<div className={styles.content}>
<p className={styles.subTitle}>
2018-10-24 01:18:09 +08:00
{intl.formatMessage(intlMessages.breakoutRoomDesc)}
2018-09-28 22:42:07 +08:00
</p>
<div className={styles.breakoutSettings}>
<label htmlFor="numberOfRooms">
2018-10-24 01:18:09 +08:00
<p className={styles.labelText}>{intl.formatMessage(intlMessages.numberOfRooms)}</p>
<select
name="numberOfRooms"
className={styles.inputRooms}
value={this.state.numberOfRooms}
onChange={this.changeNumberOfRooms}
>
2018-09-28 22:42:07 +08:00
{
_.range(MIN_BREAKOUT_ROOMS, MAX_BREAKOUT_ROOMS + 1).map(item => (<option key={_.uniqueId('value-')}>{item}</option>))
}
</select>
</label>
<label htmlFor="breakoutRoomTime" >
2018-10-24 01:18:09 +08:00
<p className={styles.labelText}>{intl.formatMessage(intlMessages.duration)}</p>
2018-09-28 22:42:07 +08:00
<div className={styles.durationArea}>
<input
type="number"
className={styles.duration}
min={MIN_BREAKOUT_ROOMS}
value={this.state.durationTime}
onChange={this.changeDurationTime}
/>
2018-09-28 22:42:07 +08:00
<span>
<HoldButton
2018-10-24 01:18:09 +08:00
key="decrease-breakout-time"
2018-09-28 22:42:07 +08:00
exec={this.decreaseDurationTime}
minBound={MIN_BREAKOUT_ROOMS}
value={this.state.durationTime}
>
<Icon
className={styles.iconsColor}
iconName="substract"
/>
</HoldButton>
<HoldButton
2018-10-24 01:18:09 +08:00
key="increase-breakout-time"
2018-09-28 22:42:07 +08:00
exec={this.increaseDurationTime}
>
<Icon
className={styles.iconsColor}
iconName="add"
/>
</HoldButton>
2018-10-24 01:18:09 +08:00
2018-09-28 22:42:07 +08:00
</span>
</div>
</label>
2018-10-24 01:18:09 +08:00
<p className={styles.randomText}>{intl.formatMessage(intlMessages.randomlyAssign)}</p>
2018-09-28 22:42:07 +08:00
</div>
<label htmlFor="freeJoinCheckbox" className={styles.freeJoinLabel}>
<input
type="checkbox"
className={styles.freeJoinCheckbox}
onChange={this.setFreeJoin}
checked={this.state.freeJoin}
/>
Allow users to choose a breakout room to join
</label>
2018-09-28 22:42:07 +08:00
</div>
</Modal >
);
}
}
export default injectIntl(BreakoutRoom);