bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-provider/video-button/component.jsx

85 lines
2.2 KiB
React
Raw Normal View History

import React, { memo } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
2017-09-20 11:12:10 +08:00
import Button from '/imports/ui/components/button/component';
2019-11-28 21:13:06 +08:00
import VideoService from '../service';
import { defineMessages, injectIntl } from 'react-intl';
import { styles } from './styles';
2019-11-28 21:13:06 +08:00
import { validIOSVersion } from '/imports/ui/components/app/service';
2017-09-20 11:12:10 +08:00
const intlMessages = defineMessages({
joinVideo: {
id: 'app.video.joinVideo',
description: 'Join video button label',
2017-09-20 11:12:10 +08:00
},
2019-12-19 01:44:56 +08:00
leaveVideo: {
id: 'app.video.leaveVideo',
description: 'Leave video button label',
},
videoButtonDesc: {
id: 'app.video.videoButtonDesc',
description: 'video button description',
},
2019-03-29 22:31:56 +08:00
videoLocked: {
id: 'app.video.videoLocked',
description: 'video disabled label',
2018-03-23 01:02:59 +08:00
},
iOSWarning: {
id: 'app.iOSWarning.label',
description: 'message indicating to upgrade ios version',
},
2017-09-20 11:12:10 +08:00
});
const propTypes = {
intl: PropTypes.object.isRequired,
2019-11-28 21:13:06 +08:00
hasVideoStream: PropTypes.bool.isRequired,
isDisabled: PropTypes.bool.isRequired,
2019-12-19 01:44:56 +08:00
mountVideoPreview: PropTypes.func.isRequired,
};
const JoinVideoButton = ({
intl,
2019-11-28 21:13:06 +08:00
hasVideoStream,
isDisabled,
2019-12-19 01:44:56 +08:00
mountVideoPreview,
}) => {
2019-12-19 01:44:56 +08:00
const exitVideo = () => hasVideoStream && !VideoService.isMultipleCamerasEnabled();
2019-11-28 21:13:06 +08:00
const handleOnClick = () => {
if (!validIOSVersion()) {
return VideoService.notify(intl.formatMessage(intlMessages.iOSWarning));
}
2019-12-19 01:44:56 +08:00
if (exitVideo()) {
VideoService.exitVideo();
} else {
mountVideoPreview();
}
};
2019-12-19 01:44:56 +08:00
const label = exitVideo() ?
intl.formatMessage(intlMessages.leaveVideo) :
intl.formatMessage(intlMessages.joinVideo);
return (
<Button
2020-03-05 03:00:45 +08:00
data-test="joinVideo"
2019-12-19 01:44:56 +08:00
label={isDisabled ? intl.formatMessage(intlMessages.videoLocked) : label}
2019-11-28 21:13:06 +08:00
className={cx(styles.button, hasVideoStream || styles.btn)}
onClick={handleOnClick}
hideLabel
aria-label={intl.formatMessage(intlMessages.videoButtonDesc)}
2019-11-28 21:13:06 +08:00
color={hasVideoStream ? 'primary' : 'default'}
icon={hasVideoStream ? 'video' : 'video_off'}
ghost={!hasVideoStream}
size="lg"
circle
disabled={isDisabled}
/>
);
};
JoinVideoButton.propTypes = propTypes;
2019-12-19 01:44:56 +08:00
export default injectIntl(memo(JoinVideoButton));