2017-09-20 11:12:10 +08:00
|
|
|
import React from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2018-11-28 20:59:03 +08:00
|
|
|
import cx from 'classnames';
|
2017-09-20 11:12:10 +08:00
|
|
|
import Button from '/imports/ui/components/button/component';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
2018-01-19 00:36:34 +08:00
|
|
|
import { styles } from './styles';
|
2017-09-20 11:12:10 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
2019-01-28 21:21:29 +08:00
|
|
|
joinVideo: {
|
|
|
|
id: 'app.video.joinVideo',
|
|
|
|
description: 'Join video button label',
|
2017-09-20 11:12:10 +08:00
|
|
|
},
|
2019-01-28 21:21:29 +08:00
|
|
|
leaveVideo: {
|
|
|
|
id: 'app.video.leaveVideo',
|
|
|
|
description: 'Leave video button label',
|
2017-09-20 11:12:10 +08:00
|
|
|
},
|
2019-01-28 21:21:29 +08:00
|
|
|
videoButtonDesc: {
|
|
|
|
id: 'app.video.videoButtonDesc',
|
|
|
|
description: 'video button description',
|
|
|
|
},
|
2019-03-29 22:31:56 +08:00
|
|
|
videoLocked: {
|
|
|
|
id: 'app.video.videoLocked',
|
2019-01-28 21:21:29 +08:00
|
|
|
description: 'video disabled label',
|
2018-03-23 01:02:59 +08:00
|
|
|
},
|
2017-09-20 11:12:10 +08:00
|
|
|
});
|
|
|
|
|
2018-01-29 19:52:07 +08:00
|
|
|
|
2018-02-26 20:29:28 +08:00
|
|
|
const propTypes = {
|
|
|
|
intl: intlShape.isRequired,
|
|
|
|
isSharingVideo: PropTypes.bool.isRequired,
|
2019-03-23 06:45:44 +08:00
|
|
|
isDisabled: PropTypes.bool.isRequired,
|
|
|
|
handleJoinVideo: PropTypes.func.isRequired,
|
|
|
|
handleCloseVideo: PropTypes.func.isRequired,
|
2018-02-26 20:29:28 +08:00
|
|
|
};
|
2018-02-08 03:20:10 +08:00
|
|
|
|
2019-01-28 21:21:29 +08:00
|
|
|
const JoinVideoButton = ({
|
2018-02-26 20:29:28 +08:00
|
|
|
intl,
|
|
|
|
isSharingVideo,
|
2019-01-28 21:21:29 +08:00
|
|
|
isDisabled,
|
2019-01-03 01:45:53 +08:00
|
|
|
handleJoinVideo,
|
|
|
|
handleCloseVideo,
|
2019-03-29 22:31:56 +08:00
|
|
|
}) => (
|
|
|
|
<Button
|
|
|
|
label={isDisabled
|
|
|
|
? intl.formatMessage(intlMessages.videoLocked)
|
|
|
|
: (isSharingVideo
|
|
|
|
? intl.formatMessage(intlMessages.leaveVideo)
|
|
|
|
: intl.formatMessage(intlMessages.joinVideo)
|
|
|
|
)
|
2019-01-03 01:45:53 +08:00
|
|
|
}
|
2019-03-23 06:45:44 +08:00
|
|
|
className={cx(styles.button, isSharingVideo || styles.btn)}
|
2019-03-29 22:31:56 +08:00
|
|
|
onClick={isSharingVideo ? handleCloseVideo : handleJoinVideo}
|
|
|
|
hideLabel
|
|
|
|
aria-label={intl.formatMessage(intlMessages.videoButtonDesc)}
|
|
|
|
color={isSharingVideo ? 'primary' : 'default'}
|
|
|
|
icon={isSharingVideo ? 'video' : 'video_off'}
|
|
|
|
ghost={!isSharingVideo}
|
|
|
|
size="lg"
|
|
|
|
circle
|
|
|
|
disabled={isDisabled}
|
|
|
|
/>
|
|
|
|
);
|
2019-03-23 06:45:44 +08:00
|
|
|
|
2019-01-28 21:21:29 +08:00
|
|
|
JoinVideoButton.propTypes = propTypes;
|
|
|
|
export default injectIntl(JoinVideoButton);
|