bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-controls/component.jsx

94 lines
2.8 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
2018-06-19 23:38:09 +08:00
import cx from 'classnames';
import { defineMessages, intlShape, injectIntl } from 'react-intl';
import Button from '/imports/ui/components/button/component';
2018-01-08 14:17:18 +08:00
import { styles } from './styles';
const intlMessages = defineMessages({
joinAudio: {
id: 'app.audio.joinAudio',
description: 'Join audio button label',
},
leaveAudio: {
id: 'app.audio.leaveAudio',
description: 'Leave audio button label',
},
muteAudio: {
id: 'app.actionsBar.muteLabel',
description: 'Mute audio button label',
},
unmuteAudio: {
id: 'app.actionsBar.unmuteLabel',
description: 'Unmute audio button label',
},
});
const propTypes = {
handleToggleMuteMicrophone: PropTypes.func.isRequired,
handleJoinAudio: PropTypes.func.isRequired,
handleLeaveAudio: PropTypes.func.isRequired,
2017-10-23 20:41:09 +08:00
disable: PropTypes.bool.isRequired,
2018-06-19 23:38:09 +08:00
unmute: PropTypes.bool,
mute: PropTypes.bool.isRequired,
join: PropTypes.bool.isRequired,
intl: intlShape.isRequired,
2017-12-14 03:03:14 +08:00
glow: PropTypes.bool,
};
const defaultProps = {
2017-12-14 03:19:26 +08:00
glow: false,
2018-06-19 23:38:09 +08:00
unmute: false,
};
2018-05-01 05:09:56 +08:00
const SHORTCUTS_CONFIG = Meteor.settings.public.app.shortcuts;
2018-05-02 08:02:45 +08:00
const JOIN_AUDIO_AK = SHORTCUTS_CONFIG.joinAudio.accesskey;
const LEAVE_AUDIO_AK = SHORTCUTS_CONFIG.leaveAudio.accesskey;
const MUTE_UNMUTE_AK = SHORTCUTS_CONFIG.toggleMute.accesskey;
2018-05-01 05:09:56 +08:00
const AudioControls = ({
handleToggleMuteMicrophone,
handleJoinAudio,
handleLeaveAudio,
mute,
unmute,
2017-10-20 18:11:51 +08:00
disable,
2017-11-17 19:52:48 +08:00
glow,
join,
intl,
}) => (
<span className={styles.container}>
{mute ?
<Button
2017-11-17 19:52:48 +08:00
className={glow ? cx(styles.button, styles.glow) : styles.button}
onClick={handleToggleMuteMicrophone}
2017-10-23 20:41:09 +08:00
disabled={disable}
hideLabel
label={unmute ? intl.formatMessage(intlMessages.unmuteAudio) : intl.formatMessage(intlMessages.muteAudio)}
aria-label={unmute ? intl.formatMessage(intlMessages.unmuteAudio) : intl.formatMessage(intlMessages.muteAudio)}
2017-12-14 03:03:14 +08:00
color="primary"
icon={unmute ? 'mute' : 'unmute'}
2017-12-14 03:03:14 +08:00
size="lg"
circle
2018-05-02 08:02:45 +08:00
accessKey={MUTE_UNMUTE_AK}
/> : null}
<Button
className={styles.button}
onClick={join ? handleLeaveAudio : handleJoinAudio}
2017-10-23 20:41:09 +08:00
disabled={disable}
hideLabel
aria-label={join ? intl.formatMessage(intlMessages.leaveAudio) : intl.formatMessage(intlMessages.joinAudio)}
label={join ? intl.formatMessage(intlMessages.leaveAudio) : intl.formatMessage(intlMessages.joinAudio)}
color={join ? 'danger' : 'primary'}
icon={join ? 'audio_off' : 'audio_on'}
2017-12-14 03:03:14 +08:00
size="lg"
circle
2018-05-02 08:02:45 +08:00
accessKey={join ? LEAVE_AUDIO_AK : JOIN_AUDIO_AK}
/>
</span>);
AudioControls.propTypes = propTypes;
2017-12-14 03:03:14 +08:00
AudioControls.defaultProps = defaultProps;
export default injectIntl(AudioControls);