bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/error-screen/component.jsx

168 lines
3.8 KiB
React
Raw Normal View History

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
2017-03-11 04:47:23 +08:00
import { defineMessages, injectIntl } from 'react-intl';
import Session from '/imports/ui/services/storage/in-memory';
2021-10-28 03:51:43 +08:00
import Styled from './styles';
import intlHolder from '../../core/singletons/intlHolder';
2017-03-11 04:47:23 +08:00
const intlMessages = defineMessages({
503: {
id: 'app.error.503',
},
2017-03-11 04:47:23 +08:00
500: {
id: 'app.error.500',
defaultMessage: 'Oops, something went wrong',
2017-03-11 04:47:23 +08:00
},
2019-04-27 01:52:18 +08:00
410: {
id: 'app.error.410',
},
409: {
id: 'app.error.409',
},
408: {
id: 'app.error.408',
},
2017-03-11 04:47:23 +08:00
404: {
id: 'app.error.404',
defaultMessage: 'Not found',
2017-03-11 04:47:23 +08:00
},
2019-04-27 01:14:37 +08:00
403: {
id: 'app.error.403',
},
2017-03-11 04:47:23 +08:00
401: {
2017-04-18 01:14:31 +08:00
id: 'app.error.401',
2017-03-11 04:47:23 +08:00
},
400: {
id: 'app.error.400',
},
meeting_ended: {
id: 'app.meeting.endedMessage',
},
user_logged_out_reason: {
id: 'app.error.userLoggedOut',
},
validate_token_failed_eject_reason: {
id: 'app.error.ejectedUser',
},
banned_user_rejoining_reason: {
id: 'app.error.userBanned',
},
joined_another_window_reason: {
id: 'app.error.joinedAnotherWindow',
},
user_inactivity_eject_reason: {
id: 'app.meeting.logout.userInactivityEjectReason',
},
user_requested_eject_reason: {
id: 'app.meeting.logout.ejectedFromMeeting',
},
max_participants_reason: {
id: 'app.meeting.logout.maxParticipantsReached',
},
guest_deny: {
id: 'app.guest.guestDeny',
},
duplicate_user_in_meeting_eject_reason: {
id: 'app.meeting.logout.duplicateUserEjectReason',
},
not_enough_permission_eject_reason: {
id: 'app.meeting.logout.permissionEjectReason',
},
able_to_rejoin_user_disconnected_reason: {
id: 'app.error.disconnected.rejoin',
},
user_not_found: {
id: 'app.error.userNotFound',
},
request_timeout: {
id: 'app.error.requestTimeout',
},
meeting_not_found: {
id: 'app.error.meetingNotFound',
},
session_token_replaced: {
id: 'app.error.sessionTokenReplaced',
},
internal_error: {
id: 'app.error.serverInternalError',
},
param_missing: {
id: 'app.error.paramMissing',
},
too_many_connections: {
id: 'app.error.tooManyConnections',
},
server_closed: {
id: 'app.error.serverClosed',
},
2017-03-11 04:47:23 +08:00
});
const propTypes = {
error: PropTypes.object,
2017-03-11 04:47:23 +08:00
};
const defaultProps = {
2023-12-08 02:37:04 +08:00
callback: () => {},
endedReason: null,
error: {},
2017-03-11 04:47:23 +08:00
};
class ErrorScreen extends PureComponent {
componentDidMount() {
const { callback, endedReason } = this.props;
// stop audio
window.dispatchEvent(new Event('StopAudioTracks'));
2024-06-15 03:54:31 +08:00
callback(endedReason, () => {});
console.error({ logCode: 'startup_client_usercouldnotlogin_error' }, 'User could not log in HTML5');
}
2017-03-11 04:47:23 +08:00
render() {
const {
children,
error,
} = this.props;
const formatedMessage = 'Oops, something went wrong';
let errorMessageDescription = Session.getItem('errorMessageDescription');
const intl = intlHolder.getIntl();
if (error) {
errorMessageDescription = error.message;
}
if (intl) {
errorMessageDescription = Session.getItem('errorMessageDescription');
2017-03-11 04:47:23 +08:00
if (errorMessageDescription in intlMessages) {
errorMessageDescription = intl.formatMessage(intlMessages[errorMessageDescription]);
}
}
2017-03-11 04:47:23 +08:00
return (
2021-10-28 03:51:43 +08:00
<Styled.Background>
<Styled.Message data-test="errorScreenMessage">
2017-03-11 04:47:23 +08:00
{formatedMessage}
2021-10-28 03:51:43 +08:00
</Styled.Message>
2019-01-08 00:26:23 +08:00
{
!errorMessageDescription
|| formatedMessage === errorMessageDescription
|| (
2021-10-28 03:51:43 +08:00
<Styled.SessionMessage>
{errorMessageDescription}
2021-10-28 03:51:43 +08:00
</Styled.SessionMessage>
)
2019-01-08 00:26:23 +08:00
}
2018-12-06 01:42:31 +08:00
<div>
2017-03-11 04:47:23 +08:00
{children}
2017-04-29 04:16:07 +08:00
</div>
2021-10-28 03:51:43 +08:00
</Styled.Background>
2017-03-11 04:47:23 +08:00
);
}
}
export default injectIntl(ErrorScreen);
2017-03-11 04:47:23 +08:00
export { ErrorScreen };
2017-03-11 04:47:23 +08:00
ErrorScreen.propTypes = propTypes;
ErrorScreen.defaultProps = defaultProps;