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

32 lines
880 B
React
Raw Normal View History

2016-11-10 14:26:24 +01:00
import Snackbar from 'react-toolbox/lib/snackbar';
import React, { PropTypes } from 'react';
class ErrorComponent extends React.Component {
static propTypes () {
return {
errors: PropTypes.array.isRequired,
muteError: PropTypes.func.isRequired,
};
}
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}
icon="question_answer"
2016-11-24 20:41:05 +01:00
timeout={10000}
2016-11-10 14:26:24 +01:00
label={error}
2016-11-24 20:41:05 +01:00
onClick={muteError}
onTimeout={muteError}
2016-11-10 14:26:24 +01:00
type="warning"
/>
);
}
}
export default ErrorComponent;