1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/component/error/error-component.jsx

30 lines
822 B
React
Raw Normal View History

2016-11-10 14:26:24 +01:00
import React, { PropTypes } from 'react';
2017-06-29 08:36:10 +02:00
import { Snackbar, Icon } from 'react-mdl';
2016-12-04 11:56:41 +01:00
2016-11-10 14:26:24 +01:00
class ErrorComponent extends React.Component {
static propTypes = {
errors: PropTypes.array.isRequired,
muteError: PropTypes.func.isRequired,
2016-11-10 14:26:24 +01:00
}
render () {
const showError = this.props.errors.length > 0;
const error = showError ? this.props.errors[0] : undefined;
2016-11-24 20:41:05 +01:00
const muteError = () => this.props.muteError(error);
2016-11-10 14:26:24 +01:00
return (
<Snackbar
action="Dismiss"
active={showError}
2016-12-05 16:24:16 +01:00
onActionClick={muteError}
2016-11-24 20:41:05 +01:00
onTimeout={muteError}
2016-12-05 16:24:16 +01:00
timeout={10000}
>
<Icon name="question_answer" /> {error}
</Snackbar>
2016-11-10 14:26:24 +01:00
);
}
}
export default ErrorComponent;