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

82 lines
1.7 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import PropTypes from 'prop-types';
2017-03-11 04:47:23 +08:00
import { defineMessages, injectIntl } from 'react-intl';
import Button from '/imports/ui/components/button/component';
2017-03-11 04:47:23 +08:00
import styles from './styles.scss';
const intlMessages = defineMessages({
500: {
id: 'app.error.500',
defaultMessage: 'Ops, something went wrong',
2017-03-11 04:47:23 +08:00
},
404: {
id: 'app.error.404',
defaultMessage: 'Not found',
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
},
403: {
2017-04-18 01:14:31 +08:00
id: 'app.error.403',
},
2017-04-29 04:16:07 +08:00
leave: {
2017-05-04 00:19:45 +08:00
id: 'app.error.leaveLabel',
2017-04-29 04:16:07 +08:00
description: 'aria-label for leaving',
},
2017-03-11 04:47:23 +08:00
});
const propTypes = {
code: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
};
const defaultProps = {
code: 500,
};
class ErrorScreen extends Component {
2017-04-29 04:16:07 +08:00
onClick() {
window.location = window.location.origin;
}
2017-03-11 04:47:23 +08:00
render() {
const { intl, code, children } = this.props;
let formatedMessage = intl.formatMessage(intlMessages[500]);
if (code in intlMessages) {
formatedMessage = intl.formatMessage(intlMessages[code]);
}
return (
<div className={styles.background}>
<h1 className={styles.code}>
{code}
</h1>
<h1 className={styles.message}>
{formatedMessage}
</h1>
<div className={styles.content}>
{children}
</div>
2017-04-29 04:16:07 +08:00
<div className={styles.content}>
<Button
size={'sm'}
onClick={this.onClick}
2017-05-19 07:16:17 +08:00
label={intl.formatMessage(intlMessages.leave)}
2017-06-03 03:25:02 +08:00
/>
2017-04-29 04:16:07 +08:00
</div>
2017-03-11 04:47:23 +08:00
</div>
);
}
}
export default injectIntl(ErrorScreen);
ErrorScreen.propTypes = propTypes;
ErrorScreen.defaultProps = defaultProps;