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

80 lines
1.6 KiB
React
Raw Normal View History

2017-03-11 04:47:23 +08:00
import React, { Component, PropTypes } from 'react';
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}
label={intl.formatMessage(intlMessages.leave)}/>
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;