bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-provider/video-button/component.jsx
2020-09-09 15:07:32 -03:00

95 lines
2.5 KiB
JavaScript
Executable File

import React, { memo } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Button from '/imports/ui/components/button/component';
import VideoService from '../service';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import { styles } from './styles';
import { validIOSVersion } from '/imports/ui/components/app/service';
const intlMessages = defineMessages({
joinVideo: {
id: 'app.video.joinVideo',
description: 'Join video button label',
},
leaveVideo: {
id: 'app.video.leaveVideo',
description: 'Leave video button label',
},
videoButtonDesc: {
id: 'app.video.videoButtonDesc',
description: 'video button description',
},
videoLocked: {
id: 'app.video.videoLocked',
description: 'video disabled label',
},
videoConnecting: {
id: 'app.video.connecting',
description: 'video connecting label',
},
dataSaving: {
id: 'app.video.dataSaving',
description: 'video data saving label',
},
meteorDisconnected: {
id: 'app.meeting.disconnected',
description: 'Meteor disconnected label',
},
iOSWarning: {
id: 'app.iOSWarning.label',
description: 'message indicating to upgrade ios version',
},
});
const propTypes = {
intl: intlShape.isRequired,
hasVideoStream: PropTypes.bool.isRequired,
mountVideoPreview: PropTypes.func.isRequired,
};
const JoinVideoButton = ({
intl,
hasVideoStream,
disableReason,
mountVideoPreview,
}) => {
const exitVideo = () => hasVideoStream && !VideoService.isMultipleCamerasEnabled();
const handleOnClick = () => {
if (!validIOSVersion()) {
return VideoService.notify(intl.formatMessage(intlMessages.iOSWarning));
}
if (exitVideo()) {
VideoService.exitVideo();
} else {
mountVideoPreview();
}
};
const label = exitVideo() ?
intl.formatMessage(intlMessages.leaveVideo) :
intl.formatMessage(intlMessages.joinVideo);
return (
<Button
label={disableReason ? intl.formatMessage(intlMessages[disableReason]) : label}
className={cx(styles.button, hasVideoStream || styles.btn)}
onClick={handleOnClick}
hideLabel
aria-label={intl.formatMessage(intlMessages.videoButtonDesc)}
color={hasVideoStream ? 'primary' : 'default'}
icon={hasVideoStream ? 'video' : 'video_off'}
ghost={!hasVideoStream}
size="lg"
circle
disabled={!!disableReason}
/>
);
};
JoinVideoButton.propTypes = propTypes;
export default injectIntl(memo(JoinVideoButton));