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-01-08 14:17:18 +08:00
|
|
|
import { styles } from '../styles';
|
2017-05-04 04:51:17 +08:00
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
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',
|
|
|
|
},
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-04 04:51:17 +08:00
|
|
|
handlePresentationClick() {
|
2017-09-29 21:51:17 +08:00
|
|
|
this.props.mountModal(<PresentationUploaderContainer />);
|
2016-10-18 05:29:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-09-13 04:47:06 +08:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
isUserPresenter,
|
|
|
|
handleShareScreen,
|
2017-11-06 23:39:55 +08:00
|
|
|
handleUnshareScreen,
|
|
|
|
isVideoBroadcasting,
|
2017-09-13 04:47:06 +08:00
|
|
|
} = this.props;
|
2017-03-24 23:37:33 +08:00
|
|
|
|
2017-05-04 04:51:17 +08:00
|
|
|
if (!isUserPresenter) return null;
|
2017-03-24 22:49:38 +08:00
|
|
|
|
2016-10-18 05:29:00 +08:00
|
|
|
return (
|
2017-11-13 20:24:06 +08:00
|
|
|
<Dropdown ref={(ref) => { this._dropdown = ref; }} >
|
|
|
|
<DropdownTrigger tabIndex={0} >
|
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>
|
|
|
|
<DropdownListItem
|
|
|
|
icon="presentation"
|
|
|
|
label={intl.formatMessage(intlMessages.presentationLabel)}
|
|
|
|
description={intl.formatMessage(intlMessages.presentationDesc)}
|
2017-05-04 04:51:17 +08:00
|
|
|
onClick={this.handlePresentationClick}
|
2016-10-18 05:29:00 +08:00
|
|
|
/>
|
2018-01-17 11:17:07 +08:00
|
|
|
{Meteor.settings.public.kurento.enableScreensharing ?
|
|
|
|
<DropdownListItem
|
|
|
|
icon="desktop"
|
|
|
|
label={intl.formatMessage(isVideoBroadcasting ? intlMessages.stopDesktopShareLabel : intlMessages.desktopShareLabel)}
|
|
|
|
description={intl.formatMessage(isVideoBroadcasting ? intlMessages.stopDesktopShareDesc : intlMessages.desktopShareDesc)}
|
|
|
|
onClick={isVideoBroadcasting ? handleUnshareScreen : handleShareScreen }
|
|
|
|
/>
|
|
|
|
: null}
|
2016-10-18 05:29:00 +08:00
|
|
|
</DropdownList>
|
|
|
|
</DropdownContent>
|
|
|
|
</Dropdown>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 20:01:18 +08:00
|
|
|
ActionsDropdown.propTypes = propTypes;
|
|
|
|
|
2017-05-04 04:51:17 +08:00
|
|
|
export default withModalMounter(injectIntl(ActionsDropdown));
|