2018-11-06 22:59:53 +08:00
|
|
|
import _ from 'lodash';
|
2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-06-07 20:01:18 +08:00
|
|
|
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
2016-10-18 05:29:00 +08:00
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import Dropdown from '/imports/ui/components/dropdown/component';
|
|
|
|
import DropdownTrigger from '/imports/ui/components/dropdown/trigger/component';
|
|
|
|
import DropdownContent from '/imports/ui/components/dropdown/content/component';
|
|
|
|
import DropdownList from '/imports/ui/components/dropdown/list/component';
|
|
|
|
import DropdownListItem from '/imports/ui/components/dropdown/list/item/component';
|
2017-09-29 21:51:17 +08:00
|
|
|
import PresentationUploaderContainer from '/imports/ui/components/presentation/presentation-uploader/container';
|
2017-09-30 04:32:31 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2018-11-01 02:51:56 +08:00
|
|
|
import withShortcutHelper from '/imports/ui/components/shortcut-help/service';
|
2018-09-28 22:42:07 +08:00
|
|
|
import BreakoutRoom from '../create-breakout-room/component';
|
2018-01-08 14:17:18 +08:00
|
|
|
import { styles } from '../styles';
|
2017-05-04 04:51:17 +08:00
|
|
|
|
2018-11-30 01:24:02 +08:00
|
|
|
import ExternalVideoModal from '/imports/ui/components/external-video-player/modal/container';
|
|
|
|
|
2017-06-07 20:01:18 +08:00
|
|
|
const propTypes = {
|
|
|
|
isUserPresenter: PropTypes.bool.isRequired,
|
2017-09-30 04:32:31 +08:00
|
|
|
intl: intlShape.isRequired,
|
2017-06-07 20:01:18 +08:00
|
|
|
mountModal: PropTypes.func.isRequired,
|
2018-12-18 23:15:51 +08:00
|
|
|
isUserModerator: PropTypes.bool.isRequired,
|
|
|
|
meetingIsBreakout: PropTypes.bool.isRequired,
|
|
|
|
hasBreakoutRoom: PropTypes.bool.isRequired,
|
|
|
|
createBreakoutRoom: PropTypes.func.isRequired,
|
|
|
|
meetingName: PropTypes.string.isRequired,
|
|
|
|
shortcuts: PropTypes.string.isRequired,
|
|
|
|
users: PropTypes.arrayOf(PropTypes.object).isRequired,
|
2019-01-11 00:10:45 +08:00
|
|
|
handleTakePresenter: PropTypes.func.isRequired,
|
2017-06-07 20:01:18 +08:00
|
|
|
};
|
|
|
|
|
2016-10-18 05:29:00 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
actionsLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.actionsLabel',
|
2017-04-10 23:50:03 +08:00
|
|
|
description: 'Actions button label',
|
2016-10-18 05:29:00 +08:00
|
|
|
},
|
|
|
|
presentationLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.presentationLabel',
|
2017-04-10 23:50:03 +08:00
|
|
|
description: 'Upload a presentation option label',
|
2016-10-18 05:29:00 +08:00
|
|
|
},
|
|
|
|
presentationDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.presentationDesc',
|
2017-04-11 21:52:30 +08:00
|
|
|
description: 'adds context to upload presentation option',
|
2016-10-18 05:29:00 +08:00
|
|
|
},
|
|
|
|
desktopShareLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.desktopShareLabel',
|
2017-04-10 23:50:03 +08:00
|
|
|
description: 'Desktop Share option label',
|
2016-10-18 05:29:00 +08:00
|
|
|
},
|
2017-11-06 23:39:55 +08:00
|
|
|
stopDesktopShareLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.stopDesktopShareLabel',
|
|
|
|
description: 'Stop Desktop Share option label',
|
|
|
|
},
|
2016-10-18 05:29:00 +08:00
|
|
|
desktopShareDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.desktopShareDesc',
|
2017-04-11 21:52:30 +08:00
|
|
|
description: 'adds context to desktop share option',
|
2016-10-18 05:29:00 +08:00
|
|
|
},
|
2017-11-06 23:39:55 +08:00
|
|
|
stopDesktopShareDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.stopDesktopShareDesc',
|
|
|
|
description: 'adds context to stop desktop share option',
|
|
|
|
},
|
2018-09-24 06:20:20 +08:00
|
|
|
pollBtnLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.pollBtnLabel',
|
|
|
|
description: 'poll menu toggle button label',
|
|
|
|
},
|
|
|
|
pollBtnDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.pollBtnDesc',
|
|
|
|
description: 'poll menu toggle button description',
|
|
|
|
},
|
2018-09-26 01:03:09 +08:00
|
|
|
createBreakoutRoom: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.createBreakoutRoom',
|
|
|
|
description: 'Create breakout room option',
|
|
|
|
},
|
|
|
|
createBreakoutRoomDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.createBreakoutRoomDesc',
|
|
|
|
description: 'Description of create breakout room option',
|
|
|
|
},
|
2018-12-28 00:20:03 +08:00
|
|
|
invitationItem: {
|
|
|
|
id: 'app.invitation.title',
|
|
|
|
description: 'invitation to breakout title',
|
|
|
|
},
|
2019-01-11 00:10:45 +08:00
|
|
|
takePresenter: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.takePresenter',
|
|
|
|
description: 'Label for take presenter role option',
|
|
|
|
},
|
|
|
|
takePresenterDesc: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.takePresenterDesc',
|
|
|
|
description: 'Description of take presenter role option',
|
|
|
|
},
|
2018-11-30 01:24:02 +08:00
|
|
|
externalVideoLabel: {
|
|
|
|
id: 'app.actionsBar.actionsDropdown.shareExternalVideo',
|
|
|
|
description: 'Share external video button',
|
|
|
|
},
|
2016-10-18 05:29:00 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
class ActionsDropdown extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2017-05-04 04:51:17 +08:00
|
|
|
this.handlePresentationClick = this.handlePresentationClick.bind(this);
|
2018-09-28 22:42:07 +08:00
|
|
|
this.handleCreateBreakoutRoomClick = this.handleCreateBreakoutRoomClick.bind(this);
|
2018-12-28 00:20:03 +08:00
|
|
|
this.onCreateBreakouts = this.onCreateBreakouts.bind(this);
|
|
|
|
this.onInvitationUsers = this.onInvitationUsers.bind(this);
|
2017-05-04 04:51:17 +08:00
|
|
|
|
2018-01-18 05:51:33 +08:00
|
|
|
this.presentationItemId = _.uniqueId('action-item-');
|
2018-02-16 03:42:50 +08:00
|
|
|
this.recordId = _.uniqueId('action-item-');
|
2018-09-24 06:20:20 +08:00
|
|
|
this.pollId = _.uniqueId('action-item-');
|
2018-09-28 22:42:07 +08:00
|
|
|
this.createBreakoutRoomId = _.uniqueId('action-item-');
|
2019-01-11 00:10:45 +08:00
|
|
|
this.takePresenterId = _.uniqueId('action-item-');
|
|
|
|
|
|
|
|
this.handlePresentationClick = this.handlePresentationClick.bind(this);
|
|
|
|
this.handleCreateBreakoutRoomClick = this.handleCreateBreakoutRoomClick.bind(this);
|
2018-01-18 05:51:33 +08:00
|
|
|
}
|
|
|
|
|
2017-10-24 18:52:44 +08:00
|
|
|
componentWillUpdate(nextProps) {
|
|
|
|
const { isUserPresenter: isPresenter } = nextProps;
|
2017-10-13 06:44:38 +08:00
|
|
|
const { isUserPresenter: wasPresenter, mountModal } = this.props;
|
|
|
|
if (wasPresenter && !isPresenter) {
|
|
|
|
mountModal(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-28 00:20:03 +08:00
|
|
|
onCreateBreakouts() {
|
|
|
|
return this.handleCreateBreakoutRoomClick(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
onInvitationUsers() {
|
|
|
|
return this.handleCreateBreakoutRoomClick(true);
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:34:35 +08:00
|
|
|
getAvailableActions() {
|
|
|
|
const {
|
|
|
|
intl,
|
2018-02-16 03:42:50 +08:00
|
|
|
isUserPresenter,
|
|
|
|
isUserModerator,
|
2018-11-30 01:24:02 +08:00
|
|
|
allowExternalVideo,
|
2018-10-24 01:18:09 +08:00
|
|
|
meetingIsBreakout,
|
|
|
|
hasBreakoutRoom,
|
2018-12-28 00:20:03 +08:00
|
|
|
getUsersNotAssigned,
|
|
|
|
users,
|
2019-01-11 00:10:45 +08:00
|
|
|
handleTakePresenter,
|
2018-01-17 21:34:35 +08:00
|
|
|
} = this.props;
|
|
|
|
|
2018-12-18 23:15:51 +08:00
|
|
|
const {
|
|
|
|
pollBtnLabel,
|
|
|
|
pollBtnDesc,
|
|
|
|
presentationLabel,
|
|
|
|
presentationDesc,
|
|
|
|
startRecording,
|
|
|
|
stopRecording,
|
|
|
|
createBreakoutRoom,
|
|
|
|
createBreakoutRoomDesc,
|
2018-12-28 19:51:41 +08:00
|
|
|
invitationItem,
|
2019-01-11 00:10:45 +08:00
|
|
|
takePresenter,
|
|
|
|
takePresenterDesc,
|
2018-12-18 23:15:51 +08:00
|
|
|
} = intlMessages;
|
|
|
|
|
|
|
|
const {
|
|
|
|
formatMessage,
|
|
|
|
} = intl;
|
|
|
|
|
2019-01-17 01:41:21 +08:00
|
|
|
const canInviteUsers = isUserModerator
|
2018-12-28 19:51:41 +08:00
|
|
|
&& !meetingIsBreakout
|
|
|
|
&& hasBreakoutRoom
|
|
|
|
&& getUsersNotAssigned(users).length;
|
|
|
|
|
2018-01-17 21:34:35 +08:00
|
|
|
return _.compact([
|
2018-12-18 23:15:51 +08:00
|
|
|
(isUserPresenter
|
|
|
|
? (
|
|
|
|
<DropdownListItem
|
|
|
|
icon="user"
|
|
|
|
label={formatMessage(pollBtnLabel)}
|
|
|
|
description={formatMessage(pollBtnDesc)}
|
|
|
|
key={this.pollId}
|
|
|
|
onClick={() => {
|
|
|
|
Session.set('openPanel', 'poll');
|
|
|
|
Session.set('forcePollOpen', true);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
2019-01-12 03:15:31 +08:00
|
|
|
: (
|
|
|
|
<DropdownListItem
|
|
|
|
icon="presentation"
|
|
|
|
label={formatMessage(takePresenter)}
|
|
|
|
description={formatMessage(takePresenterDesc)}
|
|
|
|
key={this.takePresenterId}
|
|
|
|
onClick={() => handleTakePresenter()}
|
|
|
|
/>
|
|
|
|
)),
|
2018-12-10 10:12:42 +08:00
|
|
|
(isUserPresenter
|
|
|
|
? (
|
|
|
|
<DropdownListItem
|
|
|
|
data-test="uploadPresentation"
|
|
|
|
icon="presentation"
|
2018-12-18 23:15:51 +08:00
|
|
|
label={formatMessage(presentationLabel)}
|
|
|
|
description={formatMessage(presentationDesc)}
|
2018-12-10 10:12:42 +08:00
|
|
|
key={this.presentationItemId}
|
|
|
|
onClick={this.handlePresentationClick}
|
|
|
|
/>
|
|
|
|
)
|
2018-02-21 02:23:35 +08:00
|
|
|
: null),
|
2018-12-11 07:07:20 +08:00
|
|
|
(isUserPresenter && allowExternalVideo
|
|
|
|
? (
|
|
|
|
<DropdownListItem
|
|
|
|
icon="video"
|
|
|
|
label={intl.formatMessage(intlMessages.externalVideoLabel)}
|
|
|
|
description="External Video"
|
|
|
|
key="external-video"
|
|
|
|
onClick={this.handleExternalVideoClick}
|
|
|
|
/>
|
|
|
|
)
|
2018-11-30 01:24:02 +08:00
|
|
|
: null),
|
2019-01-04 04:50:43 +08:00
|
|
|
(isUserModerator && !meetingIsBreakout && !hasBreakoutRoom
|
|
|
|
? (
|
|
|
|
<DropdownListItem
|
|
|
|
icon="rooms"
|
|
|
|
label={intl.formatMessage(intlMessages.createBreakoutRoom)}
|
|
|
|
description={intl.formatMessage(intlMessages.createBreakoutRoomDesc)}
|
|
|
|
key={this.createBreakoutRoomId}
|
2018-12-28 00:20:03 +08:00
|
|
|
onClick={this.onCreateBreakouts}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
: null),
|
2019-01-17 01:41:21 +08:00
|
|
|
(canInviteUsers
|
2018-12-28 00:20:03 +08:00
|
|
|
? (
|
|
|
|
<DropdownListItem
|
|
|
|
icon="rooms"
|
|
|
|
label={formatMessage(invitationItem)}
|
|
|
|
key={this.createBreakoutRoomId}
|
|
|
|
onClick={this.onInvitationUsers}
|
2019-01-04 04:50:43 +08:00
|
|
|
/>
|
|
|
|
)
|
2018-09-26 01:03:09 +08:00
|
|
|
: null),
|
2018-01-17 21:34:35 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2018-11-30 01:24:02 +08:00
|
|
|
handleExternalVideoClick = () => {
|
|
|
|
this.props.mountModal(<ExternalVideoModal />);
|
|
|
|
}
|
|
|
|
|
2018-02-21 02:23:35 +08:00
|
|
|
handlePresentationClick() {
|
2018-12-18 23:15:51 +08:00
|
|
|
const { mountModal } = this.props;
|
|
|
|
mountModal(<PresentationUploaderContainer />);
|
2018-02-21 02:23:35 +08:00
|
|
|
}
|
2018-12-10 10:12:42 +08:00
|
|
|
|
2018-12-28 19:51:41 +08:00
|
|
|
handleCreateBreakoutRoomClick(isInvitation) {
|
2018-10-24 01:18:09 +08:00
|
|
|
const {
|
|
|
|
createBreakoutRoom,
|
|
|
|
mountModal,
|
2018-10-30 03:29:45 +08:00
|
|
|
meetingName,
|
2018-11-27 20:44:22 +08:00
|
|
|
users,
|
2018-12-28 00:20:03 +08:00
|
|
|
getUsersNotAssigned,
|
|
|
|
getBreakouts,
|
2018-12-28 19:51:41 +08:00
|
|
|
sendInvitation,
|
2018-10-24 01:18:09 +08:00
|
|
|
} = this.props;
|
2018-11-27 20:44:22 +08:00
|
|
|
|
|
|
|
mountModal(
|
|
|
|
<BreakoutRoom
|
2018-12-28 00:20:03 +08:00
|
|
|
{...{
|
|
|
|
createBreakoutRoom,
|
|
|
|
meetingName,
|
|
|
|
users,
|
|
|
|
getUsersNotAssigned,
|
2018-12-28 19:51:41 +08:00
|
|
|
isInvitation,
|
2018-12-28 00:20:03 +08:00
|
|
|
getBreakouts,
|
2018-12-28 19:51:41 +08:00
|
|
|
sendInvitation,
|
2018-12-28 00:20:03 +08:00
|
|
|
}}
|
2018-12-18 23:15:51 +08:00
|
|
|
/>,
|
|
|
|
);
|
2018-09-28 22:42:07 +08:00
|
|
|
}
|
2018-02-21 02:23:35 +08:00
|
|
|
|
2016-10-18 05:29:00 +08:00
|
|
|
render() {
|
2017-09-13 04:47:06 +08:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
isUserPresenter,
|
2018-02-16 03:42:50 +08:00
|
|
|
isUserModerator,
|
2018-11-01 02:51:56 +08:00
|
|
|
shortcuts: OPEN_ACTIONS_AK,
|
2017-09-13 04:47:06 +08:00
|
|
|
} = this.props;
|
2017-03-24 23:37:33 +08:00
|
|
|
|
2018-01-17 21:34:35 +08:00
|
|
|
const availableActions = this.getAvailableActions();
|
|
|
|
|
2018-02-28 22:10:00 +08:00
|
|
|
if ((!isUserPresenter && !isUserModerator) || availableActions.length === 0) return null;
|
2017-03-24 22:49:38 +08:00
|
|
|
|
2016-10-18 05:29:00 +08:00
|
|
|
return (
|
2018-12-10 10:12:42 +08:00
|
|
|
<Dropdown ref={(ref) => { this._dropdown = ref; }}>
|
2018-05-02 08:02:45 +08:00
|
|
|
<DropdownTrigger tabIndex={0} accessKey={OPEN_ACTIONS_AK}>
|
2016-10-18 05:29:00 +08:00
|
|
|
<Button
|
2017-12-11 21:47:50 +08:00
|
|
|
hideLabel
|
|
|
|
aria-label={intl.formatMessage(intlMessages.actionsLabel)}
|
2017-11-13 20:24:06 +08:00
|
|
|
className={styles.button}
|
2016-10-18 05:29:00 +08:00
|
|
|
label={intl.formatMessage(intlMessages.actionsLabel)}
|
2017-12-12 01:09:09 +08:00
|
|
|
icon="plus"
|
2016-10-18 05:29:00 +08:00
|
|
|
color="primary"
|
|
|
|
size="lg"
|
2017-06-03 03:25:02 +08:00
|
|
|
circle
|
2016-10-18 05:29:00 +08:00
|
|
|
onClick={() => null}
|
|
|
|
/>
|
|
|
|
</DropdownTrigger>
|
|
|
|
<DropdownContent placement="top left">
|
|
|
|
<DropdownList>
|
2018-01-17 21:34:35 +08:00
|
|
|
{availableActions}
|
2016-10-18 05:29:00 +08:00
|
|
|
</DropdownList>
|
|
|
|
</DropdownContent>
|
|
|
|
</Dropdown>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 20:01:18 +08:00
|
|
|
ActionsDropdown.propTypes = propTypes;
|
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
export default withShortcutHelper(withModalMounter(injectIntl(ActionsDropdown)), 'openActions');
|