2017-11-17 19:52:48 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
2024-04-04 22:47:01 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2021-11-10 00:20:34 +08:00
|
|
|
import Styled from './styles';
|
2017-11-17 19:52:48 +08:00
|
|
|
|
2024-04-04 22:47:01 +08:00
|
|
|
const propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2024-04-17 01:33:23 +08:00
|
|
|
isListenOnly: PropTypes.bool.isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
isConnected: PropTypes.bool.isRequired,
|
2024-04-04 22:47:01 +08:00
|
|
|
audioErr: PropTypes.shape({
|
|
|
|
code: PropTypes.number,
|
|
|
|
message: PropTypes.string,
|
|
|
|
MIC_ERROR: PropTypes.shape({
|
|
|
|
NO_SSL: PropTypes.number,
|
|
|
|
MAC_OS_BLOCK: PropTypes.number,
|
|
|
|
NO_PERMISSION: PropTypes.number,
|
|
|
|
}),
|
|
|
|
}).isRequired,
|
|
|
|
handleBack: PropTypes.func.isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
handleRetryMic: PropTypes.func.isRequired,
|
|
|
|
handleJoinListenOnly: PropTypes.func.isRequired,
|
2024-04-04 22:47:01 +08:00
|
|
|
troubleshootingLink: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
troubleshootingLink: '',
|
|
|
|
};
|
|
|
|
|
2017-11-17 19:52:48 +08:00
|
|
|
const intlMessages = defineMessages({
|
2024-04-17 01:33:23 +08:00
|
|
|
helpSubtitleMic: {
|
|
|
|
id: 'app.audioModal.helpSubtitleMic',
|
|
|
|
description: 'Text description for the audio help subtitle (microphones)',
|
|
|
|
},
|
2024-06-05 19:26:27 +08:00
|
|
|
helpSubtitlePermission: {
|
|
|
|
id: 'app.audioModal.helpSubtitlePermission',
|
|
|
|
description: 'Text description for the audio help subtitle (permission)',
|
|
|
|
},
|
2024-04-17 01:33:23 +08:00
|
|
|
helpSubtitleGeneric: {
|
|
|
|
id: 'app.audioModal.helpSubtitleGeneric',
|
|
|
|
description: 'Text description for the audio help subtitle (generic)',
|
2024-04-04 22:47:01 +08:00
|
|
|
},
|
|
|
|
helpPermissionStep1: {
|
|
|
|
id: 'app.audioModal.helpPermissionStep1',
|
|
|
|
description: 'Text description for the audio permission help step 1',
|
2017-11-17 19:52:48 +08:00
|
|
|
},
|
2024-04-04 22:47:01 +08:00
|
|
|
helpPermissionStep2: {
|
|
|
|
id: 'app.audioModal.helpPermissionStep2',
|
|
|
|
description: 'Text description for the audio permission help step 2',
|
|
|
|
},
|
|
|
|
helpPermissionStep3: {
|
|
|
|
id: 'app.audioModal.helpPermissionStep3',
|
|
|
|
description: 'Text description for the audio permission help step 3',
|
|
|
|
},
|
2024-06-05 19:26:27 +08:00
|
|
|
backLabel: {
|
|
|
|
id: 'app.audio.backLabel',
|
|
|
|
description: 'audio settings back button label',
|
|
|
|
},
|
|
|
|
retryMicLabel: {
|
|
|
|
id: 'app.audio.audioSettings.retryMicLabel',
|
2024-04-04 22:47:01 +08:00
|
|
|
description: 'audio settings retry button label',
|
2019-09-27 21:52:29 +08:00
|
|
|
},
|
2024-06-05 19:26:27 +08:00
|
|
|
listenOnlyLabel: {
|
|
|
|
id: 'app.audioModal.listenOnlyLabel',
|
|
|
|
description: 'audio settings listen only button label',
|
|
|
|
},
|
2019-09-27 21:52:29 +08:00
|
|
|
noSSL: {
|
|
|
|
id: 'app.audioModal.help.noSSL',
|
2024-04-04 22:47:01 +08:00
|
|
|
description: 'Text description for domain not using https',
|
2019-09-27 21:52:29 +08:00
|
|
|
},
|
|
|
|
macNotAllowed: {
|
|
|
|
id: 'app.audioModal.help.macNotAllowed',
|
2024-04-04 22:47:01 +08:00
|
|
|
description: 'Text description for mac needed to enable OS setting',
|
|
|
|
},
|
|
|
|
helpTroubleshoot: {
|
|
|
|
id: 'app.audioModal.help.troubleshoot',
|
|
|
|
description: 'Text description for help troubleshoot',
|
|
|
|
},
|
|
|
|
unknownError: {
|
|
|
|
id: 'app.audioModal.help.unknownError',
|
|
|
|
description: 'Text description for unknown error',
|
|
|
|
},
|
|
|
|
errorCode: {
|
|
|
|
id: 'app.audioModal.help.errorCode',
|
|
|
|
description: 'Text description for error code',
|
2019-09-27 21:52:29 +08:00
|
|
|
},
|
|
|
|
});
|
2017-11-17 19:52:48 +08:00
|
|
|
|
|
|
|
class Help extends Component {
|
2024-04-17 01:33:23 +08:00
|
|
|
getSubtitle() {
|
2024-06-05 19:26:27 +08:00
|
|
|
const { audioErr, intl, isListenOnly } = this.props;
|
|
|
|
const { MIC_ERROR } = audioErr;
|
|
|
|
|
|
|
|
if (audioErr.code === MIC_ERROR.NO_PERMISSION) {
|
|
|
|
return intl.formatMessage(intlMessages.helpSubtitlePermission);
|
|
|
|
}
|
2024-04-17 01:33:23 +08:00
|
|
|
|
|
|
|
return !isListenOnly
|
|
|
|
? intl.formatMessage(intlMessages.helpSubtitleMic)
|
|
|
|
: intl.formatMessage(intlMessages.helpSubtitleGeneric);
|
|
|
|
}
|
|
|
|
|
2024-04-04 22:47:01 +08:00
|
|
|
renderNoSSL() {
|
|
|
|
const { intl } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Styled.Text>
|
|
|
|
{intl.formatMessage(intlMessages.noSSL)}
|
|
|
|
</Styled.Text>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderMacNotAllowed() {
|
|
|
|
const { intl } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Styled.Text>
|
|
|
|
{intl.formatMessage(intlMessages.macNotAllowed)}
|
|
|
|
</Styled.Text>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderPermissionHelp() {
|
|
|
|
const { intl } = this.props;
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Styled.Text>
|
2024-04-17 01:33:23 +08:00
|
|
|
{this.getSubtitle()}
|
2024-04-04 22:47:01 +08:00
|
|
|
</Styled.Text>
|
|
|
|
<Styled.PermissionHelpSteps>
|
|
|
|
<li>{intl.formatMessage(intlMessages.helpPermissionStep1)}</li>
|
|
|
|
<li>{intl.formatMessage(intlMessages.helpPermissionStep2)}</li>
|
|
|
|
<li>{intl.formatMessage(intlMessages.helpPermissionStep3)}</li>
|
|
|
|
</Styled.PermissionHelpSteps>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2017-11-17 19:52:48 +08:00
|
|
|
|
2024-04-04 22:47:01 +08:00
|
|
|
renderGenericErrorHelp() {
|
|
|
|
const { intl, audioErr } = this.props;
|
|
|
|
const { code, message } = audioErr;
|
2019-09-30 22:54:34 +08:00
|
|
|
|
2024-04-04 22:47:01 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Styled.Text>
|
2024-04-17 01:33:23 +08:00
|
|
|
{this.getSubtitle()}
|
2024-04-04 22:47:01 +08:00
|
|
|
</Styled.Text>
|
|
|
|
<Styled.Text>
|
|
|
|
{intl.formatMessage(intlMessages.unknownError)}
|
|
|
|
</Styled.Text>
|
|
|
|
<Styled.UnknownError>
|
|
|
|
{intl.formatMessage(intlMessages.errorCode, { 0: code, 1: message || 'UnknownError' })}
|
|
|
|
</Styled.UnknownError>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2019-09-27 21:52:29 +08:00
|
|
|
|
2024-04-04 22:47:01 +08:00
|
|
|
renderHelpMessage() {
|
|
|
|
const { audioErr } = this.props;
|
|
|
|
const { MIC_ERROR } = audioErr;
|
|
|
|
|
|
|
|
switch (audioErr.code) {
|
2019-09-30 22:54:34 +08:00
|
|
|
case MIC_ERROR.NO_SSL:
|
2024-04-04 22:47:01 +08:00
|
|
|
return this.renderNoSSL();
|
2019-09-30 22:54:34 +08:00
|
|
|
case MIC_ERROR.MAC_OS_BLOCK:
|
2024-04-04 22:47:01 +08:00
|
|
|
return this.renderMacNotAllowed();
|
2019-09-30 22:54:34 +08:00
|
|
|
case MIC_ERROR.NO_PERMISSION:
|
2024-04-04 22:47:01 +08:00
|
|
|
return this.renderPermissionHelp();
|
2019-09-27 21:52:29 +08:00
|
|
|
default:
|
2024-04-04 22:47:01 +08:00
|
|
|
return this.renderGenericErrorHelp();
|
2019-09-27 21:52:29 +08:00
|
|
|
}
|
2024-04-04 22:47:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
2024-06-05 19:26:27 +08:00
|
|
|
isConnected,
|
2024-04-04 22:47:01 +08:00
|
|
|
handleBack,
|
2024-06-05 19:26:27 +08:00
|
|
|
handleRetryMic,
|
|
|
|
handleJoinListenOnly,
|
2024-04-04 22:47:01 +08:00
|
|
|
troubleshootingLink,
|
|
|
|
} = this.props;
|
2019-09-27 21:52:29 +08:00
|
|
|
|
2017-11-17 19:52:48 +08:00
|
|
|
return (
|
2021-11-10 00:20:34 +08:00
|
|
|
<Styled.Help>
|
2024-04-04 22:47:01 +08:00
|
|
|
{this.renderHelpMessage()}
|
|
|
|
{ troubleshootingLink && (
|
|
|
|
<Styled.Text>
|
|
|
|
<Styled.TroubleshootLink
|
|
|
|
href={troubleshootingLink}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
{intl.formatMessage(intlMessages.helpTroubleshoot)}
|
|
|
|
</Styled.TroubleshootLink>
|
|
|
|
</Styled.Text>
|
|
|
|
)}
|
2021-11-10 00:20:34 +08:00
|
|
|
<Styled.EnterAudio>
|
2024-06-05 19:26:27 +08:00
|
|
|
{!isConnected ? (
|
|
|
|
<Styled.HelpActionButton
|
|
|
|
label={intl.formatMessage(intlMessages.listenOnlyLabel)}
|
|
|
|
data-test="helpListenOnlyBtn"
|
|
|
|
icon="listen"
|
|
|
|
size="md"
|
|
|
|
color="secondary"
|
|
|
|
onClick={handleJoinListenOnly}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Styled.HelpActionButton
|
|
|
|
label={intl.formatMessage(intlMessages.backLabel)}
|
|
|
|
data-test="helpBackBtn"
|
|
|
|
color="secondary"
|
|
|
|
size="md"
|
|
|
|
onClick={handleBack}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<Styled.HelpActionButton
|
|
|
|
label={intl.formatMessage(intlMessages.retryMicLabel)}
|
|
|
|
data-test="helpRetryMicBtn"
|
|
|
|
icon="unmute"
|
2019-09-27 21:52:29 +08:00
|
|
|
size="md"
|
|
|
|
color="primary"
|
2024-06-05 19:26:27 +08:00
|
|
|
onClick={handleRetryMic}
|
2017-11-17 19:52:48 +08:00
|
|
|
/>
|
2021-11-10 00:20:34 +08:00
|
|
|
</Styled.EnterAudio>
|
|
|
|
</Styled.Help>
|
2019-09-27 21:52:29 +08:00
|
|
|
);
|
2017-11-17 19:52:48 +08:00
|
|
|
}
|
2019-09-27 21:52:29 +08:00
|
|
|
}
|
2017-11-17 19:52:48 +08:00
|
|
|
|
2024-04-04 22:47:01 +08:00
|
|
|
Help.propTypes = propTypes;
|
|
|
|
Help.defaultProps = defaultProps;
|
|
|
|
|
2017-11-17 19:52:48 +08:00
|
|
|
export default injectIntl(Help);
|