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

76 lines
1.7 KiB
React
Raw Normal View History

import React 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';
import { withRouter } from 'react-router';
import { styles } from './styles';
2017-03-11 04:47:23 +08:00
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
},
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 React.PureComponent {
2017-03-11 04:47:23 +08:00
render() {
const {
intl, code, children, router,
} = this.props;
2017-03-11 04:47:23 +08:00
let formatedMessage = intl.formatMessage(intlMessages[defaultProps.code]);
2017-03-11 04:47:23 +08:00
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={() => router.push('/logout/')}
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 withRouter(injectIntl(ErrorScreen));
2017-03-11 04:47:23 +08:00
ErrorScreen.propTypes = propTypes;
ErrorScreen.defaultProps = defaultProps;