import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl, intlShape } from 'react-intl'; 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'; import PresentationUploaderContainer from '/imports/ui/components/presentation/presentation-uploader/container'; import { withModalMounter } from '/imports/ui/components/modal/service'; import BreakoutRoom from '../create-breakout-room/component'; import { styles } from '../styles'; const propTypes = { isUserPresenter: PropTypes.bool.isRequired, intl: intlShape.isRequired, mountModal: PropTypes.func.isRequired, }; const intlMessages = defineMessages({ actionsLabel: { id: 'app.actionsBar.actionsDropdown.actionsLabel', description: 'Actions button label', }, presentationLabel: { id: 'app.actionsBar.actionsDropdown.presentationLabel', description: 'Upload a presentation option label', }, presentationDesc: { id: 'app.actionsBar.actionsDropdown.presentationDesc', description: 'adds context to upload presentation option', }, desktopShareLabel: { id: 'app.actionsBar.actionsDropdown.desktopShareLabel', description: 'Desktop Share option label', }, stopDesktopShareLabel: { id: 'app.actionsBar.actionsDropdown.stopDesktopShareLabel', description: 'Stop Desktop Share option label', }, desktopShareDesc: { id: 'app.actionsBar.actionsDropdown.desktopShareDesc', description: 'adds context to desktop share option', }, stopDesktopShareDesc: { id: 'app.actionsBar.actionsDropdown.stopDesktopShareDesc', description: 'adds context to stop desktop share option', }, startRecording: { id: 'app.actionsBar.actionsDropdown.startRecording', description: 'start recording option', }, stopRecording: { id: 'app.actionsBar.actionsDropdown.stopRecording', description: 'stop recording option', }, createBreakoutRoom: { id: 'app.actionsBar.actionsDropdown.createBreakoutRoom', description: 'Create breakout room option', }, createBreakoutRoomDesc: { id: 'app.actionsBar.actionsDropdown.createBreakoutRoomDesc', description: 'Description of create breakout room option', }, }); const SHORTCUTS_CONFIG = Meteor.settings.public.app.shortcuts; const OPEN_ACTIONS_AK = SHORTCUTS_CONFIG.openActions.accesskey; class ActionsDropdown extends Component { constructor(props) { super(props); this.handlePresentationClick = this.handlePresentationClick.bind(this); this.handleCreateBreakoutRoomClick = this.handleCreateBreakoutRoomClick.bind(this); } componentWillMount() { this.presentationItemId = _.uniqueId('action-item-'); this.videoItemId = _.uniqueId('action-item-'); this.recordId = _.uniqueId('action-item-'); this.createBreakoutRoomId = _.uniqueId('action-item-'); } componentWillUpdate(nextProps) { const { isUserPresenter: isPresenter } = nextProps; const { isUserPresenter: wasPresenter, mountModal } = this.props; if (wasPresenter && !isPresenter) { mountModal(null); } } getAvailableActions() { const { intl, isUserPresenter, isUserModerator, allowStartStopRecording, isRecording, record, toggleRecording, meetingIsBreakout, hasBreakoutRoom, } = this.props; return _.compact([ (isUserPresenter ? : null), (record && isUserModerator && allowStartStopRecording ? : null), (isUserPresenter && !meetingIsBreakout && !hasBreakoutRoom ? : null), ]); } handlePresentationClick() { this.props.mountModal(); } handleCreateBreakoutRoomClick() { const { createBreakoutRoom, mountModal, } = this.props; mountModal(); } render() { const { intl, isUserPresenter, isUserModerator, } = this.props; const availableActions = this.getAvailableActions(); if ((!isUserPresenter && !isUserModerator) || availableActions.length === 0) return null; return ( { this._dropdown = ref; }} >