2018-07-10 03:04:24 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
|
|
|
import browser from 'browser-detect';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import { styles } from '../styles';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
intl: intlShape.isRequired,
|
|
|
|
isUserPresenter: PropTypes.bool.isRequired,
|
2018-07-25 05:49:40 +08:00
|
|
|
handleShareScreen: PropTypes.func.isRequired,
|
|
|
|
handleUnshareScreen: PropTypes.func.isRequired,
|
|
|
|
isVideoBroadcasting: PropTypes.bool.isRequired,
|
2018-07-10 03:04:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
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',
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const BROWSER_RESULTS = browser();
|
|
|
|
const isMobileBrowser = BROWSER_RESULTS.mobile ||
|
|
|
|
BROWSER_RESULTS.os.includes('Android'); // mobile flag doesn't always work
|
2018-07-25 00:46:30 +08:00
|
|
|
const screenSharingCheck = Meteor.settings.public.kurento.enableScreensharing;
|
2018-07-10 03:04:24 +08:00
|
|
|
|
|
|
|
const DesktopShare = ({
|
|
|
|
intl,
|
|
|
|
handleShareScreen,
|
|
|
|
handleUnshareScreen,
|
|
|
|
isVideoBroadcasting,
|
|
|
|
isUserPresenter,
|
|
|
|
}) => (
|
2018-07-25 00:46:30 +08:00
|
|
|
(screenSharingCheck && !isMobileBrowser && isUserPresenter ?
|
2018-07-25 05:49:40 +08:00
|
|
|
<Button
|
|
|
|
className={styles.button}
|
|
|
|
icon="desktop"
|
|
|
|
label={intl.formatMessage(isVideoBroadcasting ?
|
2018-07-10 03:04:24 +08:00
|
|
|
intlMessages.stopDesktopShareLabel : intlMessages.desktopShareLabel)}
|
2018-07-25 05:49:40 +08:00
|
|
|
description={intl.formatMessage(isVideoBroadcasting ?
|
2018-07-10 03:04:24 +08:00
|
|
|
intlMessages.stopDesktopShareDesc : intlMessages.desktopShareDesc)}
|
2018-07-25 05:49:40 +08:00
|
|
|
color="primary"
|
|
|
|
ghost={false}
|
|
|
|
hideLabel
|
|
|
|
circle
|
|
|
|
size="lg"
|
|
|
|
onClick={isVideoBroadcasting ? handleUnshareScreen : handleShareScreen}
|
2018-07-25 05:10:30 +08:00
|
|
|
id={isVideoBroadcasting ? 'unshare-screen-button' : 'share-screen-button'}
|
2018-07-25 05:49:40 +08:00
|
|
|
/>
|
2018-07-10 03:04:24 +08:00
|
|
|
: null)
|
|
|
|
);
|
|
|
|
|
|
|
|
DesktopShare.propTypes = propTypes;
|
|
|
|
export default injectIntl(DesktopShare);
|