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

90 lines
2.3 KiB
React
Raw Normal View History

2017-10-04 04:42:10 +08:00
import React, { Component } from 'react';
2017-10-12 05:04:10 +08:00
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import Session from '/imports/ui/services/storage/in-memory';
2021-11-10 00:11:19 +08:00
import Styled from './styles';
2017-10-04 04:42:10 +08:00
const intlMessages = defineMessages({
2018-04-04 00:48:02 +08:00
confirmLabel: {
2017-10-04 04:42:10 +08:00
id: 'app.audioModal.yes',
description: 'Hear yourself yes',
},
2018-04-04 00:48:02 +08:00
disconfirmLabel: {
2017-10-04 04:42:10 +08:00
id: 'app.audioModal.no',
description: 'Hear yourself no',
},
2018-04-04 00:48:02 +08:00
confirmAriaLabel: {
id: 'app.audioModal.yes.arialabel',
description: 'provides better context for yes btn label',
},
2018-04-04 00:48:02 +08:00
disconfirmAriaLabel: {
id: 'app.audioModal.no.arialabel',
description: 'provides better context for no btn label',
},
2017-10-04 04:42:10 +08:00
});
2017-10-12 05:04:10 +08:00
const propTypes = {
handleYes: PropTypes.func.isRequired,
handleNo: PropTypes.func.isRequired,
2021-08-09 22:24:02 +08:00
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
2017-10-12 05:04:10 +08:00
};
2017-10-04 04:42:10 +08:00
class EchoTest extends Component {
constructor(props) {
super(props);
2018-05-15 04:32:28 +08:00
this.state = {
disabled: false,
};
2017-10-05 04:49:11 +08:00
this.handleYes = props.handleYes.bind(this);
this.handleNo = props.handleNo.bind(this);
2017-10-04 04:42:10 +08:00
}
componentDidMount() {
Session.setItem('inEchoTest', true);
}
componentWillUnmount() {
Session.setItem('inEchoTest', false);
}
2017-10-04 04:42:10 +08:00
render() {
const {
intl,
} = this.props;
2021-08-09 22:24:02 +08:00
const { disabled } = this.state;
const disableYesButtonClicked = (callback) => () => {
2018-05-15 04:32:28 +08:00
this.setState({ disabled: true }, callback);
};
2017-10-04 04:42:10 +08:00
return (
2021-11-10 00:11:19 +08:00
<Styled.EchoTest>
<Styled.EchoTestButton
2018-04-04 00:48:02 +08:00
label={intl.formatMessage(intlMessages.confirmLabel)}
aria-label={intl.formatMessage(intlMessages.confirmAriaLabel)}
2022-01-20 21:03:18 +08:00
data-test="echoYesBtn"
icon="thumbs_up"
2021-08-09 22:24:02 +08:00
disabled={disabled}
2017-10-04 04:42:10 +08:00
circle
color="success"
size="jumbo"
2018-05-15 04:32:28 +08:00
onClick={disableYesButtonClicked(this.handleYes)}
2017-10-04 04:42:10 +08:00
/>
2021-11-10 00:11:19 +08:00
<Styled.EchoTestButton
2018-04-04 00:48:02 +08:00
label={intl.formatMessage(intlMessages.disconfirmLabel)}
aria-label={intl.formatMessage(intlMessages.disconfirmAriaLabel)}
icon="thumbs_down"
2017-10-04 04:42:10 +08:00
circle
color="danger"
size="jumbo"
2017-10-12 05:04:10 +08:00
onClick={this.handleNo}
2017-10-04 04:42:10 +08:00
/>
2021-11-10 00:11:19 +08:00
</Styled.EchoTest>
2017-10-04 04:42:10 +08:00
);
}
}
export default injectIntl(EchoTest);
2017-10-12 05:04:10 +08:00
EchoTest.propTypes = propTypes;